Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert MR672 #3059

Merged
merged 1 commit into from
Mar 31, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 5 additions & 13 deletions files/shaders/water_fragment.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,20 @@ const float BUMP_RAIN = 2.5;
const float REFL_BUMP = 0.10; // reflection distortion amount
const float REFR_BUMP = 0.07; // refraction distortion amount

const float SCATTER_AMOUNT = 0.3; // amount of sunlight scattering
const vec3 SCATTER_COLOUR = vec3(0.0,1.0,0.95); // colour of sunlight scattering

const vec3 SUN_EXT = vec3(0.45, 0.55, 0.68); //sunlight extinction

const float SPEC_HARDNESS = 256.0; // specular highlights hardness

const float BUMP_SUPPRESS_DEPTH = 300.0; // at what water depth bumpmap will be suppressed for reflections and refractions (prevents artifacts at shores)
const float BUMP_SUPPRESS_DEPTH_SS = 1000.0; // modifier using screenspace depth (helps prevent same artifacts but at higher distances)

const vec2 WIND_DIR = vec2(0.5f, -0.8f);
const float WIND_SPEED = 0.2f;

const vec3 WATER_COLOR = vec3(0.090195, 0.115685, 0.12745);

const float SCATTER_AMOUNT = 0.5; // amount of sunlight scattering
const vec3 SCATTER_COLOUR = WATER_COLOR * 8.0; // colour of sunlight scattering

// ---------------- rain ripples related stuff ---------------------

const float RAIN_RIPPLE_GAPS = 5.0;
Expand Down Expand Up @@ -219,10 +218,7 @@ void main(void)
float depthSampleDistorted = linearizeDepth(texture2D(refractionDepthMap,screenCoords-screenCoordsOffset).x) * radialise;
float surfaceDepth = linearizeDepth(gl_FragCoord.z) * radialise;
float realWaterDepth = depthSample - surfaceDepth; // undistorted water depth in view direction, independent of frustum
screenCoordsOffset *= clamp(
realWaterDepth / (BUMP_SUPPRESS_DEPTH
* max(1, depthSample / BUMP_SUPPRESS_DEPTH_SS)) // suppress more at distance
,0 ,1);
screenCoordsOffset *= clamp(realWaterDepth / BUMP_SUPPRESS_DEPTH,0,1);
#endif
// reflection
vec3 reflection = texture2D(reflectionMap, screenCoords + screenCoordsOffset).rgb;
Expand All @@ -240,11 +236,7 @@ void main(void)
if (cameraPos.z < 0.0)
refraction = clamp(refraction * 1.5, 0.0, 1.0);
else
{
vec3 refractionA = mix(refraction, waterColor, clamp(depthSampleDistorted/VISIBILITY, 0.0, 1.0));
vec3 refractionB = mix(refraction, waterColor, clamp(realWaterDepth/VISIBILITY, 0.0, 1.0));
refraction = mix(refractionA, refractionB, 0.8);
}
refraction = mix(refraction, waterColor, clamp(depthSampleDistorted/VISIBILITY, 0.0, 1.0));

// sunlight scattering
// normal for sunlight scattering
Expand Down