0

I have a plane that has a shader material attached to it to generate perlin noise. I'd like for my light to pass through it so that it can cast shadows on the stuff below.

enter image description here

Here is my shader:

shader_type spatial;

uniform float scale: hint_range(0.1, 10.0) = 2.0;
uniform float speed: hint_range(0.0, 5.0) = 1.0;
uniform vec4 cloud_color: source_color = vec4(1.0, 1.0, 1.0, 1.0);
uniform vec4 background_color: source_color = vec4(0.0, 0.0, 0.0, 0.0);

float rand(vec2 n) {
    return fract(sin(dot(n, vec2(12.9898, 4.1414))) * 43758.5453);
}

float noise(vec2 n) {
    const vec2 d = vec2(0.0, 1.0);
    vec2 b = floor(n), f = smoothstep(vec2(0.0), vec2(1.0), fract(n));
    return mix(mix(rand(b), rand(b + d.yx), f.x), mix(rand(b + d.xy), rand(b + d.yy), f.x), f.y);
}

void vertex() {
    VERTEX = VERTEX;
    NORMAL = normalize((MODEL_NORMAL_MATRIX * vec3(NORMAL)).xyz);
    UV = (UV + vec2(0.5, 0.5)) * 2.0;
}

void fragment() {
    vec2 uv = UV;
    float noise_value = noise(uv * scale + TIME * speed);
    vec4 color = mix(background_color, cloud_color, noise_value);
    ALBEDO = color.rgb;
    ALPHA = color.a;
}
mic
  • 4,300
  • 1
  • 19
  • 25

0 Answers0