I've started experimenting with full-screen post-processing after using a tutorial on Ramblings of A Hazy Mind (tutorial number 8 I believe), that lets you modify many things using pixel shaders, unfortunately I'm unable to find good examples of post-processing effects that will work with this implementation. I'm not really looking for a different way of doing this, rather I'd like to port an effect I've had trouble with into something that will work with Hazy Mind's system. The main one I've had a problem with is a Blur/Glow effect that I found on the XNA5D site, unfortunately it also implements a vertex shader which I have no knowledge of (I know very little about pixel shaders also) so I don't know how to get it to work without involving 3D models, here is the code (probably going to have some smiley faces or something). For those who don't know, Hazy Mind's post-processing system only uses pixel shaders (as far as I know). Also, if anyone has any effects they've made for this type of thing I'd love to see them, thanks!
const float2 offsets[12] = {
-0.326212, -0.405805,
-0.840144, -0.073580,
-0.695914, 0.457137,
-0.203345, 0.620716,
0.962340, -0.194983,
0.473434, -0.480026,
0.519456, 0.767022,
0.185461, -0.893124,
0.507431, 0.064425,
0.896420, 0.412458,
-0.321940, -0.932615,
-0.791559, -0.597705,
};
float BlurScale;
Texture UserTexture;
sampler SamplerState = sampler_state
{
texture = <UserTexture>;
magfilter = POINT;
minfilter = POINT;
mipfilter = POINT;
AddressU = clamp;
AddressV = clamp;
};
struct VertexToPixel
{
float4 Position : POSITION;
float2 TexCoord0 : TEXCOORD0;
};
VertexToPixel SimpleVertexShader( float4 inPos : POSITION, float2 tex0 : TEXCOORD0)
{
VertexToPixel Output = (VertexToPixel)0;
Output.Position = inPos;
Output.TexCoord0 = tex0;
return Output;
}
float4 ApplyBlur(VertexToPixel inp) : COLOR
{
float4 sum = tex2D(SamplerState, inp.TexCoord0);
float4 Gold = float4(255, 178, 0, 0);
for(int i = 0; i < 12; i++)
{
sum += tex2D(SamplerState, inp.TexCoord0 + BlurScale * offsets);
}
sum /= 13;
sum.a = 1.0f;
return sum;
}
float4 ApplyBlurMore(VertexToPixel inp) : COLOR
{
float4 sum = tex2D(SamplerState, inp.TexCoord0);
float4 Gold = float4(255, 178, 0, 0);
for(int i = 0; i < 12; i++)
{
sum += tex2D(SamplerState, inp.TexCoord0 + (2*BlurScale) * offsets);
}
sum /= 13;
sum.a = 0.5f;
return sum;
}
float4 ApplyBlurMed(VertexToPixel inp) : COLOR
{
float4 sum = tex2D(SamplerState, inp.TexCoord0);
float4 Gold = float4(255, 178, 0, 0);
for(int i = 0; i < 12; i++)
{
sum += tex2D(SamplerState, inp.TexCoord0 + (1.5*BlurScale) * offsets);
}
sum /= 13;
sum.a = 0.8f;
return sum;
}
float4 ApplyTexture(VertexToPixel inp) : COLOR
{
float4 TextureColor = tex2D(SamplerState, inp.TexCoord0);
TextureColor.a = 1.0f;
return TextureColor;
}
technique Blur
{
pass P0
{
VertexShader = compile vs_2_0 SimpleVertexShader();
PixelShader = compile ps_2_0 ApplyBlur();
}
pass P1
{
VertexShader = compile vs_2_0 SimpleVertexShader();
PixelShader = compile ps_2_0 ApplyBlurMed();
}
pass P2
{
VertexShader = compile vs_2_0 SimpleVertexShader();
PixelShader = compile ps_2_0 ApplyBlurMore();
}
pass P3
{
VertexShader = compile vs_2_0 SimpleVertexShader();
PixelShader = compile ps_2_0 ApplyTexture();
}
}