SV_POSITION and deferred shading

Started by
-1 comments, last by KaiserJohan 9 years, 9 months ago

So I'm trying deferred shading in DirectX11.

I am using the following method (used in the FXAA shader and described here:http://www.altdev.co/2011/08/08/interesting-vertex-shader-trick/) to render a fullscreen triangle for my deferred shading pass.


FullscreenTriangleVSOut main(uint VertexID: SV_VertexID)
{
FullscreenTriangleVSOut output;

output.mTexcoord = float2((VertexID << 1) & 2, VertexID & 2);
output.mPosition = float4(output.mTexcoord * float2(2.0f, -2.0f) + float2(-1.0f, 1.0f), 0.0f, 1.0f);

return output;
}

And then in the pixel shader, I want a proper texture coordinate to sample my diffuse, normal, position textures from the GBuffer.

In GLSL, I simply do:


ivec2 texcoord = ivec2(textureSize(unifDiffuseTexture) * (gl_FragCoord.xy / UnifAmbientPass.mScreenSize));

But for some reason, in HLSL my SV_POSITION is always (0.5, 0.5), regardless of pixel. I looked in visual studio 2013 and debugged the pixel shader at various pixels, and yes at all places the SV_POSITION is (0.5, 0.5). Why is this?

This topic is closed to new replies.

Advertisement