Fragment brightness has now a effect on the radius

This commit is contained in:
Michel Fedde 2021-03-24 14:02:48 +01:00
parent ddd2171da2
commit 9fa1ac6ad9
3 changed files with 9 additions and 8 deletions

View file

@ -81,7 +81,7 @@ namespace SM.Base.PostEffects
/// Radius of the effect
/// <para>Default: 2</para>
/// </summary>
public float Radius = 2;
public float Radius = 1;
/// <summary>
/// This can disable the bloom calculation.

View file

@ -35,12 +35,13 @@ void main() {
vec2 tex_offset = 1.0 / textureSize(renderedTexture, 0) * vec2(Horizontal ? 1 : 0, Horizontal ? 0 : 1);
vec3 result = max(GetRenderColorOffset(vec2(0)).rgb - thres, 0) * (First ? Power : 1);
result *= GetWeight(0);
vec3 result = max(GetRenderColorOffset(vec2(0)).rgb - thres, 0) * (First ? Power : 1) * GetWeight(0);
float radi = Radius + (length(result));
for(int i = 1; i < WeightCount; 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);
result += max(GetRenderColorOffset(tex_offset * i * radi).rgb - thres, 0) * (First ? Power : 1) * GetWeight(i);
result += max(GetRenderColorOffset(-tex_offset * i * radi).rgb - thres, 0) * (First ? Power : 1) * GetWeight(i);
}
color = vec4(result, 1);

View file

@ -16,11 +16,11 @@ namespace SM_TEST
MainFramebuffer = CreateWindowFramebuffer(16, PixelInformation.RGBA_HDR);
_postBuffer = CreateWindowFramebuffer(0, depth: false);
_postBuffer = CreateWindowFramebuffer(0, PixelInformation.RGBA_HDR, depth: false);
Framebuffers.Add(_postBuffer);
_bloom = new BloomEffect(_postBuffer, hdr: true, .5f)
{
Threshold = .5f
Threshold = .8f,
};
@ -40,7 +40,7 @@ namespace SM_TEST
_bloom.Draw(context);
Framebuffer.Screen.Activate(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
PostProcessUtility.FinalizeHDR(_postBuffer["color"], 1);
PostProcessUtility.FinalizeHDR(_postBuffer["color"], .5f);
context.Scene.DrawDebug(context);
}