1 registered members (AndrewAMD),
1,089
guests, and 2
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: 23 Post Processing Shaders for A6 Com/Pro
[Re: Slin]
#109920
04/07/07 13:59
04/07/07 13:59
|
Joined: Sep 2002
Posts: 8,177 Netherlands
PHeMoX
Senior Expert
|
Senior Expert
Joined: Sep 2002
Posts: 8,177
Netherlands
|
Quote:
Color = tex2D( postTex, Tex.xy); // the entire screen get's rendered at it's normal position once Color += tex2D( postTex, Tex.xy+0.001); // the entire screen get's rendered again, but this time it's moved a little bit, which causes a blur if done 2 or 3 or more times. Color += tex2D( postTex, Tex.xy+0.003); Color += tex2D( postTex, Tex.xy+0.005); Color = Color / 3.5; // as you can count, the entire screen get's rendered 4 times, if you divide it to 4, colors will be normal. However if you divide it through less than 4, the multiplication of colors will be visible. Which causes the "some sort of bloom" effect.
If you don't want a blur at all, do as Slin suggests. However because you may want a tiny blur for a more 'bloom-like' result and because it gives a nice 'anti-aliasing' too, you could play with the values 0.001 , 0.003 and 0.005.
Code:
texture postTex1;
sampler postTex = sampler_state { texture = (postTex1); MinFilter = linear; MagFilter = linear; MipFilter = linear; AddressU = Clamp; AddressV = Clamp; };
float4 MyShader( float2 Tex : TEXCOORD0 ) : COLOR0 {
float4 Color;Color = tex2D( g_samSrcColor, Tex.xy); Color += tex2D( g_samSrcColor, Tex.xy+0.001); Color += tex2D( g_samSrcColor, Tex.xy+0.0011); Color += tex2D( g_samSrcColor, Tex.xy+0.0012); Color = Color / 2.5; return Color; }
technique PostProcess { pass p1 { VertexShader = null; PixelShader = compile ps_2_0 MyShader(); } }
This one for example has less blur, but higher overexposured 'gloominess'. The lower the 0.001 to 0.005 values, the less blur, it's the amount the entire screen get's shifted and rendered on top of the other rendered screens.
Cheers
|
|
|
Re: 23 Post Processing Shaders for A6 Com/Pro
[Re: PHeMoX]
#109921
04/07/07 14:24
04/07/07 14:24
|
Joined: Jan 2004
Posts: 2,013 The Netherlands
Excessus
Expert
|
Expert
Joined: Jan 2004
Posts: 2,013
The Netherlands
|
Code:
texture postTex1;
sampler postTex = sampler_state { texture = (postTex1); MinFilter = linear; MagFilter = linear; MipFilter = linear; AddressU = Clamp; AddressV = Clamp; };
float4 MyShader( float2 Tex : TEXCOORD0 ) : COLOR0 { float4 Color; Color = tex2D( postTex, Tex.xy); Color += tex2D( postTex, Tex.xy+0.001); Color += tex2D( postTex, Tex.xy+0.003); Color += tex2D( postTex, Tex.xy+0.005); Color = Color / 3.5; return Color; }
technique PostProcess { pass p1 { VertexShader = null; PixelShader = compile ps_2_0 MyShader(); } }
To put it simple: that is not a bloom shader. A bloom shader should filter out the bright parts of the image, blur them and blend them back with the original scene. This just fetches 4 colors: the original pixel, and 3 pixels downright of it (moving away farther for each). Then it averages the color. It's just some weird kind of blur filter..
|
|
|
Re: 23 Post Processing Shaders for A6 Com/Pro
[Re: PHeMoX]
#109924
04/07/07 15:15
04/07/07 15:15
|
Joined: Nov 2003
Posts: 1,659 San Francisco
JetpackMonkey
Serious User
|
Serious User
Joined: Nov 2003
Posts: 1,659
San Francisco
|
Thanks Phemox & Slin, Both of those are a lot closer to what I am looking for. Slin, about using the Sylex Bloom-- I'm not sure why, but it just renders a black screen-- maybe I need Pro to use it? By the way, I;d also really like that ATI tone mapping shader for something else, it's beautiful-- but too dark and saturated for my project.. would you mind helping brighten it up and reducing the saturation? Code:
texture postTex1; texture postTex2;
sampler originalImageSampler = sampler_state { texture = (postTex1); MinFilter = linear; MagFilter = linear; MipFilter = linear; AddressU = Clamp; AddressV = Clamp; };
sampler blurImageSampler = sampler_state { texture = (postTex2); MinFilter = linear; MagFilter = linear; MipFilter = linear; AddressU = Clamp; AddressV = Clamp; };
float4 main(float2 tc: TEXCOORD0) : COLOR{ float fExposureLevel= 3.0f; // FROM 2 float4 original = tex2D(originalImageSampler, tc); float4 blur = tex2D(blurImageSampler, tc); float4 color = lerp(original, blur, 0.3f); tc -= 0.5f; // Put coordsin -1/2 to 1/2 range // Square of distance from origin (center of screen) float vignette = 1 -dot(tc, tc); // Multiply by vignette to the fourth color = color * vignette*vignette*vignette*vignette;//*vignette; color *= fExposureLevel; // Apply simple exposure level return pow(color, 1.95f); // Apply gamma and return FROM 1.95 }
// Just one pass: technique PostProcess { pass p1 { VertexShader = null; PixelShader = compile ps_2_0 main(); } }
Thanks again!
|
|
|
Re: 23 Post Processing Shaders for A6 Com/Pro
[Re: JetpackMonkey]
#109925
04/07/07 20:37
04/07/07 20:37
|
Joined: May 2005
Posts: 2,713 Lübeck
Slin
Expert
|
Expert
Joined: May 2005
Posts: 2,713
Lübeck
|
For the Sylex Bloom, just call this from a function:
SLX3ViewRegister(20,"camera");//Register Camera
SLX3ViewSetPostProcessingEffect(20,0,SLX3_PPE_4XDOWNSAMPLE); SLX3ViewSetPostProcessingEffect(20,1,SLX3_PPE_BRIGHTPASS); SLX3ViewSetPostProcessingEffect(20,2,SLX3_PPE_HBLOOM); SLX3ViewSetPostProcessingEffect(20,3,SLX3_PPE_VBLOOM); SLX3ViewSetPostProcessingEffect(20,4,SLX3_PPE_COMBINE); SLX3ViewSetPostProcessingEffect(20,5,0); SLX3ViewSetPostProcessing(20,1);//activate Postprocessing for the view with ID 20
SLX3EffectSetValue(SLX3_PPE_HBLOOM,0,2);//2 is the horizontal bloom strenght SLX3EffectSetValue(SLX3_PPE_VBLOOM,0,2);//2 is the vertical bloom strenght
Slin
|
|
|
Re: 23 Post Processing Shaders for A6 Com/Pro
[Re: Excessus]
#109927
04/08/07 22:58
04/08/07 22:58
|
Joined: Sep 2002
Posts: 8,177 Netherlands
PHeMoX
Senior Expert
|
Senior Expert
Joined: Sep 2002
Posts: 8,177
Netherlands
|
Quote:
Yes I'll do that after my exams. I already have something lying around. The shader code is complete, but it requires you to render onto a view entity which I couldn't get aligned with the screen correctly.. Maybe I'll try it with a dll that renders it to a screen aligned quad. If you want I can send this to you.
That would be awesome! Please understand that my shader knowledge is quite limited eventhough I have experience with HLSL. The quad aligning might have to do with the x value of the view entity ... I'd definately like to take a look at it if it's possible, thanks in advance.
Cheers
|
|
|
Re: 23 Post Processing Shaders for A6 Com/Pro
[Re: PHeMoX]
#109928
04/11/07 11:49
04/11/07 11:49
|
Joined: Jun 2004
Posts: 655 to your left
BoH_Havoc
OP
User
|
OP
User
Joined: Jun 2004
Posts: 655
to your left
|
just wanted to tell you guys that my provider finally set up my dsl line. => I can finally continue working on that shaders as i needed some ressources from teh_interwebz. Hope to show you some results soon
|
|
|
|