diff --git a/Assets/BuiltIn/Shader/PostProcessing/Bloom.xml b/Assets/BuiltIn/Shader/PostProcessing/Bloom.xml index b3b674c10..a380b2588 100644 --- a/Assets/BuiltIn/Shader/PostProcessing/Bloom.xml +++ b/Assets/BuiltIn/Shader/PostProcessing/Bloom.xml @@ -6,6 +6,7 @@ + diff --git a/Assets/BuiltIn/Shader/PostProcessing/GLSL/BloomFS.glsl b/Assets/BuiltIn/Shader/PostProcessing/GLSL/BloomFS.glsl index 564c98895..b35bf4016 100644 --- a/Assets/BuiltIn/Shader/PostProcessing/GLSL/BloomFS.glsl +++ b/Assets/BuiltIn/Shader/PostProcessing/GLSL/BloomFS.glsl @@ -3,7 +3,7 @@ precision mediump float; uniform sampler2D uSourceTex; uniform sampler2D uBlurTex; -uniform vec2 uTexelSize; +uniform float uBloomIntensity; in vec2 varTexCoord0; @@ -16,9 +16,8 @@ void main(void) // blur color vec3 blur = texture(uBlurTex, varTexCoord0).rgb; - - float intensity = 1.0; - vec3 m = base + blur * intensity; + + vec3 m = base + blur * uBloomIntensity; FragColor = vec4(m, 1.0); } \ No newline at end of file diff --git a/Assets/BuiltIn/Shader/PostProcessing/HLSL/BloomFS.hlsl b/Assets/BuiltIn/Shader/PostProcessing/HLSL/BloomFS.hlsl index f2cc61958..8cf28bfcf 100644 --- a/Assets/BuiltIn/Shader/PostProcessing/HLSL/BloomFS.hlsl +++ b/Assets/BuiltIn/Shader/PostProcessing/HLSL/BloomFS.hlsl @@ -13,7 +13,7 @@ struct PS_INPUT cbuffer cbPerFrame { - float2 uTexelSize; + float uBloomIntensity; }; float4 main(PS_INPUT input) : SV_TARGET @@ -23,9 +23,8 @@ float4 main(PS_INPUT input) : SV_TARGET // blur color float3 blur = uBlurTex.Sample(uBlurTexSampler, input.tex0).rgb; - - float intensity = 1.0; - float3 m = base + blur * intensity; + + float3 m = base + blur * uBloomIntensity; return float4(m, 1.0); } \ No newline at end of file diff --git a/Projects/Skylicht/Engine/Source/RenderPipeline/CPostProcessorRP.cpp b/Projects/Skylicht/Engine/Source/RenderPipeline/CPostProcessorRP.cpp index feeec4633..fc95fe99c 100644 --- a/Projects/Skylicht/Engine/Source/RenderPipeline/CPostProcessorRP.cpp +++ b/Projects/Skylicht/Engine/Source/RenderPipeline/CPostProcessorRP.cpp @@ -42,7 +42,8 @@ namespace Skylicht m_bloomFilter(NULL), m_fxaaFilter(NULL), m_numTarget(0), - m_bloomThreshold(0.9f) + m_bloomThreshold(0.9f), + m_bloomIntensity(1.0f) { m_luminance[0] = NULL; m_luminance[1] = NULL; @@ -234,6 +235,8 @@ namespace Skylicht m_bloomFilter->setTexture(1, m_rtt[2]); m_bloomFilter->applyMaterial(m_effectPass); + m_bloomFilter->setUniform("uBloomIntensity", m_bloomIntensity); + CShaderMaterial::setMaterial(m_bloomFilter); colorID = 0; diff --git a/Projects/Skylicht/Engine/Source/RenderPipeline/CPostProcessorRP.h b/Projects/Skylicht/Engine/Source/RenderPipeline/CPostProcessorRP.h index ecee29ad6..8dabcea13 100644 --- a/Projects/Skylicht/Engine/Source/RenderPipeline/CPostProcessorRP.h +++ b/Projects/Skylicht/Engine/Source/RenderPipeline/CPostProcessorRP.h @@ -53,6 +53,7 @@ namespace Skylicht SMaterial m_effectPass; float m_bloomThreshold; + float m_bloomIntensity; bool m_autoExposure; bool m_bloomEffect; @@ -103,6 +104,11 @@ namespace Skylicht m_bloomThreshold = f; } + inline void setBloomIntensity(float f) + { + m_bloomIntensity = f; + } + protected: void renderEffect(int fromTarget, int toTarget, CMaterial *material); diff --git a/Samples/ParticlesMagicSkill/Source/SampleParticlesMagicSkill.cpp b/Samples/ParticlesMagicSkill/Source/SampleParticlesMagicSkill.cpp index b1e8867fd..8873358cf 100644 --- a/Samples/ParticlesMagicSkill/Source/SampleParticlesMagicSkill.cpp +++ b/Samples/ParticlesMagicSkill/Source/SampleParticlesMagicSkill.cpp @@ -120,6 +120,7 @@ void SampleParticlesMagicSkill::onInitApp() m_postProcessorRP = new CPostProcessorRP(); m_postProcessorRP->setBloomThreshold(0.7f); + m_postProcessorRP->setBloomIntensity(2.0f); m_postProcessorRP->initRender(w, h); m_forwardRP->setPostProcessor(m_postProcessorRP); }