Sign in to follow this  

HLSL and pixel coordinates

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this