@firecms/neat 0.9.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/NeatGradient.d.ts +8 -0
- package/dist/NeatGradient.js +67 -6
- package/dist/NeatGradient.js.map +1 -1
- package/dist/index.es.js +313 -285
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +31 -29
- package/dist/index.umd.js.map +1 -1
- package/dist/math.d.ts +1 -0
- package/dist/math.js +20 -0
- package/dist/math.js.map +1 -1
- package/dist/shaders.d.ts +2 -2
- package/dist/shaders.js +19 -17
- package/dist/shaders.js.map +1 -1
- package/dist/types.d.ts +1 -0
- package/package.json +4 -1
- package/src/NeatGradient.ts +71 -5
- package/src/math.ts +8 -0
- package/src/shaders.ts +19 -17
- package/src/types.ts +1 -0
package/src/shaders.ts
CHANGED
|
@@ -44,7 +44,7 @@ export const vertexShaderSource = `void main() {
|
|
|
44
44
|
vec3 color = u_colors[0].color;
|
|
45
45
|
|
|
46
46
|
vec3 distortedPos = position;
|
|
47
|
-
if (
|
|
47
|
+
if (u_flat_shading < 0.5) {
|
|
48
48
|
if (u_flow_enabled > 0.5) {
|
|
49
49
|
if (u_flow_ease > 0.0 || u_flow_distortion_a > 0.0) {
|
|
50
50
|
vec3 ppp = position / 25.0;
|
|
@@ -64,7 +64,7 @@ export const vertexShaderSource = `void main() {
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
vec3 noise_cord;
|
|
67
|
-
if (
|
|
67
|
+
if (u_flat_shading < 0.5) {
|
|
68
68
|
noise_cord = vec3(distortedPos.x / 50.0, (distortedPos.y + colorOffset) / 50.0, distortedPos.z / 50.0);
|
|
69
69
|
} else {
|
|
70
70
|
vec2 adjustedUv = flowUv;
|
|
@@ -83,7 +83,7 @@ export const vertexShaderSource = `void main() {
|
|
|
83
83
|
float noiseSeed = 13. + float(i) * 7.;
|
|
84
84
|
|
|
85
85
|
float noise_z = u_time * noiseSpeed;
|
|
86
|
-
if (
|
|
86
|
+
if (u_flat_shading < 0.5) {
|
|
87
87
|
noise_z = noise_cord.z * u_color_pressure.x * u_color_pressure.x + u_time * noiseSpeed;
|
|
88
88
|
}
|
|
89
89
|
|
|
@@ -124,7 +124,7 @@ float fbm(vec3 x) {
|
|
|
124
124
|
float value = 0.0;
|
|
125
125
|
float amplitude = 0.5;
|
|
126
126
|
float frequency = 1.0;
|
|
127
|
-
for (int i = 0; i <
|
|
127
|
+
for (int i = 0; i < 2; i++) {
|
|
128
128
|
value += amplitude * snoise(x * frequency);
|
|
129
129
|
frequency *= 2.0;
|
|
130
130
|
amplitude *= 0.5;
|
|
@@ -145,7 +145,7 @@ void main() {
|
|
|
145
145
|
float texAlpha = 1.0;
|
|
146
146
|
|
|
147
147
|
if (u_enable_procedural_texture > 0.5) {
|
|
148
|
-
if (
|
|
148
|
+
if (u_flat_shading < 0.5) {
|
|
149
149
|
float parallaxFactor = 0.25;
|
|
150
150
|
float scrollOffset = (u_y_offset * u_y_offset_color_multiplier) * parallaxFactor;
|
|
151
151
|
vec3 scrolledPos = vPosition;
|
|
@@ -156,9 +156,9 @@ void main() {
|
|
|
156
156
|
vec2 uvY = p.zx + vec2(0.5);
|
|
157
157
|
vec2 uvZ = p.xy + vec2(0.5);
|
|
158
158
|
|
|
159
|
-
vec4 colX = texture2D(u_procedural_texture,
|
|
160
|
-
vec4 colY = texture2D(u_procedural_texture,
|
|
161
|
-
vec4 colZ = texture2D(u_procedural_texture,
|
|
159
|
+
vec4 colX = texture2D(u_procedural_texture, uvX);
|
|
160
|
+
vec4 colY = texture2D(u_procedural_texture, uvY);
|
|
161
|
+
vec4 colZ = texture2D(u_procedural_texture, uvZ);
|
|
162
162
|
|
|
163
163
|
vec3 n = normalize(vNormal);
|
|
164
164
|
vec3 blendWeights = abs(n);
|
|
@@ -185,7 +185,7 @@ void main() {
|
|
|
185
185
|
texUv.y -= (u_y_offset * u_y_offset_color_multiplier / u_plane_height) * parallaxFactor;
|
|
186
186
|
texUv *= 1.5;
|
|
187
187
|
|
|
188
|
-
vec4 texSample = texture2D(u_procedural_texture,
|
|
188
|
+
vec4 texSample = texture2D(u_procedural_texture, texUv);
|
|
189
189
|
baseColor = texSample.rgb;
|
|
190
190
|
if (u_transparent_texture_void > 0.5) {
|
|
191
191
|
texAlpha = texSample.a;
|
|
@@ -200,7 +200,7 @@ void main() {
|
|
|
200
200
|
// === DOMAIN WARPING (simplified: 3 fbm calls instead of 5) ===
|
|
201
201
|
if (u_domain_warp_enabled > 0.5) {
|
|
202
202
|
vec3 p;
|
|
203
|
-
if (
|
|
203
|
+
if (u_flat_shading < 0.5) {
|
|
204
204
|
p = vec3((vPosition / 50.0 + vec3(0.5)) * u_domain_warp_scale);
|
|
205
205
|
p.z += u_time * 0.15;
|
|
206
206
|
} else {
|
|
@@ -237,8 +237,8 @@ void main() {
|
|
|
237
237
|
float specular = pow(max(dot(normal, halfDir), 0.0), 32.0);
|
|
238
238
|
|
|
239
239
|
// Blend smooth 3D shading with smooth height-based wave shading
|
|
240
|
-
if (
|
|
241
|
-
//
|
|
240
|
+
if (u_flat_shading > 0.5) {
|
|
241
|
+
// Flat / height-based wave shading (plane style)
|
|
242
242
|
color += v_displacement_amount * u_highlights;
|
|
243
243
|
float heightShadow = 1.0 - v_displacement_amount;
|
|
244
244
|
color -= heightShadow * heightShadow * u_shadows;
|
|
@@ -270,7 +270,7 @@ void main() {
|
|
|
270
270
|
// === VIGNETTE ===
|
|
271
271
|
if (u_vignette_intensity > 0.0) {
|
|
272
272
|
vec2 vigUv = vUv;
|
|
273
|
-
if (
|
|
273
|
+
if (u_flat_shading < 0.5) {
|
|
274
274
|
vigUv = (v_new_position.xy / v_new_position.w) * 0.5 + vec2(0.5);
|
|
275
275
|
}
|
|
276
276
|
float dist = length(vigUv - vec2(0.5));
|
|
@@ -289,7 +289,7 @@ void main() {
|
|
|
289
289
|
if (u_chromatic_aberration > 0.0) {
|
|
290
290
|
float caAmount = u_chromatic_aberration * 0.008;
|
|
291
291
|
vec2 caUv = vUv;
|
|
292
|
-
if (
|
|
292
|
+
if (u_flat_shading < 0.5) {
|
|
293
293
|
caUv = (v_new_position.xy / v_new_position.w) * 0.5 + vec2(0.5);
|
|
294
294
|
}
|
|
295
295
|
float dist = length(caUv - vec2(0.5));
|
|
@@ -303,7 +303,7 @@ void main() {
|
|
|
303
303
|
float grain = 0.0;
|
|
304
304
|
if (u_grain_intensity > 0.0) {
|
|
305
305
|
vec2 noiseCoords = gl_FragCoord.xy / u_grain_scale;
|
|
306
|
-
if (u_grain_speed != 0.0 ||
|
|
306
|
+
if (u_grain_speed != 0.0 || u_flat_shading > 0.5) {
|
|
307
307
|
grain = fbm(vec3(noiseCoords, u_time * u_grain_speed));
|
|
308
308
|
} else {
|
|
309
309
|
// Static grain: use cheap hash instead of fbm
|
|
@@ -320,8 +320,8 @@ void main() {
|
|
|
320
320
|
|
|
321
321
|
float edgeAlpha = 1.0;
|
|
322
322
|
|
|
323
|
-
// Silhouette falloff for 3D shapes
|
|
324
|
-
if (
|
|
323
|
+
// Silhouette falloff for 3D shapes (skip when flat shading or fade is zero)
|
|
324
|
+
if (u_silhouette_fade > 0.0 && u_flat_shading < 0.5) {
|
|
325
325
|
edgeAlpha = smoothstep(0.0, u_silhouette_fade, ndotv);
|
|
326
326
|
}
|
|
327
327
|
|
|
@@ -396,6 +396,7 @@ uniform float u_fresnel_intensity;
|
|
|
396
396
|
uniform vec3 u_fresnel_color;
|
|
397
397
|
|
|
398
398
|
uniform float u_shape_type;
|
|
399
|
+
uniform float u_flat_shading;
|
|
399
400
|
`;
|
|
400
401
|
}
|
|
401
402
|
|
|
@@ -470,6 +471,7 @@ uniform float u_transparent_texture_void;
|
|
|
470
471
|
uniform float u_silhouette_fade;
|
|
471
472
|
uniform float u_cylinder_fade;
|
|
472
473
|
uniform float u_ribbon_fade;
|
|
474
|
+
uniform float u_flat_shading;
|
|
473
475
|
`;
|
|
474
476
|
}
|
|
475
477
|
|