Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
1 registered members (TipmyPip), 18,449 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Cheap, Horrible Bloom #104199
12/28/06 03:01
12/28/06 03:01
Joined: Aug 2002
Posts: 681
Massachusetts, USA
Ichiro Offline OP
User
Ichiro  Offline 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! ;)


Dejobaan Games - Bringing you quality video games for over 75 years.
Re: Cheap, Horrible Bloom [Re: Ichiro] #104200
12/28/06 10:02
12/28/06 10:02
Joined: Jan 2004
Posts: 2,013
The Netherlands
E
Excessus Offline
Expert
Excessus  Offline
Expert
E

Joined: Jan 2004
Posts: 2,013
The Netherlands
This could be usefull, but wouldn't this result in a regular blur in images with more details/transitions? You might also want to tap diagonally, because the colored dots in your image are stretched in horizontal and vertical direction.

If you want to do a real bloom, you should first do a bright pass where you filter out the dark parts, then blur that and then mix it with the original image. If you are interested I could send you a non-working example project. The shaders are written and they all work seperately, but I couldn't find a way to properly use the result of the first shader in the next because if the view-entity isn't perfectly alligned to the screen the image will be offset..

Re: Cheap, Horrible Bloom [Re: Excessus] #104201
12/28/06 17:25
12/28/06 17:25
Joined: Aug 2002
Posts: 681
Massachusetts, USA
Ichiro Offline OP
User
Ichiro  Offline OP
User

Joined: Aug 2002
Posts: 681
Massachusetts, USA
This could be usefull, but wouldn't this result in a regular blur in images with more details/transitions? ... If you want to do a real bloom, you should first do a bright pass where you filter out the dark parts, then blur that and then mix it with the original image.

The pow() does a not-too-shabby job of filtering out the dark bits. The higher the exponent, the stronger the filter. But it's definitely all cheap fakery.

If you are interested I could send you a non-working example project.

Sure! :)


Dejobaan Games - Bringing you quality video games for over 75 years.
Re: Cheap, Horrible Bloom [Re: Ichiro] #104202
12/28/06 21:02
12/28/06 21:02
Joined: Apr 2004
Posts: 320
TheGameMaker Offline
Senior Member
TheGameMaker  Offline
Senior Member

Joined: Apr 2004
Posts: 320
well, I would try a array with pseudo randnom offsets.
(I´ve done it this way, and i´ve seen Rendermonkey examples doing it the same way.)

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 Offline
Senior Expert
PHeMoX  Offline
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;
}




PHeMoX, Innervision Software (c) 1995-2008

For more info visit: Innervision Software
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
E
Excessus Offline
Expert
Excessus  Offline
Expert
E

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: Excessus] #104205
12/29/06 17:14
12/29/06 17:14
Joined: Aug 2002
Posts: 681
Massachusetts, USA
Ichiro Offline OP
User
Ichiro  Offline OP
User

Joined: Aug 2002
Posts: 681
Massachusetts, USA
Not sure you where even looking for advice, but here it is anyway

I always am; I appreciate it.


Dejobaan Games - Bringing you quality video games for over 75 years.
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 Offline
Senior Expert
PHeMoX  Offline
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


PHeMoX, Innervision Software (c) 1995-2008

For more info visit: Innervision Software
Re: Cheap, Horrible Bloom [Re: PHeMoX] #104207
12/30/06 07:47
12/30/06 07:47
Joined: Aug 2002
Posts: 681
Massachusetts, USA
Ichiro Offline OP
User
Ichiro  Offline OP
User

Joined: Aug 2002
Posts: 681
Massachusetts, USA
I believe it's a 1024x768 TGA with transparency.


Dejobaan Games - Bringing you quality video games for over 75 years.
Re: Cheap, Horrible Bloom [Re: Ichiro] #104208
12/30/06 15:33
12/30/06 15:33
Joined: Sep 2002
Posts: 8,177
Netherlands
PHeMoX Offline
Senior Expert
PHeMoX  Offline
Senior Expert

Joined: Sep 2002
Posts: 8,177
Netherlands
Okey, thanks. I was mainly wondering, because to get some better speeds wouldn't it be possible to use a smaller texture, but keep the correct scale (3d locations should visually be on the same locations, like with 1024x768) and stretch the quad along the screen, add some transparency and then you've got fast but less detailed fullscreen bloom??

Cheers


PHeMoX, Innervision Software (c) 1995-2008

For more info visit: Innervision Software
Page 1 of 2 1 2

Moderated by  Blink, Hummel, Superku 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1