0 votes

Hi guys, I have been trying to port this code:

https://github.com/jedStevens/water2D/blob/master/water_material.tres

To godot 3.0 but something seems wrong, and I don't have any more ideas. I am a newbie at shaders, so I am kinda lost.

shader_type canvas_item;

uniform float height = 1.0;
uniform sampler2D displacement_1;
uniform float displace_factor_1 = 0.01;
uniform float speed_1 = 1;

uniform sampler2D displacement_2;
uniform float displace_factor_2 = 0.01;
uniform float speed_2 = 1;

void fragment(){

    vec2 offset_1 = vec2(TIME * speed_1,0);
    vec2 d_1 = texture(displacement_1, UV + offset_1).rg;

    vec2 offset_2 = vec2(TIME * speed_2,0);
    vec2 d_2 = texture(displacement_2, UV + offset_2).rg;

    vec2 r_uv = vec2(SCREEN_UV.x, SCREEN_UV.y + UV.y*height) + (d_1 * displace_factor_1 - d_2 * displace_factor_2);
    vec4 r_col = texture(SCREEN_TEXTURE, r_uv);

    COLOR.rgba = vec4(0,0,0,0);
    COLOR.rgb += r_col.xyz + vec3(d_1 * d_2, 0.0) * 0.1 - vec3(0.4,0.2,0.1) * (1.0-UV.y + 0.1);
    COLOR.rgb += vec3(0.3,0.2,0.1) * (1.0 - dot(d_1, d_2));
    COLOR.a = 1.0 - (UV.y*UV.y);
}

As it is, this is what I have: which is nowhere close of what I want.
shader

in Engine by (227 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.