C# XNA Combining texture shaders
I'm having a lot of difficulty with this problem and was hoping someone
could help.
I'm making a glow shader, I have everything in place I just don't know how
to save the output of the glow shader to a texture so I can pass it into
my combine shader and place it ontop of the rendered scene.
Currently this is what I have:
(Draws the scene and sets up he render target)
//Passes the scene texture into the glow shader to blur it
// I don't know how to take the output of the code below and turn it into
a texture
GraphicsDevice.SetRenderTarget(finalGlowRenderTarget);
GraphicsDevice.Clear(new Color(0, 0, 0, 0));
sceneTexture = (Texture2D)sceneRenderTarget;
for (int l = 0; l <
resourceLoader.GlowShader.CurrentTechnique.Passes.Count; l++)
{
resourceLoader.GlowShader.Parameters["sceneTexture"].SetValue(sceneTexture);
resourceLoader.GlowShader.CurrentTechnique.Passes[l].Apply();
}
//I currently have this, but it's not working, I just get a blank black
texture
GraphicsDevice.SetRenderTarget(null);
finalGlowTexture = finalGlowRenderTarget;
GraphicsDevice.Clear(new Color(0, 0, 0, 0));
//Draws everything
for (int l = 0; l <
resourceLoader.GlowCombineShader.CurrentTechnique.Passes.Count;
l++)
{
resourceLoader.GlowCombineShader.Parameters["sceneTexture"].SetValue(renderTargetTexture);
resourceLoader.GlowCombineShader.Parameters["glowTexture"].SetValue(finalGlowTexture);
resourceLoader.GlowCombineShader.CurrentTechnique.Passes[l].Apply();
}
//Applies everything to the fullscreen quad
renderQuad.Render();
No comments:
Post a Comment