mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-22 23:30:14 +00:00
Add ambient insect particles near water vegetation, fix firefly particles, and improve water foam
- Spawn dark point-sprite insects buzzing around cattails/reeds/kelp/seaweed - Fix firefly M2 particles: exempt from alpha dampening and forced gravity - Make water shoreline/crest foam more irregular with UV warping and bluer tint
This commit is contained in:
parent
c35b40391f
commit
4db97e37b7
9 changed files with 332 additions and 20 deletions
14
assets/shaders/swim_insect.frag.glsl
Normal file
14
assets/shaders/swim_insect.frag.glsl
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#version 450
|
||||
|
||||
layout(location = 0) in float vAlpha;
|
||||
|
||||
layout(location = 0) out vec4 outColor;
|
||||
|
||||
void main() {
|
||||
vec2 p = gl_PointCoord - vec2(0.5);
|
||||
float dist = length(p);
|
||||
if (dist > 0.5) discard;
|
||||
float alpha = smoothstep(0.5, 0.05, dist) * vAlpha;
|
||||
// Dark brown/black insect color
|
||||
outColor = vec4(0.12, 0.08, 0.05, alpha);
|
||||
}
|
||||
BIN
assets/shaders/swim_insect.frag.spv
Normal file
BIN
assets/shaders/swim_insect.frag.spv
Normal file
Binary file not shown.
|
|
@ -130,20 +130,26 @@ float fbmNoise(vec2 p, float time) {
|
|||
}
|
||||
|
||||
// Voronoi-like cellular noise for foam particles
|
||||
float cellularFoam(vec2 p) {
|
||||
// jitter parameter controls how much cell points deviate from grid centers
|
||||
// (0.0 = regular grid, 1.0 = fully random within cell)
|
||||
float cellularFoam(vec2 p, float jitter) {
|
||||
vec2 i = floor(p);
|
||||
vec2 f = fract(p);
|
||||
float minDist = 1.0;
|
||||
for (int y = -1; y <= 1; y++) {
|
||||
for (int x = -1; x <= 1; x++) {
|
||||
vec2 neighbor = vec2(float(x), float(y));
|
||||
vec2 point = vec2(hash21(i + neighbor), hash22x(i + neighbor));
|
||||
vec2 cellId = i + neighbor;
|
||||
// Jittered cell point — higher jitter = more irregular placement
|
||||
vec2 point = vec2(hash21(cellId), hash22x(cellId)) * jitter
|
||||
+ vec2(0.5) * (1.0 - jitter);
|
||||
float d = length(neighbor + point - f);
|
||||
minDist = min(minDist, d);
|
||||
}
|
||||
}
|
||||
return minDist;
|
||||
}
|
||||
float cellularFoam(vec2 p) { return cellularFoam(p, 1.0); }
|
||||
|
||||
void main() {
|
||||
float time = fogParams.z;
|
||||
|
|
@ -299,24 +305,32 @@ void main() {
|
|||
if (basicType < 1.5 && verticalDepth > 0.01 && push.waveAmp > 0.0) {
|
||||
float foamDepthMask = 1.0 - smoothstep(0.0, 1.8, verticalDepth);
|
||||
|
||||
// Warp UV coords with noise to break up cellular regularity
|
||||
vec2 warpOffset = vec2(
|
||||
noiseValue(FragPos.xy * 2.5 + time * 0.08) - 0.5,
|
||||
noiseValue(FragPos.xy * 2.5 + vec2(37.0) + time * 0.06) - 0.5
|
||||
) * 1.6;
|
||||
vec2 foamUV = FragPos.xy + warpOffset;
|
||||
|
||||
// Fine scattered particles
|
||||
float cells1 = cellularFoam(FragPos.xy * 14.0 + time * vec2(0.15, 0.08));
|
||||
float foam1 = (1.0 - smoothstep(0.0, 0.10, cells1)) * 0.5;
|
||||
float cells1 = cellularFoam(foamUV * 14.0 + time * vec2(0.15, 0.08));
|
||||
float foam1 = (1.0 - smoothstep(0.0, 0.12, cells1)) * 0.45;
|
||||
|
||||
// Tiny spray dots
|
||||
float cells2 = cellularFoam(FragPos.xy * 30.0 + time * vec2(-0.12, 0.22));
|
||||
float foam2 = (1.0 - smoothstep(0.0, 0.06, cells2)) * 0.35;
|
||||
float cells2 = cellularFoam(foamUV * 28.0 + time * vec2(-0.12, 0.22));
|
||||
float foam2 = (1.0 - smoothstep(0.0, 0.07, cells2)) * 0.3;
|
||||
|
||||
// Micro specks
|
||||
float cells3 = cellularFoam(FragPos.xy * 55.0 + time * vec2(0.25, -0.1));
|
||||
float foam3 = (1.0 - smoothstep(0.0, 0.04, cells3)) * 0.2;
|
||||
float cells3 = cellularFoam(foamUV * 50.0 + time * vec2(0.25, -0.1));
|
||||
float foam3 = (1.0 - smoothstep(0.0, 0.05, cells3)) * 0.18;
|
||||
|
||||
// Noise breakup for clumping
|
||||
float noiseMask = noiseValue(FragPos.xy * 3.0 + time * 0.15);
|
||||
float foam = (foam1 + foam2 + foam3) * foamDepthMask * smoothstep(0.3, 0.6, noiseMask);
|
||||
|
||||
foam *= smoothstep(0.0, 0.1, verticalDepth);
|
||||
color = mix(color, vec3(0.92, 0.95, 0.98), clamp(foam, 0.0, 0.45));
|
||||
// Bluer foam tint instead of near-white
|
||||
color = mix(color, vec3(0.68, 0.78, 0.88), clamp(foam, 0.0, 0.40));
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
|
|
@ -324,11 +338,15 @@ void main() {
|
|||
// ============================================================
|
||||
if (basicType > 0.5 && basicType < 1.5 && push.waveAmp > 0.0) {
|
||||
float crestMask = smoothstep(0.5, 1.0, WaveOffset);
|
||||
float crestCells = cellularFoam(FragPos.xy * 6.0 + time * vec2(0.12, 0.08));
|
||||
vec2 crestWarp = vec2(
|
||||
noiseValue(FragPos.xy * 1.8 + time * 0.1) - 0.5,
|
||||
noiseValue(FragPos.xy * 1.8 + vec2(53.0) + time * 0.07) - 0.5
|
||||
) * 2.0;
|
||||
float crestCells = cellularFoam((FragPos.xy + crestWarp) * 6.0 + time * vec2(0.12, 0.08));
|
||||
float crestFoam = (1.0 - smoothstep(0.0, 0.18, crestCells)) * crestMask;
|
||||
float crestNoise = noiseValue(FragPos.xy * 3.0 - time * 0.3);
|
||||
crestFoam *= smoothstep(0.3, 0.6, crestNoise);
|
||||
color = mix(color, vec3(0.92, 0.95, 0.98), crestFoam * 0.35);
|
||||
color = mix(color, vec3(0.68, 0.78, 0.88), crestFoam * 0.30);
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue