Skip to content

Commit

Permalink
Merge branch 'ripple-tweaks' into 'master'
Browse files Browse the repository at this point in the history
Ripple shader tweaks

See merge request OpenMW/openmw!4351
  • Loading branch information
psi29a committed Sep 9, 2024
2 parents fc7c141 + 82fe345 commit 7a6fa45
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion files/shaders/compatibility/ripples_blobber.frag
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void main()
for (int i = 0; i < positionCount; ++i)
{
float wavesize = wavesizeMultiplier * positions[i].z;
float displace = clamp(2.0 * abs(length((positions[i].xy + offset) - gl_FragCoord.xy) / wavesize - 1.0), 0.0, 1.0);
float displace = clamp(0.2 * abs(length((positions[i].xy + offset) - gl_FragCoord.xy) / wavesize - 1.0) + 0.8, 0.0, 1.0);
color.rg = mix(vec2(-1.0), color.rg, displace);
}

Expand Down
2 changes: 1 addition & 1 deletion files/shaders/core/ripples_blobber.comp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void main()
for (int i = 0; i < positionCount; ++i)
{
float wavesize = wavesizeMultiplier * positions[i].z;
float displace = clamp(2.0 * abs(length((positions[i].xy + offset) - vec2(gl_GlobalInvocationID.xy)) / wavesize - 1.0), 0.0, 1.0);
float displace = clamp(0.2 * abs(length((positions[i].xy + offset) - vec2(gl_GlobalInvocationID.xy)) / wavesize - 1.0) + 0.8, 0.0, 1.0);
color.rg = mix(vec2(-1.0), color.rg, displace);
}

Expand Down
8 changes: 4 additions & 4 deletions files/shaders/lib/water/ripples.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ vec4 applySprings(in vec4 samplerData, in vec4 n, in vec4 n2)
vec4 storage = vec4(0.0, samplerData.r, 0.0, 0.0);

// Tweak to look most like water, not a physically accurate simulation
const float a = 0.14;
const float udamp = 0.02;
const float vdamp = 0.02;
const float a = 0.28;
const float udamp = 0.04;
const float vdamp = 0.04;

// Apply 2d wave equation with dampening
// Continous impulse needed to maintain simulation, otherwise ripples will fade
float nsum = n.x + n.y + n.z + n.w;
storage.r = a * nsum + ((2.0 - udamp - vdamp) - 4.0 * a) * samplerData.r - (1.0 - vdamp) * samplerData.g;

// Calculate normal and store in blue-alpha channel
storage.ba = 2.0 * (n.xy - n.zw) + 0.5 * (n2.xy - n2.zw);
storage.ba = 2.0 * (n.xz - n.yw) + 0.5 * (n2.xz - n2.yw);

return storage;
}
Expand Down

0 comments on commit 7a6fa45

Please sign in to comment.