Improved Bloom Effect by adding a Radius-parameter

This commit is contained in:
Michel Fedde 2021-03-24 13:08:27 +01:00
parent c492470430
commit 7ea788534c
4 changed files with 17 additions and 3 deletions

View file

@ -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;

View file

@ -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);