These are good shaders but they don't work on gl_compatibility (just show as white), which means they don't work on web exports. An option on them to disable features so that gl_compatibility works would be amazing.
Viewing post in New Release: Godot Water comments
I was able to fix the toon shader with this diff. Here's why it works:
1. sample_world_dpos reconstructs world position using the depth buffer
2. It passes texture(DEPTH_TEXTURE, screen_uv).r directly as the clip-space z
3. That works in Forward+/Vulkan where NDC z is [0, 1] — depth maps directly to it
4. In gl_compatibility/OpenGL, NDC z is [-1, 1], so depth (which is [0, 1]) must be remapped to 2*depth - 1 before using it with INV_PROJECTION_MATRIX
5. With the wrong clip z, world_dpos.y ends up reconstructed above the water surface, which makes edge_foam_depth = 1.0 everywhere, which creates pure white foam
--- a/src/shader/water_toon.gdshader
+++ b/src/shader/water_toon.gdshader
@@ -3,6 +3,10 @@
#define USE_DISPLACEMENT 1
#define USE_STYLIZED_LIGHTING 1
#define USE_UNSHADED 0
+// Set to 1 when using the gl_compatibility renderer.
+// OpenGL depth buffer [0,1] maps to NDC z [-1,1] and must be remapped
+// before reconstruction; Vulkan (Forward+) uses [0,1] NDC z and does not.
+#define GL_COMPATIBILITY 1
shader_type spatial;
#if USE_UNSHADED
@@ -85,7 +89,11 @@ vec3 sample_caustics(vec2 uv){
#endif
vec4 sample_world_dpos(vec2 screen_uv, mat4 inv_proj_mat, mat4 inv_view_mat){
- vec4 clip_pos = vec4(screen_uv * 2.0 - 1.0, texture(DEPTH_TEXTURE, screen_uv).r, 1.0);
+ float depth = texture(DEPTH_TEXTURE, screen_uv).r;
+ #if GL_COMPATIBILITY
+ depth = depth * 2.0 - 1.0;
+ #endif
+ vec4 clip_pos = vec4(screen_uv * 2.0 - 1.0, depth, 1.0);
vec4 view_pos = inv_proj_mat * clip_pos;
view_pos /= view_pos.w;
vec4 world_dpos = inv_view_mat * view_pos;