D3DXMATRIXA16 matPostProjRescale;
D3DXMATRIXA16 translation, scaling;
D3DXMatrixIdentity(&matPostProjRescale);
D3DXMatrixIdentity(&translation);
D3DXMatrixIdentity(&scaling);
D3DXMatrixTranslation(&translation, 1.0f + 1.0f / 512.0f, -1.0f - 1.0f / 512.0f, 0.0f);
D3DXMatrixScaling(&scaling, 0.5f, -0.5f, 1.0f);
D3DXMatrixMultiply(&matPostProjRescale,&translation,&scaling);
anyone tried this way of getting screen space texcoords before?
if u do, do you get extremely accurate results or also have slight distortions...
then again, I might as well get an X1K card and use VPOS instead. And I hope ATI supports VPOS...
phew!
Edwin
screen space texcoord from vertex position [HLSL]
ok i was trying to see how accurate this can be done using tex2Dproj.
first, i looked at two sources:
ShaderTech link
Deferred Shading demo
I tried the sample code from the second source, but couldnt get it work though.
What happened was that i could get screen space texcoords with a slight distortion, about 2-3 pixels being offsetted along the x axis.
What I did was to render a quad with screen space coords. And then a second pass tries to uses tex2Dproj to lookup the earlier texture to see the lookup was done correctly or not. I use a modified DX texture tool to read back the pixel values (like Image Debugger) to check if the 2nd pass was performing the lookup accurately. Unfortunately, it didnt. :(
Quote:Original post by edwinnieI've not tried the way you're talking about, but I'd personally choose to implement the viewport matrix in a shader and pass the values across to the pixel shader.
anyone tried this way of getting screen space texcoords before?
(from this page)
The regular output of a vertex shader should be in projection space, and the above matrix can remap it to screenspace. You just need to output a float2 from the vertex shader as a TEXCOORD[n] that you can read into the pixel shader.
Quote:Original post by edwinnieUnlike when ATI cheated their way around vertex texturing, I don't see any way that they can't support VPOS [smile]
I might as well get an X1K card and use VPOS instead. And I hope ATI supports VPOS...
hth
Jack
After you have applied this matrix there is a final step to get screen coordinates. X,Y and Z need to be divided by W. If you are sure that W is always 1 you don’t need to do this.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement