3D spatial shader graident between two colors

jaymjaym Posts: 3Member
edited September 10 in Shaders

Hey! I'm trying to learn how shaders work!

I'm learning by writing a bunch of spatial shaders for a 3d waterfall.

Something I'd like to do is have a graident for the "main part" of the waterfall. so at the top, it'd start at color1 and ends with color2. with a gradient of the two in-between.

I'm unsure how to write this code, specifically for a 3D spatial shader?

here's what I've got so far:


  • SIsilicon28SIsilicon28 Posts: 757Moderator

    Wait, so you have it working here? Then what are you asking for exactly? I'm confused.

  • jaymjaym Posts: 3Member
    edited September 10

    for some reason part of my post was removed? that is a mockup of how I would like it to look.

    The "here's what I've got so far" referred to my code:

    shader_type spatial;
    render_mode unshaded;
    uniform sampler2D noise_tex;
    uniform sampler2D displ_tex;
    uniform vec4 rapids_color : hint_color;
    uniform vec4 transparent : hint_color;
    uniform vec4 color0 : hint_color;
    uniform vec4 color1 : hint_color;
    uniform float displ_amount = 0.02;
    uniform float speed = 0.25;
    void fragment()
    vec2 displ = texture(displ_tex, UV - TIME / 8.0).xy;
    displ = ((displ * 2.0) - 1.0) * displ_amount;
    float newy = UV.y * 0.5;
    ALBEDO.rgb = mix(color0.rgb, color1.rgb, newy);

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file