• Advertisement
Sign in to follow this  

SV_POSITION and deferred shading

This topic is 1270 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement