@monogany wrote:
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(); } }
Calling code:
edgeDetect.CurrentTechnique = edgeDetect.Techniques["EdgeDetect"]; spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Opaque); edgeDetect.CurrentTechnique.Passes[0].Apply(); spriteBatch.Draw(EdgeDetectSceneRenderTarget, Vector2.Zero, Color.White); spriteBatch.End();
Posts: 2
Participants: 1