I am working with a migrated project from XNA, and one of the shaders is no longer working. It looks like the texcoords to the pixel shader always sample the same pixel, resulting in screen-sized output of just one color.
Effect/shader code (edited):
sampler SceneSampler : register(s0);
float4 PixelShaderFunction(float2 texCoord : TEXCOORD0) : COLOR0
{
return float4(texCoord.x, texCoord.y, 1, 1); // test shows constant color
// Look up the original color from the main scene.
float3 scene = tex2D(SceneSampler, texCoord).xyz;
return float4(scene, 1); // always the same color
}
// Compile the pixel shader for doing edge detection.
technique EdgeDetect
{
pass P0
{
PixelShader = compile ps_4_0_level_9_3 PixelShaderFunction();
}
}
I am doing some render target swaps also, before and after this code. But I have verified that the texture/render target called EdgeDetectSceneRenderTarget contains actual image data.
I think I have a similar problem on some of my other shaders, which don’t use SpriteBatch. They also output a single color (black). I am looking into it now.