0
\$\begingroup\$

I'm working on a tutorial for creating wake waves with Godot, versions 3.5 and, importantly, the upcoming 4.0. It uses shaders (including visual) and works fine so far, but in attempting to get the fragment shader working, it is suggested that I add an expression using the line:

float d = texture(DEPTH_TEXTURE, SCREEN_UV).r;

Unfortunately, this tutorial was made during the beta phase, and DEPTH_TEXTURE has been removed in favor of something called hint_depth_texture... which I am having a terrible time finding any actual documentation on. It does not seem to refer to a texture directly, and I cannot seem to declare a uniform from within an expression node.

Can someone help me mimic this functionality with the new Godot visual shaders?

Thank you.

\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

This change really just means that there's no longer a special constant representing the screen or depth textures. Instead, you're supposed to define a uniform sampler2D that will receive the screen or depth texture instead.

You can even restore the previous behavior, just by picking DEPTH_TEXTURE as its name.

uniform sampler2D SCREEN_TEXTURE: hint_screen_texture;
uniform sampler2D DEPTH_TEXTURE: hint_depth_texture;

While this sounds like a unnecessary change, it gives you way greater control, e.g. by defining whether you want the texture to repeat, how to filter it, etc. (all using additional hints):

uniform sampler2D screen_nearest: hint_screen_texture, filter_nearest;
uniform sampler2D screen_no_repeat: hint_screen_texture, repeat_disable;
\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .