Cut a hole in a water shader?

Godot Version

4.2

Question

Hi

Is it possible to cut a hole in the middle of a water shader? I want a sort of cave there below water level and hope there is some way to achieve this?

use masking technique of shader code cropping with mask texture
something like:

uniform sampler2D mask_texture;
...
//in fragment()
vec4 mask_value = texture(mask_texture, UV);
if (mask_value.a==0.0){
COLOR.a=0.0;
}

You could use discard along with a circle SDF inside the shader code. Maybe applying the shader material on a CSG shape then subtracting a hole. I believe editing the shader itself would do you better.

1 Like

Thanks… it is a little try but you both helped me the good way :slight_smile: