I'm working on a shader but it has a weird tint to it and I'm not sure why. Right now it's extremely simple, it just sets a rendertarget, draws to it, passes it as a texture to the shader then oututs the pixels to a fullscreen quad. If I remove the rendertarget/texture part and just directly pass it into the shader it comes out properly, but once I start including rendertargets the colors get a little weird.
Here are two images showing what I mean:
This is how it should look normally
This is how it looks with the rendertargets I've included the code for the shader and the draw method below:
Shader:
float4x4 World;
float4x4 View;
float4x4 Projection;
Texture glowTexture;
sampler glowSampler = sampler_state
{
texture = <glowTexture>;
magfilter = LINEAR;
minfilter = LINEAR;
mipfilter = LINEAR;
AddressU = clamp;
AddressV = clamp;
};
struct VertexShaderInput
{
float4 Position : POSITION0;
};
struct VertexShaderOutput
{
float4 Position : POSITION0;
};
VertexShaderOutput VSOutline(VertexShaderInput input)
{
VertexShaderOutput output;
output.Position = input.Position;
return output;
}
float4 PSOutline(VertexShaderOutput input, float2 pixel:VPOS) : COLOR0
{
float2 uvPixel = (pixel + 0.5) * float2(1.0 / 1280, 1.0 / 770);
float4 finalColor = tex2D(glowSampler, uvPixel);
return finalColor;
}
technique Outline
{
pass Pass1
{
AlphaBlendEnable = TRUE;
DestBlend = INVSRCALPHA;
SrcBlend = SRCALPHA;
VertexShader = compile vs_3_0 VSOutline();
PixelShader = compile ps_3_0 PSOutline();
}
}
Draw method:
GraphicsDevice.SetRenderTarget(renderTarget);
GraphicsDevice.Clear(Color.Black);
scene.RenderGrid();
playerList.Render();
scene.RenderObjects();
GraphicsDevice.SetRenderTarget(null);
renderTargetTexture = (Texture2D)renderTarget;
for (int l = 0; l < resourceLoader.GlowShader.CurrentTechnique.Passes.Count; l++)
{
resourceLoader.GlowShader.Parameters["glowTexture"].SetValue(renderTargetTexture);
resourceLoader.GlowShader.CurrentTechnique.Passes[l].Apply();
renderQuad.Render();
}