I have a pixel shader and I want to calculate the position of each pixel in terms of my world space coordinates. How would I do this? What would I need?
I have a ps_input
structure which has a float4 position : SV_POSITION
. I'm assuming this is important, but the values stored inside seems to be kind of funny.
I can't seem to figure out what they relate to. For instance, if a pixel is 2d, how come it has a w component, or a z component for that matter?
I'm using DirectX
and the pixel shader is in HLSL
. C++
as my programing language on the CPU.
Any help would be appreciated.