how to get a sharp 2D in 3D world
I am trying to use a 2D sprite in 3D.
If I set the sampler state to D3DTEXF_NONE, it's sharp,
but after zooming in to twice size, i can see jaggy edges.
If I set it to D3DTEXF_LINEAR, the scaling is acceptable,
but it's blurred even without scaling.
The original picture size, the texture size and the projected
size on the window are all the same.
How should I config it to get a sharp display with fine scaling?
I know that windows xp uses D3D as the renderer to play movies,
so there must be some way.
You didn't say if you were using ID3DXSprite or if you've developed your own sprite renderer.
The D3DX code should handle it fine, but if you rolled your own then you need to get the texture coordinates correct - see the "Directly Mapping Texels To Pixels" document in the SDK [smile]
hth
Jack
[Edited by - jollyjeffers on April 23, 2006 4:40:39 PM]
The D3DX code should handle it fine, but if you rolled your own then you need to get the texture coordinates correct - see the "Directly Mapping Texels To Pixels" document in the SDK [smile]
hth
Jack
[Edited by - jollyjeffers on April 23, 2006 4:40:39 PM]
I'm not using any D3DX code.
I implemented the 2D function according to online samples like this:
http://www.andypike.com/tutorials/directx8/011.asp
And the matrix is right.
From the document you mentioned, do you mean that I should change the
texture coordinate of the triangle strip vertexes?
I can't find any sample of "2D in 3D" considering that.
I implemented the 2D function according to online samples like this:
http://www.andypike.com/tutorials/directx8/011.asp
And the matrix is right.
From the document you mentioned, do you mean that I should change the
texture coordinate of the triangle strip vertexes?
I can't find any sample of "2D in 3D" considering that.
I just had a quick glance through that tutorial...
I'm not sure about this part:Unless the height/width is even then you're going to get it rasterizing to 1/2 pixel locations. Even then I'm not 100% sure whether the exact coordinate going into this vertex will be the exact 2D coordinate coming out post-projection. You can check this fairly easy with a screenshot though.
And this part definitely doesn't follow what I originally posted:Changing this as per my original post might well yield the results you desire. Read this thread for a bit more discussion...
Cheers,
Jack
I'm not sure about this part:
//Set the positions of the vertices pVertices[0].x = -(m_nWidth) / 2.0f; pVertices[0].y = -(m_nHeight) / 2.0f; pVertices[1].x = -(m_nWidth) / 2.0f; pVertices[1].y = m_nHeight / 2.0f; pVertices[2].x = (m_nWidth) / 2.0f; pVertices[2].y = -(m_nHeight) / 2.0f; pVertices[3].x = (m_nWidth) / 2.0f; pVertices[3].y = m_nHeight / 2.0f;
And this part definitely doesn't follow what I originally posted:
//Set the texture coordinates of the vertices pVertices[0].u = 0.0f; pVertices[0].v = 1.0f; pVertices[1].u = 0.0f; pVertices[1].v = 0.0f; pVertices[2].u = 1.0f; pVertices[2].v = 1.0f; pVertices[3].u = 1.0f; pVertices[3].v = 0.0f;
Cheers,
Jack
So amazing that it works after offseting half a texel!
Thanks jollyjeffers!
MS should put that article in a more obvious place of DXSDK, I think.
Thanks jollyjeffers!
MS should put that article in a more obvious place of DXSDK, I think.
Good to hear you got it sorted.
Cheers,
Jack
Quote:Original post by raytracer03[lol] Well its become a bit of a running joke with anyone who answers forums/newsgroups questions on a regular basis. If the DirectX MVP's got a £/$/€ for every time we mentioned that article we'd all be millionaires!!
MS should put that article in a more obvious place of DXSDK, I think.
Cheers,
Jack
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement