2 registered members (TipmyPip, 1 invisible),
18,699
guests, and 8
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Cheap, Horrible Bloom
#104199
12/28/06 03:01
12/28/06 03:01
|
Joined: Aug 2002
Posts: 681 Massachusetts, USA
Ichiro
OP
User
|
OP
User
Joined: Aug 2002
Posts: 681
Massachusetts, USA
|
 This, here, is some cheap, horrible bloom as a full-screen shader. And by "cheap," I mean, "you get what you pay for." Which isn't very much, these days. The top image is a scene without the bloom. The middle image is a scene with the bloom described below. The bottom image is with the ds division removed. Code:
// Bloom test: material mat_bloom_2 { effect = " sampler2D g_samSrcColor; float ds; float4 Color;
float4 MyShader( float2 Tex : TEXCOORD0 ) : COLOR0 { Color = tex2D( g_samSrcColor, Tex.xy);
// Go four pixels out and blend them to this one: for(ds=1; ds<4; ds++) { Color += pow( tex2D( g_samSrcColor, float2(Tex.x-ds*0.002, Tex.y)), 3.0f)/ds; Color += pow( tex2D( g_samSrcColor, float2(Tex.x+ds*0.002, Tex.y)), 3.0f)/ds; Color += pow( tex2D( g_samSrcColor, float2(Tex.x, Tex.y-ds*0.002)), 3.0f)/ds; Color += pow( tex2D( g_samSrcColor, float2(Tex.x, Tex.y+ds*0.002)), 3.0f)/ds; }
return Color; }
// Just one pass: technique PostProcess { pass p1 { VertexShader = null; PixelShader = compile ps_2_0 MyShader(); } } "; }
I apply this to a screen-aligned quad (requires Pro for render-to-texture). As you might be able to tell, I'm just goofing around. I don't actually know anytihng about shaders. Yet! ; )
|
|
|
Re: Cheap, Horrible Bloom
[Re: Ichiro]
#104203
12/28/06 21:06
12/28/06 21:06
|
Joined: Sep 2002
Posts: 8,177 Netherlands
PHeMoX
Senior Expert
|
Senior Expert
Joined: Sep 2002
Posts: 8,177
Netherlands
|
Nice effect Ichiro and thanks for sharing!! Quote:
This could be usefull, but wouldn't this result in a regular blur in images with more details/transitions?
No, but it will become a blur effect if you change say ds<4 to ds<1 though.
Code:
// blur only: for(ds=1; ds<1; ds++) { Color += pow( tex2D( g_samSrcColor, float2(Tex.x-ds*0.002, Tex.y)), 3.0f)/ds; Color += pow( tex2D( g_samSrcColor, float2(Tex.x+ds*0.002, Tex.y)), 3.0f)/ds; Color += pow( tex2D( g_samSrcColor, float2(Tex.x, Tex.y-ds*0.002)), 3.0f)/ds; Color += pow( tex2D( g_samSrcColor, float2(Tex.x, Tex.y+ds*0.002)), 3.0f)/ds; }
|
|
|
Re: Cheap, Horrible Bloom
[Re: PHeMoX]
#104204
12/29/06 12:58
12/29/06 12:58
|
Joined: Jan 2004
Posts: 2,013 The Netherlands
Excessus
Expert
|
Expert
Joined: Jan 2004
Posts: 2,013
The Netherlands
|
Hmm, I should really read and think before I post..  I hadn't seen the pow() at all. And about that project.. Can't seem to find it  I still remember some things that might be usefull for improving this effect. You can compute a luminance value by dotting the original color with a precomputed luminance vector like this: float Luminance = dot(OriginalColor, float3(0.299f, 0.587f, 0.114f)); You can output that value in the first pass and then use several blur passes to blur the result and then blend it with the original image. This way it can be made to work for 1.1 shaders, but you could also do a single (gaussian) blur pass. This also allows you to controll the way you blend the blurred and original image; when leaving a tunnel/cave, you could create an 'overexposure' effect by turning up a variable in cscript. Not sure you where even looking for advice, but here it is anyway 
|
|
|
Re: Cheap, Horrible Bloom
[Re: Ichiro]
#104206
12/29/06 19:58
12/29/06 19:58
|
Joined: Sep 2002
Posts: 8,177 Netherlands
PHeMoX
Senior Expert
|
Senior Expert
Joined: Sep 2002
Posts: 8,177
Netherlands
|
I've got one small question, what size is your screen aligned quad (view entity's?) bitmap? At the moment I'm in a battle with resolution errors when this bloom is active (e.g. I click somewhere and the target were supposedly was clicked give a wrong location because of view displacement of some sort.) Thanks in advance,  Cheers
|
|
|
|