Sign in to follow this  
Mick is Stumped

D3DTSS_TCI_CAMERASPACEPOSITION

Recommended Posts

I found an old thread (http://www.gamedev.net/community/forums/topic.asp?topic_id=185962) about D3DTSS_TCI_CAMERASPACEPOSITION... it sounds as if it works exactly as I'd like it to, but I'm not getting ideal results.

Basically I'm trying to backport a graphics framework to some legacy targets... D3D9 with only pixel shaders, D3D9 with no shaders, and D3D7.

I want to implement dithering because it's not supported by any modern hardware drivers (I've found)

Have dither working splendid under ps_3_0 via the vpos semantic. So I'm trying first to map D3DTSS_TCI_CAMERASPACEPOSITION to a pixel shader without a vertex shader bound.

What I get definitely looks dithered. So I'm assuming something is working. However while moving around very strange patterns appear here and there... often circular and checkered. The checkers come from not a 1:1 mapping with the dither texture point filtered. The circular warping I've no clue.

What I'd like is just each vertex to have a second texture coord generated which maps directly to screen space somehow. That sounds anyway exactly what this function is for, but it's just not what I'm seeing unfortunately.

Thanks,

Share this post


Link to post
Share on other sites
PS:

Setup looks like this.

SetTextureStageState(g,D3DTSS_TEXCOORDINDEX,D3DTSS_TCI_CAMERASPACEPOSITION);
SetTextureStageState(g,D3DTSS_TEXTURETRANSFORMFLAGS,D3DTTFF_COUNT2);
SetTextureStageState(g,D3DTSS_COLOROP,D3DTOP_SELECTARG1);
SetTextureStageState(g,D3DTSS_COLORARG1,D3DTA_TEXTURE);
SetTextureStageState(g,D3DTSS_ALPHAOP,D3DTOP_SELECTARG1);
SetTextureStageState(g,D3DTSS_ALPHAARG1,D3DTA_TEXTURE);
SetSamplerState(g,D3DSAMP_ADDRESSU,D3DTADDRESS_WRAP);
SetSamplerState(g,D3DSAMP_ADDRESSV,D3DTADDRESS_WRAP);
SetSamplerState(g,D3DSAMP_MAGFILTER,D3DTEXF_POINT);
SetSamplerState(g,D3DSAMP_MINFILTER,D3DTEXF_POINT);

Probably where I'm dumbfounded is I don't know what coordinates to actually expect in the shader. The docs usually say stuff like "clipping space" "camera space" etc, but never explicitly define that... not in the same place anyway.

Sans pshader the texture matrix will be a must, but just trying to get it working this way first.

Thanks again (anyone)

Share this post


Link to post
Share on other sites
With a little intuition I was able to stabilize things with...

float2 vpos = (In.uv1.xy/In.uv1.z*0.5f+0.5f)*dimViewport;

Changed D3DTTFF_COUNT2 to D3DTTFF_COUNT3 because the docs say D3DTTFF_PROJECTED is only honored by ps_1_x and the colours I was getting running some test patterns did not appear perspective corrected.

Still however the dither pattern does not appear ideal. It looks a little grainy/maybe stretched.


[Edited by - Mick is Stumped on November 13, 2010 3:19:37 AM]

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