Godot Version
4.4
Question
I’m using a MultiMeshInstance3D with a QuadMesh and a simple 2D texture for some grass. It’s working well except for the fact that the grass texture is not affected by shadow.
I’m using this ShaderMaterial as the mesh material:
shader_type spatial;
render_mode cull_disabled, depth_prepass_alpha;
uniform sampler2D grass_texture : filter_nearest, source_color;
uniform float cut : hint_range(0.0, 1.0) = 0.35;
void vertex() {
float mask = clamp(UV.y, 0.0, 1.0);
VERTEX.x += sin(NODE_POSITION_WORLD.x + TIME * 1.25 + UV.y) * pow(mask, 1.5) * 0.1;
VERTEX.z += cos(NODE_POSITION_WORLD.z + TIME * 0.45 + UV.y) * pow(mask, 1.5) * 0.08;
NORMAL = vec3(0.0, 1.0, 0.0);
}
void fragment() {
vec4 tex = texture(grass_texture, UV);
ALBEDO = tex.rgb;
ALPHA = tex.a;
ALPHA_SCISSOR_THRESHOLD = cut;
ROUGHNESS = 1.0;
SPECULAR = 0.0;
}
I’ve tried various render_mode
and ALPHA_SCISSOR_THRESHOLD
options based on what I’ve read online, but nothing is working. Grass placed in the shadow of another object is not affected by the shadow — it’s the same colour as the non-shaded grass. The surrounding “terrain” (mesh) is correctly in shadow. I can’t see any transparency / shadow settings in the inspector for this.