Improved Bloom Effect by adding a Radius-parameter
This commit is contained in:
parent
c492470430
commit
7ea788534c
4 changed files with 17 additions and 3 deletions
|
|
@ -77,6 +77,12 @@ namespace SM.Base.PostEffects
|
|||
/// </summary>
|
||||
public float Power = 1;
|
||||
|
||||
/// <summary>
|
||||
/// Radius of the effect
|
||||
/// <para>Default: 2</para>
|
||||
/// </summary>
|
||||
public float Radius = 2;
|
||||
|
||||
/// <summary>
|
||||
/// This can disable the bloom calculation.
|
||||
/// <para>Default: true</para>
|
||||
|
|
@ -175,6 +181,8 @@ namespace SM.Base.PostEffects
|
|||
collection["Weights"].SetUniform1(_weights);
|
||||
collection["WeightCount"].SetUniform1(WeightCurvePickAmount);
|
||||
collection["Power"].SetUniform1(Power);
|
||||
|
||||
collection["Radius"].SetUniform1(_textureScale * Radius);
|
||||
});
|
||||
|
||||
hoz = !hoz;
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ uniform float[32] Weights;
|
|||
uniform int WeightCount;
|
||||
uniform float Power;
|
||||
|
||||
uniform float Radius;
|
||||
|
||||
layout(location = 0) out vec4 color;
|
||||
|
||||
vec4 GetRenderColorOffset(vec2 offset);
|
||||
|
|
@ -37,8 +39,8 @@ void main() {
|
|||
result *= GetWeight(0);
|
||||
|
||||
for(int i = 1; i < WeightCount; i++) {
|
||||
result += max(GetRenderColorOffset(tex_offset * i).rgb - thres, 0) * (First ? Power : 1) * GetWeight(i);
|
||||
result += max(GetRenderColorOffset(-tex_offset * i).rgb - thres, 0) * (First ? Power : 1) * GetWeight(i);
|
||||
result += max(GetRenderColorOffset(tex_offset * i * Radius).rgb - thres, 0) * (First ? Power : 1) * GetWeight(i);
|
||||
result += max(GetRenderColorOffset(-tex_offset * i * Radius).rgb - thres, 0) * (First ? Power : 1) * GetWeight(i);
|
||||
}
|
||||
|
||||
color = vec4(result, 1);
|
||||
|
|
|
|||
|
|
@ -23,8 +23,11 @@ namespace SM_TEST
|
|||
{
|
||||
window = new GLWindow();
|
||||
window.ApplySetup(new Window2DSetup());
|
||||
window.SetRenderPipeline(new TestRenderPipeline());
|
||||
|
||||
window.SetScene(scene = new Scene());
|
||||
scene.Objects.Add(new DrawObject2D());
|
||||
|
||||
window.UpdateFrame += WindowOnUpdateFrame;
|
||||
window.Run();
|
||||
|
||||
|
|
|
|||
|
|
@ -18,9 +18,10 @@ namespace SM_TEST
|
|||
|
||||
_postBuffer = CreateWindowFramebuffer(0);
|
||||
Framebuffers.Add(_postBuffer);
|
||||
_bloom = new BloomEffect(MainFramebuffer, hdr: true, .75f)
|
||||
_bloom = new BloomEffect(MainFramebuffer, hdr: true, .5f)
|
||||
{
|
||||
Threshold = .5f,
|
||||
Radius = 5
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue