diff --git a/wgpu/examples/cube/shader.frag.spv b/wgpu/examples/cube/shader.frag.spv index 95a79e2e15..f41e3c9ecc 100644 Binary files a/wgpu/examples/cube/shader.frag.spv and b/wgpu/examples/cube/shader.frag.spv differ diff --git a/wgpu/examples/hello-compute/shader.comp.spv b/wgpu/examples/hello-compute/shader.comp.spv index 972544e0f9..417dd3c5ed 100644 Binary files a/wgpu/examples/hello-compute/shader.comp.spv and b/wgpu/examples/hello-compute/shader.comp.spv differ diff --git a/wgpu/examples/water/terrain_shader.frag b/wgpu/examples/water/terrain_shader.frag index 0c903b2195..895b179023 100644 --- a/wgpu/examples/water/terrain_shader.frag +++ b/wgpu/examples/water/terrain_shader.frag @@ -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; diff --git a/wgpu/examples/water/terrain_shader.frag.spv b/wgpu/examples/water/terrain_shader.frag.spv index 33e27fea05..aa54ce6d05 100644 Binary files a/wgpu/examples/water/terrain_shader.frag.spv and b/wgpu/examples/water/terrain_shader.frag.spv differ diff --git a/wgpu/examples/water/terrain_shader.vert b/wgpu/examples/water/terrain_shader.vert index a87ddf4579..aa3d12a727 100644 --- a/wgpu/examples/water/terrain_shader.vert +++ b/wgpu/examples/water/terrain_shader.vert @@ -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); diff --git a/wgpu/examples/water/terrain_shader.vert.spv b/wgpu/examples/water/terrain_shader.vert.spv index 6504a274d6..587504e4fd 100644 Binary files a/wgpu/examples/water/terrain_shader.vert.spv and b/wgpu/examples/water/terrain_shader.vert.spv differ diff --git a/wgpu/examples/water/water_shader.frag b/wgpu/examples/water/water_shader.frag index 5ab3787b6b..0d704e33be 100644 --- a/wgpu/examples/water/water_shader.frag +++ b/wgpu/examples/water/water_shader.frag @@ -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); diff --git a/wgpu/examples/water/water_shader.frag.spv b/wgpu/examples/water/water_shader.frag.spv index 7f22caf234..8eb94cfa6e 100644 Binary files a/wgpu/examples/water/water_shader.frag.spv and b/wgpu/examples/water/water_shader.frag.spv differ diff --git a/wgpu/examples/water/water_shader.vert b/wgpu/examples/water/water_shader.vert index 5b381571a2..b35251ef16 100644 --- a/wgpu/examples/water/water_shader.vert +++ b/wgpu/examples/water/water_shader.vert @@ -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; } diff --git a/wgpu/examples/water/water_shader.vert.spv b/wgpu/examples/water/water_shader.vert.spv index dc7d6bd9c5..688792a7c9 100644 Binary files a/wgpu/examples/water/water_shader.vert.spv and b/wgpu/examples/water/water_shader.vert.spv differ