VPOS, WPOS - are they in there?

Unity 3.3.0 update claims, that VPOS is in there. Still, I always get

Program 'vert', *** exception during compilation *** at line 735

error when I use it.

And same for WPOS.

(I’m using pragma target 3.0)

As method
described here (http://www.gamerendering.com/2009/12/07/vpos/) is not working for me to get screen pixel coordinates, and in fragment shader this is not working either (I guesss it is valid for surface sahder only):

half2 screenuv = IN.screenPos.xy / IN.screenPos.w;

I feel kinda of stuck

Well, i’m not a shader expert, but i guess your example you’ve linked works only in Microsoft’s HLSL. Cg is quite similar but not the same. Take a look at cg(wikipedia).

I think VPOS is not a valid semantic in cg, but maybe someone else know a bit more about that.

There is even a include file (HLSLSupport.cginc) in the unity data directory for HLSL support. It just defines VPOS as WPOS :D. Since you said that WPOS doesn’t work either i guess that include won’t help much.

Just had a look into the “UnityCG.cginc” and there is a function ComputeScreenPos that looks like it’s what you need. I use a quite old version of Unity (3.0) so there can be changes in 3.3+

Hmmm, ComputeScreenPos might be helpfull, thanks a lot for the suggestion. Will try looking into it

ComputeScreenPos is not working as expected, with I can see texture project on the plane, but in distorted way. Something is missing, still, I feel I’m almost there. I’ll try now comparing ComputeScreenPos to script in there http://www.gamerendering.com/2009/12/07/vpos/, maybe that will triger something in my head.

Got it!

if we are using

o.projPos = ComputeScreenPos (o.pos);

in vertex shader, we need also write this line ie pixel shader:

i.projPos /= i.projPos.w;

And here we are