D3DTSS_TCI_CAMERASPACEPOSITION

Started by
1 comment, last by Mick is Stumped 13 years, 5 months ago
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,
Advertisement
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)
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]

This topic is closed to new replies.

Advertisement