Hey all,
I'm working on a system for my 2D engine to add some image post processing. Basically I'm following the pretty standard procedure of rendering the scene to a texture then using a shader to modify that texture.
I've hit a little snag though and I'm not quite sure what the solution is.
I render the scene to the texture, loop through the scene processing shader, apply the effects and draw the quad. But I have to draw this quad at the end of every shader pass, which ends up overlapping the one previous to it. So really the only post-processing effect I see is the one last applied.
I thought about just enabling some sort of blending mode to merge the two images, but I'm not sure if that's the
correct solution to the problem, as I'm new to shaders AND render surfaces (heh).
Here's the shader technique:
technique TestTechnique
{
pass P0
{
VertexShader = NULL;
PixelShader = compile ps_2_0 TestPS();
}
pass P1
{
VertexShader = NULL;
PixelShader = compile ps_2_0 TestPSGreyscale();
}
}
Here's the render surface rendering:
_device.Clear(Direct3D.ClearFlags.Target, Color.Black, 1.0f, 0);
_device.BeginScene();
_effect.Technique = "TestTechnique";
_effect.SetValue("WorldViewProj", worldViewProj);
_effect.SetValue("Time", (float)Kernel.Instance.Time.TotalTime);
int numPasses = _effect.Begin(0);
for (int pass = 0; pass < numPasses; pass++)
{
_effect.BeginPass(pass);
_device.SetTexture(0, _renderTexture);
_graphics.DrawRectangle(new Point(0, 0), Kernel.Instance.Window.ClientSize);
_graphics.Flush();
_effect.EndPass();
}
_effect.End();
_device.EndScene();
_device.Present();
So what's the deal? Is blending the way to go or have I done something wrong?
Thanks for your help.
(_graphics is my own class for rendering sprites and such)
[Edited by - GroZZleR on August 8, 2005 1:26:30 PM]