Writing ALPHA caused Godot to treat all meshes as transparent, breaking per-pixel depth testing. Hair clipped through the head, clothing through the body — all caused by object-level depth sorting instead of z-buffer. Removing ALPHA makes everything opaque with correct depth behavior. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
16 lines
548 B
Plaintext
16 lines
548 B
Plaintext
shader_type spatial;
|
|
render_mode unshaded;
|
|
|
|
uniform vec4 base_color : source_color = vec4(0.8, 0.6, 0.4, 1.0);
|
|
uniform vec4 shadow_color : source_color = vec4(0.4, 0.3, 0.2, 1.0);
|
|
uniform float shadow_threshold : hint_range(0.0, 1.0) = 0.5;
|
|
|
|
void fragment() {
|
|
// Simple toon shading: use normal dot light to pick between base and shadow
|
|
vec3 light_dir = normalize(vec3(0.3, -1.0, 0.5));
|
|
float ndl = dot(NORMAL, -light_dir);
|
|
float toon = step(shadow_threshold, ndl);
|
|
vec3 color = mix(shadow_color.rgb, base_color.rgb, toon);
|
|
ALBEDO = color;
|
|
}
|