From e5b7a95f884e9057e6cb43e44496371b178cf507 Mon Sep 17 00:00:00 2001 From: Yuri Rubinsky Date: Thu, 13 Jun 2024 17:55:24 +0300 Subject: [PATCH] Implement glow map effect --- doc/classes/Environment3D.xml | 9 +++ doc/classes/RenderingServer.xml | 9 +++ drivers/dummy/rasterizer_dummy.h | 1 + drivers/gles2/rasterizer_scene_gles2.cpp | 5 ++ drivers/gles2/rasterizer_scene_gles2.h | 2 + drivers/gles3/rasterizer_scene_gles3.cpp | 19 ++++- drivers/gles3/rasterizer_scene_gles3.h | 4 + drivers/gles3/shaders/tonemap.glsl | 7 +- scene/resources/environment_3d.cpp | 80 +++++++++++++++++--- scene/resources/environment_3d.h | 11 +++ servers/rendering/rasterizer.h | 1 + servers/rendering/rendering_server_raster.h | 1 + servers/rendering/rendering_server_wrap_mt.h | 1 + servers/rendering_server.cpp | 1 + servers/rendering_server.h | 2 + 15 files changed, 140 insertions(+), 13 deletions(-) diff --git a/doc/classes/Environment3D.xml b/doc/classes/Environment3D.xml index 6eb26c4c5..35580a682 100644 --- a/doc/classes/Environment3D.xml +++ b/doc/classes/Environment3D.xml @@ -230,6 +230,15 @@ If [code]true[/code], the 7th level of glow is enabled. This is the most "global" level (blurriest). + + The texture that should be used as a glow map to [i]multiply[/i] the resulting glow color according to [member glow_map_strength]. This can be used to create a "lens dirt" effect. The texture's RGB color channels are used for modulation, but the alpha channel is ignored. + [b]Note:[/b] The texture will be stretched to fit the screen. Therefore, it's recommended to use a texture with an aspect ratio that matches your project's base aspect ratio (typically 16:9). + [b]Note:[/b] [member glow_map] has no effect when using the GLES2 rendering method, due to this rendering method using a simpler glow implementation optimized for low-end devices. + + + How strong of an impact the [member glow_map] should have on the overall glow effect. A strength of [code]0.0[/code] means the glow map has no effect on the overall glow effect. A strength of [code]1.0[/code] means the glow has a full effect on the overall glow effect (and can turn off glow entirely in specific areas of the screen if the glow map has black areas). + [b]Note:[/b] [member glow_map_strength] has no effect when using the GLES2 rendering method, due to this rendering method using a simpler glow implementation optimized for low-end devices. + The glow strength. When using the GLES2 renderer, this should be increased to 1.3 to compensate for the lack of HDR rendering. diff --git a/doc/classes/RenderingServer.xml b/doc/classes/RenderingServer.xml index fa3555db2..b105dda8f 100644 --- a/doc/classes/RenderingServer.xml +++ b/doc/classes/RenderingServer.xml @@ -985,6 +985,15 @@ Sets the variables to be used with the "glow" post-process effect. See [Environment3D] for more details. + + + + + + + Sets the variables to be used with the glow map post-process effect. See [Environment] for more details. + + diff --git a/drivers/dummy/rasterizer_dummy.h b/drivers/dummy/rasterizer_dummy.h index 30a9dd697..b82042abe 100644 --- a/drivers/dummy/rasterizer_dummy.h +++ b/drivers/dummy/rasterizer_dummy.h @@ -66,6 +66,7 @@ public: void environment_set_dof_blur_near(RID p_env, bool p_enable, float p_distance, float p_transition, float p_far_amount, RS::Environment3DDOFBlurQuality p_quality) {} void environment_set_dof_blur_far(RID p_env, bool p_enable, float p_distance, float p_transition, float p_far_amount, RS::Environment3DDOFBlurQuality p_quality) {} void environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_bloom_threshold, RS::Environment3DGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, float p_hdr_luminance_cap, bool p_bicubic_upscale, bool p_high_quality) {} + void environment_set_glow_map(RID p_env, float p_glow_map_strength, RID p_glow_map) {} void environment_set_fog(RID p_env, bool p_enable, float p_begin, float p_end, RID p_gradient_texture) {} diff --git a/drivers/gles2/rasterizer_scene_gles2.cpp b/drivers/gles2/rasterizer_scene_gles2.cpp index 5a15efcc1..509c2f390 100644 --- a/drivers/gles2/rasterizer_scene_gles2.cpp +++ b/drivers/gles2/rasterizer_scene_gles2.cpp @@ -841,6 +841,11 @@ void RasterizerSceneGLES2::environment_set_glow(RID p_env, bool p_enable, int p_ env->glow_high_quality = p_high_quality; } +void RasterizerSceneGLES2::environment_set_glow_map(RID p_env, float p_glow_map_strength, RID p_glow_map) { + Environment3D *env = environment_owner.getornull(p_env); + ERR_FAIL_COND(!env); +} + void RasterizerSceneGLES2::environment_set_fog(RID p_env, bool p_enable, float p_begin, float p_end, RID p_gradient_texture) { Environment3D *env = environment_owner.getornull(p_env); ERR_FAIL_COND(!env); diff --git a/drivers/gles2/rasterizer_scene_gles2.h b/drivers/gles2/rasterizer_scene_gles2.h index 73fba4878..f79524a6f 100644 --- a/drivers/gles2/rasterizer_scene_gles2.h +++ b/drivers/gles2/rasterizer_scene_gles2.h @@ -484,6 +484,8 @@ public: virtual void environment_set_dof_blur_far(RID p_env, bool p_enable, float p_distance, float p_transition, float p_amount, RS::Environment3DDOFBlurQuality p_quality); virtual void environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_bloom_threshold, RS::Environment3DGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, float p_hdr_luminance_cap, bool p_bicubic_upscale, bool p_high_quality); + virtual void environment_set_glow_map(RID p_env, float p_glow_map_strength, RID p_glow_map); + virtual void environment_set_fog(RID p_env, bool p_enable, float p_begin, float p_end, RID p_gradient_texture); virtual void environment_set_ssr(RID p_env, bool p_enable, int p_max_steps, float p_fade_in, float p_fade_out, float p_depth_tolerance, bool p_roughness); diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp index abb48a062..b357d655d 100644 --- a/drivers/gles3/rasterizer_scene_gles3.cpp +++ b/drivers/gles3/rasterizer_scene_gles3.cpp @@ -884,6 +884,15 @@ void RasterizerSceneGLES3::environment_set_glow(RID p_env, bool p_enable, int p_ env->glow_bicubic_upscale = p_bicubic_upscale; env->glow_high_quality = p_high_quality; } + +void RasterizerSceneGLES3::environment_set_glow_map(RID p_env, float p_glow_map_strength, RID p_glow_map) { + Environment3D *env = environment_owner.getornull(p_env); + ERR_FAIL_COND(!env); + + env->glow_map_strength = p_glow_map_strength; + env->glow_map = p_glow_map; +} + void RasterizerSceneGLES3::environment_set_fog(RID p_env, bool p_enable, float p_begin, float p_end, RID p_gradient_texture) { } @@ -4022,7 +4031,7 @@ void RasterizerSceneGLES3::_post_process(Environment3D *env, const Projection &p RasterizerStorageGLES3::Texture *tex = storage->texture_owner.getornull(env->color_correction); if (tex) { state.tonemap_shader.set_conditional(TonemapShaderGLES3::USE_COLOR_CORRECTION, true); - WRAPPED_GL_ACTIVE_TEXTURE(GL_TEXTURE3); + WRAPPED_GL_ACTIVE_TEXTURE(GL_TEXTURE4); glBindTexture(tex->target, tex->tex_id); } } @@ -4037,6 +4046,14 @@ void RasterizerSceneGLES3::_post_process(Environment3D *env, const Projection &p if (max_glow_level >= 0) { state.tonemap_shader.set_uniform(TonemapShaderGLES3::GLOW_INTENSITY, env->glow_intensity); + state.tonemap_shader.set_uniform(TonemapShaderGLES3::GLOW_MAP_STRENGTH, env->glow_map_strength); + + RasterizerStorageGLES3::Texture *tex = storage->texture_owner.getornull(env->glow_map); + if (tex) { + WRAPPED_GL_ACTIVE_TEXTURE(GL_TEXTURE3); + glBindTexture(tex->target, tex->tex_id); + } + int ss[2] = { storage->frame.current_rt->width, storage->frame.current_rt->height, diff --git a/drivers/gles3/rasterizer_scene_gles3.h b/drivers/gles3/rasterizer_scene_gles3.h index 7edd5e0c6..98756fcc3 100644 --- a/drivers/gles3/rasterizer_scene_gles3.h +++ b/drivers/gles3/rasterizer_scene_gles3.h @@ -413,6 +413,8 @@ public: float glow_hdr_luminance_cap; bool glow_bicubic_upscale; bool glow_high_quality; + float glow_map_strength; + RID glow_map; RS::Environment3DToneMapper tone_mapper; float tone_mapper_exposure; @@ -551,6 +553,8 @@ public: virtual void environment_set_dof_blur_far(RID p_env, bool p_enable, float p_distance, float p_transition, float p_amount, RS::Environment3DDOFBlurQuality p_quality); virtual void environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_bloom_threshold, RS::Environment3DGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, float p_hdr_luminance_cap, bool p_bicubic_upscale, bool p_high_quality); + virtual void environment_set_glow_map(RID p_env, float p_glow_map_strength, RID p_glow_map); + virtual void environment_set_fog(RID p_env, bool p_enable, float p_begin, float p_end, RID p_gradient_texture); virtual void environment_set_ssr(RID p_env, bool p_enable, int p_max_steps, float p_fade_in, float p_fade_out, float p_depth_tolerance, bool p_roughness); diff --git a/drivers/gles3/shaders/tonemap.glsl b/drivers/gles3/shaders/tonemap.glsl index bdf0bd8d2..da9f33516 100644 --- a/drivers/gles3/shaders/tonemap.glsl +++ b/drivers/gles3/shaders/tonemap.glsl @@ -42,6 +42,8 @@ uniform highp float auto_exposure_grey; uniform highp sampler2D source_glow; //texunit:2 uniform highp float glow_intensity; +uniform highp float glow_map_strength; +uniform highp sampler2D glow_map; //texunit:3 #endif #ifdef USE_BCS @@ -57,7 +59,7 @@ uniform float sharpen_intensity; #endif #ifdef USE_COLOR_CORRECTION -uniform sampler2D color_correction; //texunit:3 +uniform sampler2D color_correction; //texunit:4 #endif layout(location = 0) out vec4 frag_color; @@ -482,6 +484,9 @@ void main() { #ifdef USING_GLOW vec3 glow = gather_glow(source_glow, uv_interp) * glow_intensity; + if (glow_map_strength > 0.001) { + glow = mix(glow, texture(glow_map, vec2(uv_interp.x, 1.0 - uv_interp.y)).rgb * glow, glow_map_strength); + } // high dynamic range -> SRGB glow = apply_tonemapping(glow, white); diff --git a/scene/resources/environment_3d.cpp b/scene/resources/environment_3d.cpp index 8471b2bba..3d00488d6 100644 --- a/scene/resources/environment_3d.cpp +++ b/scene/resources/environment_3d.cpp @@ -487,7 +487,7 @@ float Environment3D::get_ssao_edge_sharpness() const { void Environment3D::set_glow_enabled(bool p_enabled) { glow_enabled = p_enabled; - RS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_bloom, RS::Environment3DGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_scale, glow_hdr_luminance_cap, glow_bicubic_upscale, glow_high_quality); + _update_glow(); _change_notify(); } @@ -504,7 +504,7 @@ void Environment3D::set_glow_level(int p_level, bool p_enabled) { glow_levels &= ~(1 << p_level); } - RS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_bloom, RS::Environment3DGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_scale, glow_hdr_luminance_cap, glow_bicubic_upscale, glow_high_quality); + _update_glow(); } bool Environment3D::is_glow_level_enabled(int p_level) const { ERR_FAIL_INDEX_V(p_level, RS::MAX_GLOW_LEVELS, false); @@ -515,7 +515,7 @@ bool Environment3D::is_glow_level_enabled(int p_level) const { void Environment3D::set_glow_intensity(float p_intensity) { glow_intensity = p_intensity; - RS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_bloom, RS::Environment3DGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_scale, glow_hdr_luminance_cap, glow_bicubic_upscale, glow_high_quality); + _update_glow(); } float Environment3D::get_glow_intensity() const { return glow_intensity; @@ -523,7 +523,8 @@ float Environment3D::get_glow_intensity() const { void Environment3D::set_glow_strength(float p_strength) { glow_strength = p_strength; - RS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_bloom, RS::Environment3DGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_scale, glow_hdr_luminance_cap, glow_bicubic_upscale, glow_high_quality); + + _update_glow(); } float Environment3D::get_glow_strength() const { return glow_strength; @@ -532,7 +533,7 @@ float Environment3D::get_glow_strength() const { void Environment3D::set_glow_bloom(float p_threshold) { glow_bloom = p_threshold; - RS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_bloom, RS::Environment3DGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_scale, glow_hdr_luminance_cap, glow_bicubic_upscale, glow_high_quality); + _update_glow(); } float Environment3D::get_glow_bloom() const { return glow_bloom; @@ -541,7 +542,7 @@ float Environment3D::get_glow_bloom() const { void Environment3D::set_glow_blend_mode(GlowBlendMode p_mode) { glow_blend_mode = p_mode; - RS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_bloom, RS::Environment3DGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_scale, glow_hdr_luminance_cap, glow_bicubic_upscale, glow_high_quality); + _update_glow(); } Environment3D::GlowBlendMode Environment3D::get_glow_blend_mode() const { return glow_blend_mode; @@ -550,7 +551,7 @@ Environment3D::GlowBlendMode Environment3D::get_glow_blend_mode() const { void Environment3D::set_glow_hdr_bleed_threshold(float p_threshold) { glow_hdr_bleed_threshold = p_threshold; - RS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_bloom, RS::Environment3DGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_scale, glow_hdr_luminance_cap, glow_bicubic_upscale, glow_high_quality); + _update_glow(); } float Environment3D::get_glow_hdr_bleed_threshold() const { return glow_hdr_bleed_threshold; @@ -559,7 +560,7 @@ float Environment3D::get_glow_hdr_bleed_threshold() const { void Environment3D::set_glow_hdr_luminance_cap(float p_amount) { glow_hdr_luminance_cap = p_amount; - RS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_bloom, RS::Environment3DGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_scale, glow_hdr_luminance_cap, glow_bicubic_upscale, glow_high_quality); + _update_glow(); } float Environment3D::get_glow_hdr_luminance_cap() const { return glow_hdr_luminance_cap; @@ -568,7 +569,7 @@ float Environment3D::get_glow_hdr_luminance_cap() const { void Environment3D::set_glow_hdr_bleed_scale(float p_scale) { glow_hdr_bleed_scale = p_scale; - RS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_bloom, RS::Environment3DGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_scale, glow_hdr_luminance_cap, glow_bicubic_upscale, glow_high_quality); + _update_glow(); } float Environment3D::get_glow_hdr_bleed_scale() const { return glow_hdr_bleed_scale; @@ -576,7 +577,8 @@ float Environment3D::get_glow_hdr_bleed_scale() const { void Environment3D::set_glow_bicubic_upscale(bool p_enable) { glow_bicubic_upscale = p_enable; - RS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_bloom, RS::Environment3DGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_scale, glow_hdr_luminance_cap, glow_bicubic_upscale, glow_high_quality); + + _update_glow(); } bool Environment3D::is_glow_bicubic_upscale_enabled() const { @@ -585,13 +587,59 @@ bool Environment3D::is_glow_bicubic_upscale_enabled() const { void Environment3D::set_glow_high_quality(bool p_enable) { glow_high_quality = p_enable; - RS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_bloom, RS::Environment3DGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_scale, glow_hdr_luminance_cap, glow_bicubic_upscale, glow_high_quality); + + _update_glow(); } bool Environment3D::is_glow_high_quality_enabled() const { return glow_high_quality; } +void Environment3D::set_glow_map_strength(float p_glow_map_strength) { + glow_map_strength = p_glow_map_strength; + _update_glow_map(); +} + +float Environment3D::get_glow_map_strength() const { + return glow_map_strength; +} + +void Environment3D::set_glow_map(Ref p_glow_map) { + glow_map = p_glow_map; + _update_glow_map(); +} + +Ref Environment3D::get_glow_map() const { + return glow_map; +} + +void Environment3D::_update_glow() { + RS::get_singleton()->environment_set_glow( + environment, + glow_enabled, + glow_levels, + glow_intensity, + glow_strength, + glow_bloom, + RS::Environment3DGlowBlendMode(glow_blend_mode), + glow_hdr_bleed_threshold, + glow_hdr_bleed_scale, + glow_hdr_luminance_cap, + glow_bicubic_upscale, + glow_high_quality); +} + +void Environment3D::_update_glow_map() { + float _glow_map_strength = 0.0f; + RID glow_map_rid; + if (glow_map.is_valid()) { + glow_map_rid = glow_map->get_rid(); + _glow_map_strength = glow_map_strength; + } + + RS::get_singleton()->environment_set_glow_map(environment, _glow_map_strength, glow_map_rid); +} + void Environment3D::set_dof_blur_far_enabled(bool p_enable) { dof_blur_far_enabled = p_enable; RS::get_singleton()->environment_set_dof_blur_far(environment, dof_blur_far_enabled, dof_blur_far_distance, dof_blur_far_transition, dof_blur_far_amount, RS::Environment3DDOFBlurQuality(dof_blur_far_quality)); @@ -1086,6 +1134,12 @@ void Environment3D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_glow_high_quality", "enabled"), &Environment3D::set_glow_high_quality); ClassDB::bind_method(D_METHOD("is_glow_high_quality_enabled"), &Environment3D::is_glow_high_quality_enabled); + ClassDB::bind_method(D_METHOD("set_glow_map_strength", "strength"), &Environment3D::set_glow_map_strength); + ClassDB::bind_method(D_METHOD("get_glow_map_strength"), &Environment3D::get_glow_map_strength); + + ClassDB::bind_method(D_METHOD("set_glow_map", "mode"), &Environment3D::set_glow_map); + ClassDB::bind_method(D_METHOD("get_glow_map"), &Environment3D::get_glow_map); + ADD_GROUP("Glow", "glow_"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "glow_enabled"), "set_glow_enabled", "is_glow_enabled"); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "glow_levels/1"), "set_glow_level", "is_glow_level_enabled", 0); @@ -1105,6 +1159,8 @@ void Environment3D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::REAL, "glow_hdr_scale", PROPERTY_HINT_RANGE, "0.0,4.0,0.01"), "set_glow_hdr_bleed_scale", "get_glow_hdr_bleed_scale"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "glow_bicubic_upscale"), "set_glow_bicubic_upscale", "is_glow_bicubic_upscale_enabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "glow_high_quality"), "set_glow_high_quality", "is_glow_high_quality_enabled"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "glow_map_strength", PROPERTY_HINT_RANGE, "0.0,1.0,0.01"), "set_glow_map_strength", "get_glow_map_strength"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "glow_map", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_glow_map", "get_glow_map"); ClassDB::bind_method(D_METHOD("set_adjustment_enable", "enabled"), &Environment3D::set_adjustment_enable); ClassDB::bind_method(D_METHOD("is_adjustment_enabled"), &Environment3D::is_adjustment_enabled); @@ -1229,6 +1285,7 @@ Environment3D::Environment3D() : glow_hdr_bleed_scale = 2.0; glow_bicubic_upscale = false; glow_high_quality = false; + glow_map_strength = 0.8f; dof_blur_far_enabled = false; dof_blur_far_distance = 10; @@ -1268,3 +1325,4 @@ Environment3D::Environment3D() : Environment3D::~Environment3D() { RS::get_singleton()->free(environment); } + diff --git a/scene/resources/environment_3d.h b/scene/resources/environment_3d.h index b3a74e11c..4dd2ac73a 100644 --- a/scene/resources/environment_3d.h +++ b/scene/resources/environment_3d.h @@ -147,6 +147,11 @@ private: float glow_hdr_luminance_cap; bool glow_bicubic_upscale; bool glow_high_quality; + float glow_map_strength; + Ref glow_map; + + void _update_glow(); + void _update_glow_map(); bool dof_blur_far_enabled; float dof_blur_far_distance; @@ -335,6 +340,12 @@ public: void set_glow_high_quality(bool p_enable); bool is_glow_high_quality_enabled() const; + void set_glow_map_strength(float p_glow_map_strength); + float get_glow_map_strength() const; + + void set_glow_map(Ref p_glow_map); + Ref get_glow_map() const; + void set_dof_blur_far_enabled(bool p_enable); bool is_dof_blur_far_enabled() const; diff --git a/servers/rendering/rasterizer.h b/servers/rendering/rasterizer.h index 70552e89e..71e61ce70 100644 --- a/servers/rendering/rasterizer.h +++ b/servers/rendering/rasterizer.h @@ -66,6 +66,7 @@ public: virtual void environment_set_dof_blur_near(RID p_env, bool p_enable, float p_distance, float p_transition, float p_far_amount, RS::Environment3DDOFBlurQuality p_quality) = 0; virtual void environment_set_dof_blur_far(RID p_env, bool p_enable, float p_distance, float p_transition, float p_far_amount, RS::Environment3DDOFBlurQuality p_quality) = 0; virtual void environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_bloom_threshold, RS::Environment3DGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, float p_hdr_luminance_cap, bool p_bicubic_upscale, bool p_high_quality) = 0; + virtual void environment_set_glow_map(RID p_env, float p_glow_map_strength, RID p_glow_map) = 0; virtual void environment_set_fog(RID p_env, bool p_enable, float p_begin, float p_end, RID p_gradient_texture) = 0; virtual void environment_set_ssr(RID p_env, bool p_enable, int p_max_steps, float p_fade_int, float p_fade_out, float p_depth_tolerance, bool p_roughness) = 0; diff --git a/servers/rendering/rendering_server_raster.h b/servers/rendering/rendering_server_raster.h index ac94726bd..88c1a7216 100644 --- a/servers/rendering/rendering_server_raster.h +++ b/servers/rendering/rendering_server_raster.h @@ -538,6 +538,7 @@ public: BIND6(environment_set_dof_blur_near, RID, bool, float, float, float, Environment3DDOFBlurQuality) BIND6(environment_set_dof_blur_far, RID, bool, float, float, float, Environment3DDOFBlurQuality) BIND12(environment_set_glow, RID, bool, int, float, float, float, Environment3DGlowBlendMode, float, float, float, bool, bool) + BIND3(environment_set_glow_map, RID, float, RID) BIND9(environment_set_tonemap, RID, Environment3DToneMapper, float, float, bool, float, float, float, float) diff --git a/servers/rendering/rendering_server_wrap_mt.h b/servers/rendering/rendering_server_wrap_mt.h index fe1f01ef5..b24f72283 100644 --- a/servers/rendering/rendering_server_wrap_mt.h +++ b/servers/rendering/rendering_server_wrap_mt.h @@ -451,6 +451,7 @@ public: FUNC6(environment_set_dof_blur_near, RID, bool, float, float, float, Environment3DDOFBlurQuality) FUNC6(environment_set_dof_blur_far, RID, bool, float, float, float, Environment3DDOFBlurQuality) FUNC12(environment_set_glow, RID, bool, int, float, float, float, Environment3DGlowBlendMode, float, float, float, bool, bool) + FUNC3(environment_set_glow_map, RID, float, RID) FUNC9(environment_set_tonemap, RID, Environment3DToneMapper, float, float, bool, float, float, float, float) diff --git a/servers/rendering_server.cpp b/servers/rendering_server.cpp index 3e88e89ff..eee3ee95a 100644 --- a/servers/rendering_server.cpp +++ b/servers/rendering_server.cpp @@ -2143,6 +2143,7 @@ void RenderingServer::_bind_methods() { ClassDB::bind_method(D_METHOD("environment_set_dof_blur_near", "env", "enable", "distance", "transition", "far_amount", "quality"), &RenderingServer::environment_set_dof_blur_near); ClassDB::bind_method(D_METHOD("environment_set_dof_blur_far", "env", "enable", "distance", "transition", "far_amount", "quality"), &RenderingServer::environment_set_dof_blur_far); ClassDB::bind_method(D_METHOD("environment_set_glow", "env", "enable", "level_flags", "intensity", "strength", "bloom_threshold", "blend_mode", "hdr_bleed_threshold", "hdr_bleed_scale", "hdr_luminance_cap", "bicubic_upscale", "high_quality"), &RenderingServer::environment_set_glow); + ClassDB::bind_method(D_METHOD("environment_set_glow_map", "env", "glow_map_strength", "glow_map"), &RenderingServer::environment_set_glow_map); ClassDB::bind_method(D_METHOD("environment_set_tonemap", "env", "tone_mapper", "exposure", "white", "auto_exposure", "min_luminance", "max_luminance", "auto_exp_speed", "auto_exp_grey"), &RenderingServer::environment_set_tonemap); ClassDB::bind_method(D_METHOD("environment_set_adjustment", "env", "enable", "brightness", "contrast", "saturation", "ramp"), &RenderingServer::environment_set_adjustment); ClassDB::bind_method(D_METHOD("environment_set_ssr", "env", "enable", "max_steps", "fade_in", "fade_out", "depth_tolerance", "roughness"), &RenderingServer::environment_set_ssr); diff --git a/servers/rendering_server.h b/servers/rendering_server.h index 8cd4886d1..09df9f7b2 100644 --- a/servers/rendering_server.h +++ b/servers/rendering_server.h @@ -792,7 +792,9 @@ public: GLOW_BLEND_MODE_SOFTLIGHT, GLOW_BLEND_MODE_REPLACE, }; + virtual void environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_bloom_threshold, Environment3DGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, float p_hdr_luminance_cap, bool p_bicubic_upscale, bool p_high_quality) = 0; + virtual void environment_set_glow_map(RID p_env, float p_glow_map_strength, RID p_glow_map) = 0; enum Environment3DToneMapper { ENV_TONE_MAPPER_LINEAR,