Hi.
I'm trying to create a water reflection shader and apply it to a Node2D.
I used the SCREEN_TEXTURE to do this. Here is my shader code.
shader_type canvas_item;
render_mode unshaded;
uniform float base_y;
void fragment()
{
vec2 uv = SCREEN_UV;
float y = base_y - uv.y;
vec4 tx = texture(SCREEN_TEXTURE, vec2(uv.x, y));
COLOR.r = COLOR.r + (tx.r * 0.3);
COLOR.g = COLOR.g + (tx.g * 0.3);
COLOR.b = COLOR.b + (tx.b * 0.3);
}
Actually, i did it. The image below show the water reflecting what is above it.
https://ibb.co/kXXsgmV
Well... not everything is being reflected!
I noticed that only the nodes that are below the water node (lower z-index) are being displayed on the reflection.
The image above show the reflection of a platform where the player is on top of.
But the player itself is not being displayed.
The player has a higher z-index, compared with the water node.
If i change this z-index to be lower than the water node one, the player is displayed on the reflection.
--
Here is a quick test.
On this first image, the player is not being displayed on the reflection.
https://ibb.co/vYx15Kb
On this second image, the player get displayed. What i did was just reordered the nodes on the scene. That basicaly changed the z-index of the nodes.
https://ibb.co/rHW1C4p
Am i doing something wrong?
I'd like to show on the reflection everything that is on the screen.
And not only the nodes that are below (lower z-index) the water node.