2 registered members (AndrewAMD, alibaba),
1,426
guests, and 9
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: pp bloom in gamestudio
[Re: frazzle]
#169225
11/24/07 22:54
11/24/07 22:54
|
Joined: Mar 2006
Posts: 3,538 WA, Australia
JibbSmart
Expert
|
Expert
Joined: Mar 2006
Posts: 3,538
WA, Australia
|
just one (two-part) question:
why are the horizontal and vertical blurs done separately? wouldn't it be faster to use one less view and do them together?
julz
Formerly known as JulzMighty. I made KarBOOM!
|
|
|
Re: pp bloom in gamestudio
[Re: JibbSmart]
#169226
11/24/07 23:39
11/24/07 23:39
|
Joined: Jan 2007
Posts: 1,619 Germany
Scorpion
OP
Serious User
|
OP
Serious User
Joined: Jan 2007
Posts: 1,619
Germany
|
no, it uses a lot less texture lookups...it's a little loss in quality, but a big benefit in speed.here is a nice site about it: http://www.blackpawn.com/texts/blur/default.htmland i did a shader, that does it all in one pass, but the quality is worse. But this way you can use it in A6, too. Code:
float4x4 matWorldViewProj; float4 vecSkill1; float4 vecSkill5;
texture entSkin1;
sampler2D colorMap = sampler_state{Texture=<entSkin1>;};
void bloomVS( in float4 pos :POSITION, in float2 tex :TEXCOORD0, out float4 oPos :POSITION, out float2 oTex :TEXCOORD0) { oPos=mul(pos,matWorldViewProj); oTex=tex; }
float4 isBlack(uniform float4 lookup) { if((lookup.r+lookup.g+lookup.b)/3>vecSkill1.x) { return lookup; } else { return 0; } }
float4 bloomPS( in float2 texcrd :TEXCOORD0):COLOR { float4 Color = tex2D(colorMap,texcrd); float4 Blurred = isBlack(Color); Blurred += isBlack(tex2D(colorMap,texcrd+vecSkill1.y)); Blurred += isBlack(tex2D(colorMap,texcrd-vecSkill1.y)); Blurred += isBlack(tex2D(colorMap,texcrd+vecSkill1.y*2)); Blurred += isBlack(tex2D(colorMap,texcrd-vecSkill1.y*2)); //here you could add 4 more texlookups for the other "side" => looks better,worse performance /*float2 tempCrd; tempCrd.x = vecSkill1.y; tempCrd.y = -vecSkill1.y; Blurred += isBlack(tex2D(colorMap,texcrd+tempCrd)); tempCrd.x = -vecSkill1.y; tempCrd.y = vecSkill1.y; Blurred += isBlack(tex2D(colorMap,texcrd-tempCrd)); tempCrd.x = vecSkill1.y*2; tempCrd.y = -vecSkill1.y*2; Blurred += isBlack(tex2D(colorMap,texcrd+tempCrd)); tempCrd.x = -vecSkill1.y*2; tempCrd.y = vecSkill1.y*2; Blurred += isBlack(tex2D(colorMap,texcrd-tempCrd));*/ //here you can add as much texlookups as you want... Blurred/=5; Color += vecSkill1.z*Blurred; Color=lerp(Color,(Color.r+Color.g+Color.b)/3,vecSkill5.x)*vecSkill1.w; Color.w = 1; return Color;// }
technique bloom { pass p0 { vertexShader = compile vs_1_0 bloomVS(); pixelShader = compile ps_2_0 bloomPS(); } }
Have fun!
|
|
|
Re: pp bloom in gamestudio
[Re: Scorpion]
#169227
11/25/07 02:43
11/25/07 02:43
|
Joined: Jun 2004
Posts: 655 to your left
BoH_Havoc
User
|
User
Joined: Jun 2004
Posts: 655
to your left
|
Quote:
why are the horizontal and vertical blurs done separately? wouldn't it be faster to use one less view and do them together?
First it would be kinda slow as Scorpion already mentioned. Second you would get a "star-shaped" bloom effect and not a "circular" one as you aren't able to use the blurred scene again in the same pass and blur it again horizontally/vertically
Oh and btw you can do this in A6, but you have to use some workarounds. As you aren't able to use stages as in A7 beta, you have to render PPEed scene to a plane, put a view in front of that plane, render the plane through the view and use this rendertarget in the next step. It works, but you also get some kind of "bloom-motionblur" effect, as you need 3 frames to compute the whole bloom thing (brightpass,hblur,vblur+combine)... sooo.... go for A7
|
|
|
Re: pp bloom in gamestudio
[Re: JibbSmart]
#169229
11/25/07 13:43
11/25/07 13:43
|
Joined: Jan 2004
Posts: 2,013 The Netherlands
Excessus
Expert
|
Expert
Joined: Jan 2004
Posts: 2,013
The Netherlands
|
Quote:
if((Color.r+Color.g+Color.b)/3<vecSkill1.x) { Color.rgb = 0; }
I think you will get a better quality bloom if you just calculate the luminance instead of making dark parts black. You can calculate luminance like this: float lum = dot(color, float3(0.299f, 0.587f, 0.114f); return (float3)lum;
Then just blur it and blend with the original render like you already do.
|
|
|
|