   HLSL major problem (win coord)
  HIHI!ok i dun have access to an NVidia 6800 so i got no vpos.i tried to render a cuboid(8 vertices), with a vertex shader, and pass the calculated window screen coords to the fragment shader via the texcoord. If the camera did not move, the calculations are accurate, but if the camera moves abit, the calculations become unaccurate.i am SURE someone of us have been through this problem, so please share how u do it... THX!//Vertex program//window dimensions: (512,512)//g_Display.viewport.z == g_Display.viewport.w == 256VertexOut_V4T4 SceneAABBIntersectVP(VertexIn_V3 IN){    VertexOut_V4T4 OUT;    OUT.position = mul(half4(IN.position,1.0f), g_WorldViewProjection);    half3 oneOverW = OUT.position.xyz / OUT.position.w;    half3 pDivide = oneOverW / oneOverW.z;    half2 screen = half2(g_Display.viewport.z * (1 + pDivide.x), g_Display.viewport.w * (1 + pDivide.y));    OUT.texcoord0 = screen;    return OUT;}THX!Edwinz   
  if you mul the incoming world position of the vector with the worldviewprojection matrix, you already get the point in screen-space coordinates. You don't have to mul a 4, just do:Out.position = mul( In.position.xyz, g_WorldViewProjection );now, Out.position is in screen coordinates.Quote:ok i dun have access to an NVidia 6800 so i got no vpos.what do you mean by this?   ;Quote:Original post by Wicked Ewokif you mul the incoming world position of the vector with the worldviewprojection matrix, you already get the point in screen-space coordinates. You don't have to mul a 4, just do:Out.position = mul( In.position.xyz, g_WorldViewProjection );now, Out.position is in screen coordinates.That's not quite it.  He's trying to perform the viewport transform in the shader so he can pass the pixel position on to the PShader in a texcoord.  (He's not multiplying by 4 either; half4 is a type.)Quote:Original post by Wicked EwokQuote:ok i dun have access to an NVidia 6800 so i got no vpos.what do you mean by this?The 6800 supports PS3.0, which supports the VPOS register/semantic to get the pixel location.As for the code, what exactly is 'unaccurate?'  Slight discrpancies, or way off?  You're using halfs which, depending on the hardware, may or may not signify lower precision.  Plus, I don't think you can really expect it to be 100% accurate; you're dealing with positions of vertices in 3d space, which won't map to round numbers.  You can try using ints instead (it'll likely cost more).   ;Quote:That's not quite it.  He's trying to perform the viewport transform in the shader so he can pass the pixel position on to the PShader in a texcoord.  (He's not multiplying by 4 either; half4 is a type.)ah, ok, I see what he's trying to do now. Not sure on the implementation though.when I said mul a 4, I meant mul a 4 type, not 'by' 4 to the world matrix, a 3 type would work, i.e. vector.xyz instead of vector.xyzw;  HIHI!thx fer replying!eg my actual coord i hit in the debugger is (89,338) but the interpolated values are like (81.xxx,343.xxx).Such inaccuracies actually arise when i move my camera around.so it could be damn way off if i move around alot.i also changed all to floats and changed the render texture to 128bit, still having this inaccuracy...THX!Edwinz[Edited by - edwinnie on July 16, 2004 2:01:14 AM];  what's the default camera view transform? I see why you use a half4 now btw.Here's a formula I use to transform from worldspace to screen coordinates( mouse coords? )vPos = mul( vPos, worldviewprojectionmat );vScreen.x = ( vPos.x/vPos.w + 1 )*windowwidth/2;vScreen.y = ( vPos.y/vPos.w + 1 )*windowheight/2;maybe it'll help, I don't know   