+1 vote

ALBEDO is vec3 and COLOR is vec4.. I need make pass COLOR to ALBEDO on Godot.. This shader work on shadertype itemscanvas but not working on spatial material..

    shader_type  spatial;
    uniform float amp = 0.1;
    uniform vec4 tint_color = vec4(0.0, 0.5,0.99, 1);
    uniform sampler2D iChannel0;
    void fragment ()
    {

            vec2 uv = FRAGCOORD.xy / (1.0/VIEWPORT_SIZE).xy;// (1.0/SCREEN_PIXEL_SIZE) for  shader_type canvas_item

            vec2 p = uv +
            (vec2(.5)-texture(iChannel0, uv*0.3+vec2(TIME*0.05, TIME*0.025)).xy)*amp +
            (vec2(.5)-texture(iChannel0, uv*0.3-vec2(-TIME*0.005, TIME*0.0125)).xy)*amp;
            vec4 a = texture(iChannel0, p)*tint_color;

        ALBEDO = a.xyz; //the w channel is not important, works without it
on shader_type canvas_item but if used this on 3d spatial the effect no pass.. whats problem?

    }
Godot version 3.2
in Engine by (16 points)

1 Answer

+1 vote
Best answer

I changed uv coordinates and added hint_color then it did some mixing

shader_type spatial;
uniform float amp = 0.1;
uniform vec4 tint_color: hint_color = vec4(0.0, 0.5, 0.99, 1);
uniform sampler2D iChannel0;

void fragment () {
    vec2 uv = (FRAGCOORD.xy / VIEWPORT_SIZE).xy;
    vec2 p = uv +
        (vec2(.5)-texture(iChannel0, uv*0.3+vec2(TIME*0.05, TIME*0.025)).xy)*amp +
        (vec2(.5)-texture(iChannel0, uv*0.3-vec2(-TIME*0.005, TIME*0.0125)).xy)*amp;
    vec4 a = texture(iChannel0, p) * tint_color;
    ALBEDO = a.xyz;
}
by (638 points)
selected by

i change uv = (FRAGCOORD.xy / VIEWPORT_SIZE).xy; for uv = SCREEN_UV; camera fixed and is work!

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.