diff options
author | Juan Linietsky <reduzio@gmail.com> | 2016-12-04 12:45:30 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2016-12-04 12:45:30 -0300 |
commit | a299c3ebf1ceb3ce108526b3e134e82e5bf4413b (patch) | |
tree | f62ea61a7245d83caadc8c6c84d82e129ef240cf /scene | |
parent | 27a46d78ec43b69a70a1d84c540353e3cb3b04c0 (diff) |
Support for SSAO
Diffstat (limited to 'scene')
-rw-r--r-- | scene/resources/environment.cpp | 142 | ||||
-rw-r--r-- | scene/resources/environment.h | 39 |
2 files changed, 181 insertions, 0 deletions
diff --git a/scene/resources/environment.cpp b/scene/resources/environment.cpp index 578a8ae50a..c945d2a95d 100644 --- a/scene/resources/environment.cpp +++ b/scene/resources/environment.cpp @@ -377,6 +377,102 @@ bool Environment::is_ssr_rough() const { return ssr_roughness; } +void Environment::set_ssao_enabled(bool p_enable) { + + ssao_enabled=p_enable; + VS::get_singleton()->environment_set_ssao(environment,ssao_enabled,ssao_radius,ssao_intensity,ssao_radius2,ssao_intensity2,ssao_bias,ssao_direct_light_affect,ssao_color,ssao_blur); + +} + +bool Environment::is_ssao_enabled() const{ + + return ssao_enabled; +} + +void Environment::set_ssao_radius(float p_radius){ + + ssao_radius=p_radius; + VS::get_singleton()->environment_set_ssao(environment,ssao_enabled,ssao_radius,ssao_intensity,ssao_radius2,ssao_intensity2,ssao_bias,ssao_direct_light_affect,ssao_color,ssao_blur); +} +float Environment::get_ssao_radius() const{ + + return ssao_radius; +} + + +void Environment::set_ssao_intensity(float p_intensity){ + + ssao_intensity=p_intensity; + VS::get_singleton()->environment_set_ssao(environment,ssao_enabled,ssao_radius,ssao_intensity,ssao_radius2,ssao_intensity2,ssao_bias,ssao_direct_light_affect,ssao_color,ssao_blur); +} + +float Environment::get_ssao_intensity() const{ + + return ssao_intensity; +} + +void Environment::set_ssao_radius2(float p_radius){ + + ssao_radius2=p_radius; + VS::get_singleton()->environment_set_ssao(environment,ssao_enabled,ssao_radius,ssao_intensity,ssao_radius2,ssao_intensity2,ssao_bias,ssao_direct_light_affect,ssao_color,ssao_blur); +} +float Environment::get_ssao_radius2() const{ + + return ssao_radius2; +} + + +void Environment::set_ssao_intensity2(float p_intensity){ + + ssao_intensity2=p_intensity; + VS::get_singleton()->environment_set_ssao(environment,ssao_enabled,ssao_radius,ssao_intensity,ssao_radius2,ssao_intensity2,ssao_bias,ssao_direct_light_affect,ssao_color,ssao_blur); +} +float Environment::get_ssao_intensity2() const{ + + return ssao_intensity2; +} + +void Environment::set_ssao_bias(float p_bias){ + + ssao_bias=p_bias; + VS::get_singleton()->environment_set_ssao(environment,ssao_enabled,ssao_radius,ssao_intensity,ssao_radius2,ssao_intensity2,ssao_bias,ssao_direct_light_affect,ssao_color,ssao_blur); +} +float Environment::get_ssao_bias() const{ + + return ssao_bias; +} + +void Environment::set_ssao_direct_light_affect(float p_direct_light_affect){ + + ssao_direct_light_affect=p_direct_light_affect; + VS::get_singleton()->environment_set_ssao(environment,ssao_enabled,ssao_radius,ssao_intensity,ssao_radius2,ssao_intensity2,ssao_bias,ssao_direct_light_affect,ssao_color,ssao_blur); +} +float Environment::get_ssao_direct_light_affect() const{ + + return ssao_direct_light_affect; +} + + +void Environment::set_ssao_color(const Color& p_color) { + + ssao_color=p_color; + VS::get_singleton()->environment_set_ssao(environment,ssao_enabled,ssao_radius,ssao_intensity,ssao_radius2,ssao_intensity2,ssao_bias,ssao_direct_light_affect,ssao_color,ssao_blur); +} + +Color Environment::get_ssao_color() const { + + return ssao_color; +} + +void Environment::set_ssao_blur(bool p_enable) { + + ssao_blur=p_enable; + VS::get_singleton()->environment_set_ssao(environment,ssao_enabled,ssao_radius,ssao_intensity,ssao_radius2,ssao_intensity2,ssao_bias,ssao_direct_light_affect,ssao_color,ssao_blur); +} +bool Environment::is_ssao_blur_enabled() const { + + return ssao_blur; +} void Environment::_bind_methods() { @@ -442,6 +538,43 @@ void Environment::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL,"ss_reflections/accel_smooth"),_SCS("set_ssr_smooth"),_SCS("is_ssr_smooth") ); ADD_PROPERTY(PropertyInfo(Variant::BOOL,"ss_reflections/roughness"),_SCS("set_ssr_rough"),_SCS("is_ssr_rough") ); + ObjectTypeDB::bind_method(_MD("set_ssao_enabled","enabled"),&Environment::set_ssao_enabled); + ObjectTypeDB::bind_method(_MD("is_ssao_enabled"),&Environment::is_ssao_enabled); + + ObjectTypeDB::bind_method(_MD("set_ssao_radius","radius"),&Environment::set_ssao_radius); + ObjectTypeDB::bind_method(_MD("get_ssao_radius"),&Environment::get_ssao_radius); + + ObjectTypeDB::bind_method(_MD("set_ssao_intensity","intensity"),&Environment::set_ssao_intensity); + ObjectTypeDB::bind_method(_MD("get_ssao_intensity"),&Environment::get_ssao_intensity); + + ObjectTypeDB::bind_method(_MD("set_ssao_radius2","radius"),&Environment::set_ssao_radius2); + ObjectTypeDB::bind_method(_MD("get_ssao_radius2"),&Environment::get_ssao_radius2); + + ObjectTypeDB::bind_method(_MD("set_ssao_intensity2","intensity"),&Environment::set_ssao_intensity2); + ObjectTypeDB::bind_method(_MD("get_ssao_intensity2"),&Environment::get_ssao_intensity2); + + ObjectTypeDB::bind_method(_MD("set_ssao_bias","bias"),&Environment::set_ssao_bias); + ObjectTypeDB::bind_method(_MD("get_ssao_bias"),&Environment::get_ssao_bias); + + ObjectTypeDB::bind_method(_MD("set_ssao_direct_light_affect","amount"),&Environment::set_ssao_direct_light_affect); + ObjectTypeDB::bind_method(_MD("get_ssao_direct_light_affect"),&Environment::get_ssao_direct_light_affect); + + ObjectTypeDB::bind_method(_MD("set_ssao_color","color"),&Environment::set_ssao_color); + ObjectTypeDB::bind_method(_MD("get_ssao_color"),&Environment::get_ssao_color); + + ObjectTypeDB::bind_method(_MD("set_ssao_blur","enabled"),&Environment::set_ssao_blur); + ObjectTypeDB::bind_method(_MD("is_ssao_blur_enabled"),&Environment::is_ssao_blur_enabled); + + ADD_PROPERTY(PropertyInfo(Variant::BOOL,"ambient_occlusion/enable"),_SCS("set_ssao_enabled"),_SCS("is_ssao_enabled") ); + ADD_PROPERTY(PropertyInfo(Variant::REAL,"ambient_occlusion/radius",PROPERTY_HINT_RANGE,"0.1,16,0.1"),_SCS("set_ssao_radius"),_SCS("get_ssao_radius") ); + ADD_PROPERTY(PropertyInfo(Variant::REAL,"ambient_occlusion/intensity",PROPERTY_HINT_RANGE,"0.0,9,0.1"),_SCS("set_ssao_intensity"),_SCS("get_ssao_intensity") ); + ADD_PROPERTY(PropertyInfo(Variant::REAL,"ambient_occlusion/radius2",PROPERTY_HINT_RANGE,"0.0,16,0.1"),_SCS("set_ssao_radius2"),_SCS("get_ssao_radius2") ); + ADD_PROPERTY(PropertyInfo(Variant::REAL,"ambient_occlusion/intensity2",PROPERTY_HINT_RANGE,"0.0,9,0.1"),_SCS("set_ssao_intensity2"),_SCS("get_ssao_intensity2") ); + ADD_PROPERTY(PropertyInfo(Variant::REAL,"ambient_occlusion/bias",PROPERTY_HINT_RANGE,"0.001,8,0.001"),_SCS("set_ssao_bias"),_SCS("get_ssao_bias") ); + ADD_PROPERTY(PropertyInfo(Variant::REAL,"ambient_occlusion/light_affect",PROPERTY_HINT_RANGE,"0.00,1,0.01"),_SCS("set_ssao_direct_light_affect"),_SCS("get_ssao_direct_light_affect") ); + ADD_PROPERTY(PropertyInfo(Variant::COLOR,"ambient_occlusion/color",PROPERTY_HINT_COLOR_NO_ALPHA),_SCS("set_ssao_color"),_SCS("get_ssao_color") ); + ADD_PROPERTY(PropertyInfo(Variant::BOOL,"ambient_occlusion/blur"),_SCS("set_ssao_blur"),_SCS("is_ssao_blur_enabled") ); + ObjectTypeDB::bind_method(_MD("set_tonemapper","mode"),&Environment::set_tonemapper); ObjectTypeDB::bind_method(_MD("get_tonemapper"),&Environment::get_tonemapper); @@ -561,6 +694,15 @@ Environment::Environment() { ssr_smooth=true; ssr_roughness=true; + ssao_enabled=false; + ssao_radius=1; + ssao_intensity=1; + ssao_radius2=0; + ssao_intensity2=1; + ssao_bias=0.01; + ssao_direct_light_affect=false; + ssao_blur=true; + } Environment::~Environment() { diff --git a/scene/resources/environment.h b/scene/resources/environment.h index f4610ada47..c489ff97fc 100644 --- a/scene/resources/environment.h +++ b/scene/resources/environment.h @@ -102,6 +102,17 @@ private: bool ssr_smooth; bool ssr_roughness; + bool ssao_enabled; + float ssao_radius; + float ssao_intensity; + float ssao_radius2; + float ssao_intensity2; + float ssao_bias; + float ssao_direct_light_affect; + Color ssao_color; + bool ssao_blur; + + protected: static void _bind_methods(); @@ -191,6 +202,34 @@ public: void set_ssr_rough(bool p_enable); bool is_ssr_rough() const; + void set_ssao_enabled(bool p_enable); + bool is_ssao_enabled() const; + + void set_ssao_radius(float p_radius); + float get_ssao_radius() const; + + void set_ssao_intensity(float p_intensity); + float get_ssao_intensity() const; + + void set_ssao_radius2(float p_radius); + float get_ssao_radius2() const; + + void set_ssao_intensity2(float p_intensity); + float get_ssao_intensity2() const; + + void set_ssao_bias(float p_bias); + float get_ssao_bias() const; + + void set_ssao_direct_light_affect(float p_direct_light_affect); + float get_ssao_direct_light_affect() const; + + void set_ssao_color(const Color& p_color); + Color get_ssao_color() const; + + void set_ssao_blur(bool p_enable); + bool is_ssao_blur_enabled() const; + + virtual RID get_rid() const; |