Sign in to follow this  
Funkymunky

cg syntax WPOS

Recommended Posts

I'm looking through some CG code and in the fragment function parameters list I see "float4 position : WPOS" and "float4 normOff : TEX1" What are these two, WPOS and TEX1? I would think TEX1 to be texcoords but it is a float4 and isn't "TEXUNIT1" and I can't figure out at all what WPOS could be

Share this post


Link to post
Share on other sites
Hello,

WPOS can be used as a binding semantic and returns the coordinates of the pixel in 2D window coordinates i.e as an integer between 0 and the size of the window in pixel units. This is with the fp30 profile. The first two values are the 2D window coordinates, and the rest are useless (they're always 0, if my memory's right).

As for the TEX1, I don't know...

Hope I've been able to help,
Jeroen

Share this post


Link to post
Share on other sites
Quote:
oh. and can I use WPOS in HLSL? I'm still confused, it returns the vertex position orthogonally?


In HLSL it's VPOS, an input semantic only available to ps3.0 and above. It doesn't give vertex position, because it's only available in the pixel shader.

Share this post


Link to post
Share on other sites
WPOS = (x, y, z, 1/w)

This stands for "window position". The x and y coordinates give the window position of the current fragment, but will not be integers because they are set to the center of the fragment, which is offset by (0.5, 0.5). The z coordinate is your depth in the range [0, 1]. 1/w is the reciprocal of the w coordinate after multiplying by the MVP matrix.

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