Applying a water caustics shader to Terrain3D

Godot Version

4.2.2

Question

Some friends and I have been working on a game which takes place underwater, and I’ve been trying to add a fake water caustics shader to the terrain. We’re using the Terrain3D addon, and I can’t figure out how to apply a shader that effects the whole terrain. I assume I would have to override the built-in terrain shader, but I know next to nothing about shaders, so I wouldn’t know where to start with that. If anyone could help point me in the right direction, that would be incredibly helpful, thank you.

A Decal node might be a quick solution to your problem. You can make it only affect your terrain/specific objects by setting the cull_mask property accordingly.
But keep in mind that the builtin decals don’t support custom materials, so animating it could get very tricky.

1 Like

I was able to figure it out B)

Basically, I was on the right track, I just had to edit Terrain3D’s default terrain shader with the Shader Override property. For my situation (and with my almost nonexistent shader skills) I was able to take this caustics shader and basically add it to the fragment function of the default terrain shader. It’s not perfect (there are tiny bright flashing artifacts if you look closely, its always there no matter how deep the “water” is, I’d like to add chromatic aberration, and make it go away when its in shadow), but it’s good enough for now.
caustics