Skip to content

Commit ebd32c1

Browse files
committed
Fix Light2D none shadow filter to use nearest sampling
1 parent 07f4c06 commit ebd32c1

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

servers/rendering/renderer_rd/shaders/canvas.glsl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,9 @@ vec4 light_shadow_compute(uint light_base, vec4 light_color, vec4 shadow_uv
407407
uint shadow_mode = light_array.data[light_base].flags & LIGHT_FLAGS_FILTER_MASK;
408408

409409
if (shadow_mode == LIGHT_FLAGS_SHADOW_NEAREST) {
410-
shadow = texture_shadow(shadow_uv);
410+
vec2 unit_p = floor(shadow_uv.xy / canvas_data.shadow_pixel_size) * canvas_data.shadow_pixel_size;
411+
float depth_sample = texture(sampler2D(shadow_atlas_texture, shadow_sampler), unit_p.xy).r;
412+
shadow = step(depth_sample, shadow_uv.z);
411413
} else if (shadow_mode == LIGHT_FLAGS_SHADOW_PCF5) {
412414
vec4 shadow_pixel_size = vec4(light_array.data[light_base].shadow_pixel_size, 0.0, 0.0, 0.0);
413415
shadow = 0.0;

0 commit comments

Comments
 (0)