Advertisement Jump to content
Sign in to follow this  

HLSL and pixel coordinates

This topic is 4881 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

Thank you for your answer but I haven't managed to make it works like that.
First, I must confess that I do Cg but HLSL and Cg are very close.
Here is my answer:

float4 main(in float4 color : COLOR,
in float4 fragpos : WPOS)

fragpos has the good coordinates.

I don't know if it works with HLSL (I'm curious to know) but if you want to use a texture interpolator, you will need to compute the complete projection in the vertex shader not only transform the vertex by modelviewproj.


Share this post

Link to post
Share on other sites
With SM3 you can use the VPOS register for the pixel shader and it will be filled with the screen position of the pixel.

Older shader models do not have this and you'll have to pass it in from the vertex shader as mentioned above.

Share this post

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

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!