summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2017-09-02 12:13:01 +0200
committerGitHub <noreply@github.com>2017-09-02 12:13:01 +0200
commit8e75e7311bfedae6d94b295b2daa50c742582680 (patch)
treeeeffe92b4857c8940d7e8b1ff6db83a032897a56
parent4d580d76ca814809bcc1e6175c271900b746ef36 (diff)
parent3a188015be668884dc296abc86e15225fe04418d (diff)
Merge pull request #10858 from letheed/add-shadow_filter-variant
add shadow_filter variant PCF7
-rw-r--r--drivers/gles3/rasterizer_canvas_gles3.cpp2
-rw-r--r--drivers/gles3/shaders/canvas.glsl14
-rw-r--r--scene/2d/light_2d.cpp2
-rw-r--r--scene/2d/light_2d.h1
-rw-r--r--servers/visual_server.h1
5 files changed, 19 insertions, 1 deletions
diff --git a/drivers/gles3/rasterizer_canvas_gles3.cpp b/drivers/gles3/rasterizer_canvas_gles3.cpp
index 09f35f097a..ff0741f425 100644
--- a/drivers/gles3/rasterizer_canvas_gles3.cpp
+++ b/drivers/gles3/rasterizer_canvas_gles3.cpp
@@ -1284,6 +1284,7 @@ void RasterizerCanvasGLES3::canvas_render_items(Item *p_item_list, int p_z, cons
case VS::CANVAS_LIGHT_FILTER_NONE: state.canvas_shader.set_conditional(CanvasShaderGLES3::SHADOW_FILTER_NEAREST, true); break;
case VS::CANVAS_LIGHT_FILTER_PCF3: state.canvas_shader.set_conditional(CanvasShaderGLES3::SHADOW_FILTER_PCF3, true); break;
case VS::CANVAS_LIGHT_FILTER_PCF5: state.canvas_shader.set_conditional(CanvasShaderGLES3::SHADOW_FILTER_PCF5, true); break;
+ case VS::CANVAS_LIGHT_FILTER_PCF7: state.canvas_shader.set_conditional(CanvasShaderGLES3::SHADOW_FILTER_PCF7, true); break;
case VS::CANVAS_LIGHT_FILTER_PCF9: state.canvas_shader.set_conditional(CanvasShaderGLES3::SHADOW_FILTER_PCF9, true); break;
case VS::CANVAS_LIGHT_FILTER_PCF13: state.canvas_shader.set_conditional(CanvasShaderGLES3::SHADOW_FILTER_PCF13, true); break;
}
@@ -1334,6 +1335,7 @@ void RasterizerCanvasGLES3::canvas_render_items(Item *p_item_list, int p_z, cons
state.canvas_shader.set_conditional(CanvasShaderGLES3::SHADOW_FILTER_NEAREST, false);
state.canvas_shader.set_conditional(CanvasShaderGLES3::SHADOW_FILTER_PCF3, false);
state.canvas_shader.set_conditional(CanvasShaderGLES3::SHADOW_FILTER_PCF5, false);
+ state.canvas_shader.set_conditional(CanvasShaderGLES3::SHADOW_FILTER_PCF7, false);
state.canvas_shader.set_conditional(CanvasShaderGLES3::SHADOW_FILTER_PCF9, false);
state.canvas_shader.set_conditional(CanvasShaderGLES3::SHADOW_FILTER_PCF13, false);
diff --git a/drivers/gles3/shaders/canvas.glsl b/drivers/gles3/shaders/canvas.glsl
index 37187a86cc..3bcfd24383 100644
--- a/drivers/gles3/shaders/canvas.glsl
+++ b/drivers/gles3/shaders/canvas.glsl
@@ -585,6 +585,20 @@ FRAGMENT_SHADER_CODE
#endif
+#ifdef SHADOW_FILTER_PCF7
+
+ SHADOW_TEST(su+shadowpixel_size*3.0);
+ SHADOW_TEST(su+shadowpixel_size*2.0);
+ SHADOW_TEST(su+shadowpixel_size);
+ SHADOW_TEST(su);
+ SHADOW_TEST(su-shadowpixel_size);
+ SHADOW_TEST(su-shadowpixel_size*2.0);
+ SHADOW_TEST(su-shadowpixel_size*3.0);
+ shadow_attenuation/=7.0;
+
+#endif
+
+
#ifdef SHADOW_FILTER_PCF9
SHADOW_TEST(su+shadowpixel_size*4.0);
diff --git a/scene/2d/light_2d.cpp b/scene/2d/light_2d.cpp
index ab8277ecf3..1bca2c6f37 100644
--- a/scene/2d/light_2d.cpp
+++ b/scene/2d/light_2d.cpp
@@ -435,7 +435,7 @@ void Light2D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "shadow_color"), "set_shadow_color", "get_shadow_color");
ADD_PROPERTY(PropertyInfo(Variant::INT, "shadow_buffer_size", PROPERTY_HINT_RANGE, "32,16384,1"), "set_shadow_buffer_size", "get_shadow_buffer_size");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "shadow_gradient_length", PROPERTY_HINT_RANGE, "0,4096,0.1"), "set_shadow_gradient_length", "get_shadow_gradient_length");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "shadow_filter", PROPERTY_HINT_ENUM, "None,PCF3,PCF5,PCF9,PCF13"), "set_shadow_filter", "get_shadow_filter");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "shadow_filter", PROPERTY_HINT_ENUM, "None,PCF3,PCF5,PCF7,PCF9,PCF13"), "set_shadow_filter", "get_shadow_filter");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "shadow_filter_smooth", PROPERTY_HINT_RANGE, "0,64,0.1"), "set_shadow_smooth", "get_shadow_smooth");
ADD_PROPERTY(PropertyInfo(Variant::INT, "shadow_item_cull_mask", PROPERTY_HINT_LAYERS_2D_RENDER), "set_item_shadow_cull_mask", "get_item_shadow_cull_mask");
diff --git a/scene/2d/light_2d.h b/scene/2d/light_2d.h
index 66b0aa2299..f6bc943adb 100644
--- a/scene/2d/light_2d.h
+++ b/scene/2d/light_2d.h
@@ -48,6 +48,7 @@ public:
SHADOW_FILTER_NONE,
SHADOW_FILTER_PCF3,
SHADOW_FILTER_PCF5,
+ SHADOW_FILTER_PCF7,
SHADOW_FILTER_PCF9,
SHADOW_FILTER_PCF13,
};
diff --git a/servers/visual_server.h b/servers/visual_server.h
index 45eaeeea25..d516013ee2 100644
--- a/servers/visual_server.h
+++ b/servers/visual_server.h
@@ -831,6 +831,7 @@ public:
CANVAS_LIGHT_FILTER_NONE,
CANVAS_LIGHT_FILTER_PCF3,
CANVAS_LIGHT_FILTER_PCF5,
+ CANVAS_LIGHT_FILTER_PCF7,
CANVAS_LIGHT_FILTER_PCF9,
CANVAS_LIGHT_FILTER_PCF13,
};