I'm alittle confused on how to separate the glow areas. And I seem to get strange artifacts. What I've been doing is in the first pass for the render to texture on my character I've taking the diffuse and multiply it with a texture leaving on the glow areas. Step 2 This texture is then pass to a glow shader and then to a screenquad. Only problem is If I take the diffuse and multiply with the glow texture on what glows will be rendered the rest of the diffuse texture will be black.
Up close
Camera moves further away.
Not sure how to make it stick with the object.
Code: Select all
float viewWidth;
float viewHeight;
struct VS_INPUT
{
float4 Position : POSITION0;
float2 Texcoord : TEXCOORD0;
};
struct VS_OUTPUT
{
float4 Position : POSITION0;
float2 Texcoord : TEXCOORD0;
};
VS_OUTPUT vs_main( VS_INPUT Input )
{
VS_OUTPUT Output;
Output.Position = float4(Input.Position.xy, 0,1) ;
Output.Texcoord.x = 0.5 * (1 + Input.Position.x - viewWidth);
Output.Texcoord.y = 0.5 * (1 - Input.Position.y - viewHeight);
return( Output );
}
sampler Texture0;
float BlurScale;
float4 color;
float glow;
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,
};
float4 ps_main(float2 Texcoord : TEXCOORD0) : COLOR0
{
float4 sum = tex2D(Texture0, Texcoord);
for (int i = 0; i < 12; i++){
sum += tex2D(Texture0, Texcoord + BlurScale * offsets[i]) /8;
}
return (sum * glow ) + color * sum;
}