[rs] Remove interface blocks from the water shaders

This commit is contained in:
Dzmitry Malyshau
2020-06-17 10:58:30 -04:00
parent 0d807b7d26
commit 9cd109e67c
10 changed files with 19 additions and 27 deletions

Binary file not shown.

View File

@@ -2,11 +2,9 @@
layout(early_fragment_tests) in;
layout(location = 0) in PerVertex {
vec4 v_Colour;
// Comment this out if using user-clipping planes:
float v_ClipDist;
};
layout(location = 0) in vec4 v_Colour;
// Comment this out if using user-clipping planes:
layout(location = 1) in float v_ClipDist;
layout(location = 0) out vec4 outColour;

View File

@@ -14,11 +14,9 @@ layout(location = 0) in vec3 position;
layout(location = 1) in vec3 normal;
layout(location = 2) in vec4 colour;
layout(location = 0) out PerVertex {
vec4 v_Colour;
// Comment this out if using user-clipping planes:
float v_ClipDist;
};
layout(location = 0) out vec4 v_Colour;
// Comment this out if using user-clipping planes:
layout(location = 1) out float v_ClipDist;
void main() {
gl_Position = projection_view * vec4(position, 1.0);

View File

@@ -15,11 +15,9 @@ layout(set = 0, binding = 1) uniform texture2D reflection;
layout(set = 0, binding = 2) uniform texture2D terrain_depth_tex;
layout(set = 0, binding = 3) uniform sampler colour_sampler;
layout(location = 0) in PerVertex {
vec2 f_WaterScreenPos;
float f_Fresnel;
vec3 f_Light;
} f_In;
layout(location = 0) in vec2 f_WaterScreenPos;
layout(location = 1) in float f_Fresnel;
layout(location = 2) in vec3 f_Light;
layout(location = 0) out vec4 outColor;
@@ -30,17 +28,17 @@ float to_linear_depth(float depth) {
}
void main() {
vec3 reflection_colour = texture(sampler2D(reflection, colour_sampler), f_In.f_WaterScreenPos.xy).xyz;
vec3 reflection_colour = texture(sampler2D(reflection, colour_sampler), f_WaterScreenPos.xy).xyz;
float pixel_depth = to_linear_depth(gl_FragCoord.z);
float terrain_depth = to_linear_depth(texture(sampler2D(terrain_depth_tex, colour_sampler), gl_FragCoord.xy / vec2(time_size_width.w, viewport_height)).r);
float dist = terrain_depth - pixel_depth;
float clamped = smoothstep(0.0, 1.0, dist);
float clamped = pow(smoothstep(0.0, 1.5, dist), 4.8);
outColor.a = clamped * (1.0 - f_In.f_Fresnel);
outColor.a = clamped * (1.0 - f_Fresnel);
vec3 final_colour = f_In.f_Light + reflection_colour;
vec3 final_colour = f_Light + reflection_colour;
vec3 depth_colour = mix(final_colour, water_colour, smoothstep(1.0, 5.0, dist) * 0.2);

View File

@@ -17,11 +17,9 @@ const float INV_1_CURVE_BIAS = 1.0 / (1.0 + CURVE_BIAS);
layout(location = 0) in ivec2 position;
layout(location = 1) in ivec4 offsets;
layout(location = 0) out PerVertex {
vec2 f_WaterScreenPos;
float f_Fresnel;
vec3 f_Light;
} f_In;
layout(location = 0) out vec2 f_WaterScreenPos;
layout(location = 1) out float f_Fresnel;
layout(location = 2) out vec3 f_Light;
//
// The following code to calculate simplex 3D
@@ -201,13 +199,13 @@ void main() {
vec4 transformed_light = vm * vec4(light_point, 1.0);
f_In.f_Light = light_colour * calc_specular(eye, normal, normalize(water_pos.xyz - (transformed_light.xyz / transformed_light.w)));
f_In.f_Fresnel = calc_fresnel(eye, normal);
f_Light = light_colour * calc_specular(eye, normal, normalize(water_pos.xyz - (transformed_light.xyz / transformed_light.w)));
f_Fresnel = calc_fresnel(eye, normal);
vec4 projected_pos = projection * transformed_pos;
gl_Position = projected_pos;
vec4 gridpos = projection * vm * original_pos;
f_In.f_WaterScreenPos.xy = (0.5 * gridpos.xy / gridpos.w) + 0.5;
f_WaterScreenPos.xy = (0.5 * gridpos.xy / gridpos.w) + 0.5;
}