diff options
author | Juan Linietsky <reduzio@gmail.com> | 2017-09-07 18:00:47 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2017-09-07 18:00:47 -0300 |
commit | eedb39091aaa1dc0b8f204844bb1eb270b2349f6 (patch) | |
tree | ed08e5e7baf7d21403da34d531223404688513aa /scene/3d | |
parent | 1eeda0f32f66b48c8df3b93f333bf702b149ba31 (diff) |
Several fixes to directional shadows, closes #10926
Added option to change directional light range mode, between optimized and stable. For Orthogonal, you might need to use optimized.
Diffstat (limited to 'scene/3d')
-rw-r--r-- | scene/3d/light.cpp | 23 | ||||
-rw-r--r-- | scene/3d/light.h | 10 |
2 files changed, 32 insertions, 1 deletions
diff --git a/scene/3d/light.cpp b/scene/3d/light.cpp index 09b253b309..d410ba1e2a 100644 --- a/scene/3d/light.cpp +++ b/scene/3d/light.cpp @@ -230,7 +230,6 @@ void Light::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::COLOR, "shadow_color", PROPERTY_HINT_COLOR_NO_ALPHA), "set_shadow_color", "get_shadow_color"); ADD_PROPERTYI(PropertyInfo(Variant::REAL, "shadow_bias", PROPERTY_HINT_RANGE, "-16,16,0.01"), "set_param", "get_param", PARAM_SHADOW_BIAS); ADD_PROPERTYI(PropertyInfo(Variant::REAL, "shadow_contact", PROPERTY_HINT_RANGE, "0,16,0.01"), "set_param", "get_param", PARAM_CONTACT_SHADOW_SIZE); - ADD_PROPERTYI(PropertyInfo(Variant::REAL, "shadow_max_distance", PROPERTY_HINT_RANGE, "0,65536,0.1"), "set_param", "get_param", PARAM_SHADOW_MAX_DISTANCE); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "shadow_reverse_cull_face"), "set_shadow_reverse_cull_face", "get_shadow_reverse_cull_face"); ADD_GROUP("Editor", ""); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "editor_only"), "set_editor_only", "is_editor_only"); @@ -308,6 +307,18 @@ DirectionalLight::ShadowMode DirectionalLight::get_shadow_mode() const { return shadow_mode; } +void DirectionalLight::set_shadow_depth_range(ShadowDepthRange p_range) { + shadow_depth_range=p_range; + VS::get_singleton()->light_directional_set_shadow_depth_range_mode(light, VS::LightDirectionalShadowDepthRangeMode(p_range)); + +} + +DirectionalLight::ShadowDepthRange DirectionalLight::get_shadow_depth_range() const { + + return shadow_depth_range; +} + + void DirectionalLight::set_blend_splits(bool p_enable) { blend_splits = p_enable; @@ -324,6 +335,9 @@ void DirectionalLight::_bind_methods() { ClassDB::bind_method(D_METHOD("set_shadow_mode", "mode"), &DirectionalLight::set_shadow_mode); ClassDB::bind_method(D_METHOD("get_shadow_mode"), &DirectionalLight::get_shadow_mode); + ClassDB::bind_method(D_METHOD("set_shadow_depth_range", "mode"), &DirectionalLight::set_shadow_depth_range); + ClassDB::bind_method(D_METHOD("get_shadow_depth_range"), &DirectionalLight::get_shadow_depth_range); + ClassDB::bind_method(D_METHOD("set_blend_splits", "enabled"), &DirectionalLight::set_blend_splits); ClassDB::bind_method(D_METHOD("is_blend_splits_enabled"), &DirectionalLight::is_blend_splits_enabled); @@ -335,10 +349,15 @@ void DirectionalLight::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "directional_shadow_blend_splits"), "set_blend_splits", "is_blend_splits_enabled"); ADD_PROPERTYI(PropertyInfo(Variant::REAL, "directional_shadow_normal_bias", PROPERTY_HINT_RANGE, "0,16,0.01"), "set_param", "get_param", PARAM_SHADOW_NORMAL_BIAS); ADD_PROPERTYI(PropertyInfo(Variant::REAL, "directional_shadow_bias_split_scale", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_param", "get_param", PARAM_SHADOW_BIAS_SPLIT_SCALE); + ADD_PROPERTY(PropertyInfo(Variant::INT, "directional_shadow_depth_range", PROPERTY_HINT_ENUM, "Stable,Optimized"), "set_shadow_depth_range", "get_shadow_depth_range"); + ADD_PROPERTYI(PropertyInfo(Variant::REAL, "directional_shadow_max_distance", PROPERTY_HINT_RANGE, "0,65536,0.1"), "set_param", "get_param", PARAM_SHADOW_MAX_DISTANCE); BIND_ENUM_CONSTANT(SHADOW_ORTHOGONAL); BIND_ENUM_CONSTANT(SHADOW_PARALLEL_2_SPLITS); BIND_ENUM_CONSTANT(SHADOW_PARALLEL_4_SPLITS); + + BIND_ENUM_CONSTANT( SHADOW_DEPTH_RANGE_STABLE ); + BIND_ENUM_CONSTANT( SHADOW_DEPTH_RANGE_OPTIMIZED ); } DirectionalLight::DirectionalLight() @@ -349,6 +368,8 @@ DirectionalLight::DirectionalLight() set_param(PARAM_SHADOW_MAX_DISTANCE, 200); set_param(PARAM_SHADOW_BIAS_SPLIT_SCALE, 0.25); set_shadow_mode(SHADOW_PARALLEL_4_SPLITS); + set_shadow_depth_range(SHADOW_DEPTH_RANGE_STABLE); + blend_splits = false; } diff --git a/scene/3d/light.h b/scene/3d/light.h index 5d589d33e5..6aa0220265 100644 --- a/scene/3d/light.h +++ b/scene/3d/light.h @@ -133,9 +133,15 @@ public: SHADOW_PARALLEL_4_SPLITS }; + enum ShadowDepthRange { + SHADOW_DEPTH_RANGE_STABLE = VS::LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_STABLE, + SHADOW_DEPTH_RANGE_OPTIMIZED = VS::LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_OPTIMIZED, + }; + private: bool blend_splits; ShadowMode shadow_mode; + ShadowDepthRange shadow_depth_range; protected: static void _bind_methods(); @@ -144,6 +150,9 @@ public: void set_shadow_mode(ShadowMode p_mode); ShadowMode get_shadow_mode() const; + void set_shadow_depth_range(ShadowDepthRange p_mode); + ShadowDepthRange get_shadow_depth_range() const; + void set_blend_splits(bool p_enable); bool is_blend_splits_enabled() const; @@ -151,6 +160,7 @@ public: }; VARIANT_ENUM_CAST(DirectionalLight::ShadowMode) +VARIANT_ENUM_CAST(DirectionalLight::ShadowDepthRange) class OmniLight : public Light { |