summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--drivers/gles2/rasterizer_canvas_gles2.cpp15
-rw-r--r--drivers/gles3/rasterizer_canvas_gles3.cpp15
2 files changed, 26 insertions, 4 deletions
diff --git a/drivers/gles2/rasterizer_canvas_gles2.cpp b/drivers/gles2/rasterizer_canvas_gles2.cpp
index 1db1625194..3b2851fbcd 100644
--- a/drivers/gles2/rasterizer_canvas_gles2.cpp
+++ b/drivers/gles2/rasterizer_canvas_gles2.cpp
@@ -1898,9 +1898,20 @@ void RasterizerCanvasGLES2::canvas_light_shadow_buffer_update(RID p_buffer, cons
}
state.canvas_shadow_shader.set_uniform(CanvasShadowShaderGLES2::WORLD_MATRIX, instance->xform_cache);
- if (cull != instance->cull_cache) {
- cull = instance->cull_cache;
+ VS::CanvasOccluderPolygonCullMode transformed_cull_cache = instance->cull_cache;
+
+ if (transformed_cull_cache != VS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED &&
+ (p_light_xform.basis_determinant() * instance->xform_cache.basis_determinant()) < 0) {
+ transformed_cull_cache =
+ transformed_cull_cache == VS::CANVAS_OCCLUDER_POLYGON_CULL_CLOCKWISE ?
+ VS::CANVAS_OCCLUDER_POLYGON_CULL_COUNTER_CLOCKWISE :
+ VS::CANVAS_OCCLUDER_POLYGON_CULL_CLOCKWISE;
+ }
+
+ if (cull != transformed_cull_cache) {
+
+ cull = transformed_cull_cache;
switch (cull) {
case VS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED: {
diff --git a/drivers/gles3/rasterizer_canvas_gles3.cpp b/drivers/gles3/rasterizer_canvas_gles3.cpp
index c798dff839..1803a3dbbe 100644
--- a/drivers/gles3/rasterizer_canvas_gles3.cpp
+++ b/drivers/gles3/rasterizer_canvas_gles3.cpp
@@ -1887,9 +1887,20 @@ void RasterizerCanvasGLES3::canvas_light_shadow_buffer_update(RID p_buffer, cons
}
state.canvas_shadow_shader.set_uniform(CanvasShadowShaderGLES3::WORLD_MATRIX, instance->xform_cache);
- if (cull != instance->cull_cache) {
- cull = instance->cull_cache;
+ VS::CanvasOccluderPolygonCullMode transformed_cull_cache = instance->cull_cache;
+
+ if (transformed_cull_cache != VS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED &&
+ (p_light_xform.basis_determinant() * instance->xform_cache.basis_determinant()) < 0) {
+ transformed_cull_cache =
+ transformed_cull_cache == VS::CANVAS_OCCLUDER_POLYGON_CULL_CLOCKWISE ?
+ VS::CANVAS_OCCLUDER_POLYGON_CULL_COUNTER_CLOCKWISE :
+ VS::CANVAS_OCCLUDER_POLYGON_CULL_CLOCKWISE;
+ }
+
+ if (cull != transformed_cull_cache) {
+
+ cull = transformed_cull_cache;
switch (cull) {
case VS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED: {