Hard Light Productions Forums

Community Projects => The FreeSpace Upgrade Project => Topic started by: The E on July 01, 2011, 04:50:08 am

Title: A new bloom effect
Post by: The E on July 01, 2011, 04:50:08 am
Coming soon to a MediaVPs release near you, a new, more detailed bloom effect.

A few pics to show it in action:

Reference bloom off:
(http://blueplanet.fsmods.net/E/pics/bloom0.png)

Bloom level 50:
(http://blueplanet.fsmods.net/E/pics/bloom50.png)

Level 100:
(http://blueplanet.fsmods.net/E/pics/bloom100.png)

Level 150:
(http://blueplanet.fsmods.net/E/pics/bloom150.png)

Level 200:
(http://blueplanet.fsmods.net/E/pics/bloom200.png)

If you want it yourself, save the following text as blur-f.sdr in mediavps_3612/data/effects.

Code: [Select]
varying float blurSize;

uniform sampler2D tex;

#define BLUR_SIZE_DIV 3

// Gaussian Blur
// 512x512 and smaller textures give best results
// 2 passes required
void main()
{
// Echelon9 - Due to Apple not implementing array constructors in OS X's
// GLSL implementation we need to setup the arrays this way as a workaround
float BlurWeights[6];

BlurWeights[5] = 0.0402;
BlurWeights[4] = 0.0623;
BlurWeights[3] = 0.0877;
BlurWeights[2] = 0.1120;
BlurWeights[1] = 0.1297;
BlurWeights[0] = 0.1362;

vec4 sum = texture2D(tex, gl_TexCoord[0].xy) * BlurWeights[0];

#ifdef PASS_0
for (int i = 1; i < 6; i++) {
sum += texture2D(tex, vec2(clamp(gl_TexCoord[0].x - float(i) * (blurSize/BLUR_SIZE_DIV), 0.0, 1.0), gl_TexCoord[0].y)) * BlurWeights[i];
sum += texture2D(tex, vec2(clamp(gl_TexCoord[0].x + float(i) * (blurSize/BLUR_SIZE_DIV), 0.0, 1.0), gl_TexCoord[0].y)) * BlurWeights[i];
}
#endif

#ifdef PASS_1
for (int i = 1; i < 6; i++) {
sum += texture2D(tex, vec2(gl_TexCoord[0].x, clamp(gl_TexCoord[0].y - float(i) * (blurSize/2), 0.0, 1.0))) * BlurWeights[i];
sum += texture2D(tex, vec2(gl_TexCoord[0].x, clamp(gl_TexCoord[0].y + float(i) * (blurSize/2), 0.0, 1.0))) * BlurWeights[i];
}
#endif

gl_FragColor = sum;
}


This needs to be saved as post-v.sdr:

Code: [Select]
varying float blurSize;
uniform float bsize;

void main()
{
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_Position = gl_Vertex;

gl_FrontColor = gl_Color;
gl_FrontSecondaryColor = vec4(0.0, 0.0, 0.0, 1.0);

blurSize = 1.0 / bsize;

 // Check necessary for ATI specific behavior
 #ifdef __GLSL_CG_DATA_TYPES
gl_ClipVertex = (gl_ModelViewMatrix * gl_Vertex);
 #endif
}
Title: Re: A new bloom effect
Post by: Commander Zane on July 01, 2011, 06:40:17 am
This looks awesome, though I fear it'll look bad on my system at certain angles when / if the bloom is rendered as vertical lines.
Title: Re: A new bloom effect
Post by: The E on July 01, 2011, 07:34:29 am
Shaders and pictures have been updated. Force refresh if you can't see them
Title: Re: A new bloom effect
Post by: Kolgena on July 01, 2011, 08:30:33 am
Looks really good. Much better than the old effect, IMO, if only because the vertical striping artifacts are gone now. That, and much less over saturation than before, as far as I can tell.
Title: Re: A new bloom effect
Post by: MetalDestroyer on July 01, 2011, 08:32:59 am
Is there a way to increase lighting generated from the glowmaps ?
I don't really like bloom effect in most time since it increase all lighting sources.

I tried to change the value of the flag spec_point  but, I don't notice any radical change.
Title: Re: A new bloom effect
Post by: Rodo on July 01, 2011, 08:33:37 am
amazing, will test it with FSport in a couple of days then :D
Title: Re: A new bloom effect
Post by: Thaeris on July 01, 2011, 08:37:45 am
E, is there any particular difference in this new feature and the FAXX feature you highlighted a few days ago? I do see FAXX in the screenshots as well...
Title: Re: A new bloom effect
Post by: MetalDestroyer on July 01, 2011, 08:51:40 am
E, is there any particular difference in this new feature and the FAXX feature you highlighted a few days ago? I do see FAXX in the screenshots as well...

FXAA is a rendering method for anti-aliasing when you have post processing render.
Title: Re: A new bloom effect
Post by: Commander Zane on July 01, 2011, 08:56:42 am
Ohmygod the bloom effect isn't ugly on my screen anymore.
Outstanding work!
:jaw:
Title: Re: A new bloom effect
Post by: The E on July 01, 2011, 09:08:25 am
E, is there any particular difference in this new feature and the FAXX feature you highlighted a few days ago? I do see FAXX in the screenshots as well...

They're very diferent. FXAA is an antialiasing filter that you can use if hardware antialiasing doesn't work with postprocessing for you. This is a new bloom shader, one that makes the bloom effect less susceptible to the "banding" effect it exhibited previously.

Is there a way to increase lighting generated from the glowmaps ?
I don't really like bloom effect in most time since it increase all lighting sources.

I tried to change the value of the flag spec_point  but, I don't notice any radical change.

No, the bloom effect cannot differentiate between lighting generated by reflections and lighting generated by glowmaps.
Title: Re: A new bloom effect
Post by: Sushi on July 01, 2011, 01:56:38 pm
Will this go into the built-in shaders?

Any reason for it not to?
Title: Re: A new bloom effect
Post by: The E on July 01, 2011, 02:04:06 pm
Yes, it will. No reason for it not to.
Title: Re: A new bloom effect
Post by: Snail on July 02, 2011, 06:20:09 am
Does this work with those ATI cards?
Title: Re: A new bloom effect
Post by: The E on July 02, 2011, 06:29:37 am
Yes. Or No. Depends on what you mean by those.
Title: Re: A new bloom effect
Post by: Commander Zane on July 02, 2011, 11:54:53 am
All of them. :P

11.4 with 5870 works for me without quarrel as far as I know.