using transformed data

Started by
16 comments, last by iota1410 19 years, 5 months ago
I need to use data that I receive which comes in in screen space (i.e. x=100, y=150 not x = -1.0, y = 2.0). But I want to use it in the following format so that it works with my vertex shader. Since this data is already tranformed int screen space, how can I get it to work. struct CUSTOMVERTEX { FLOAT x, y, z; // The transformed, 3D position for the vertex }; #define VERTEX (D3DFVF_XYZ) D3DFVF_XYZRHW does not work due to the need of my vertex shader. D3DDECLUSAGE_POSITIONT does not allow multiple streams, which I need for my application. Using the data as is, it does not show up on the screen. Please help. [Edited by - iota1410 on November 11, 2004 10:05:09 AM]
Advertisement
In the shader it is your responsibility to transform the data. If it is already in screen space simply don't transform it, that is don't multiply it by the projection and view mats.
You'd have to transform the coords into homogenous clip space since that's what the shader outputs. The projection is applied after the vertex shader.
How would I transform the coords into homogenous clip space?
Sorry, I was a little unclear. I didn't mean it is projected, rather the viewport transform is applied. You can find all the information in the SDK, under Viewports and Clipping I believe.
I am folloing the sample you suggested and i receive an error:
Direct3D9: (ERROR) :Viewport outside the render target surface

I use the following code:


D3DVIEWPORT9 viewData = { 0, 0, 640, 480, 0.0f, 1.0f };
HRESULT hr;
hr = g_pd3dDevice->SetViewport(&viewData);
if(FAILED(hr))
return hr;

What am I missing? I call this during my init calls.


[Edited by - iota1410 on November 11, 2004 7:17:26 AM]
Quote:Original post by turnpast
In the shader it is your responsibility to transform the data. If it is already in screen space simply don't transform it, that is don't multiply it by the projection and view mats.


I followed your advice, but with no result. My shader basically just passes the information through, yet still nothing shows up on the screen.

[Edited by - iota1410 on November 11, 2004 10:45:29 AM]
Any help here would be greatly appreciated. If I am asking wrong, or what I want is not possable, please let me know. Im theory what I ask seems very simple. I just want to be able to present my data to the screen. I receive my data in screen space coordinates. I do not want to use the XYZRHW format due to shader limitations, so how can I present the picture.

If any code snippets will help please let me know.
I think you must tranform your coordinates to the zone (-1, -1)-(1,1) and not output them in the rect (0,0)-(640,480).
How can I convert from screen coordinates to untransformed coordinates? (640,480) = (1,-1)
or am I looking at this complety wrong.

[Edited by - iota1410 on November 11, 2004 2:20:50 PM]

This topic is closed to new replies.

Advertisement