Untransformed Vertex w/o Normals
Hi everyone,
I''ve been playing around with drawprimitives lately (was using exe buffers) and I''ve tried to set up a flexible vertex format,
this:
struct {
float x,y,z;
long color;
float lightu;
float lightv;
float tu;
float tv;
};
My flags for it are:
D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX2
I use this vertex to render a lightmap texture, and a texture.
I get some very strange results. When I render with only one texture stage, everything looks correct. When I render with two texture stages, my texture coordinates on the second stage are
destroyed.
I played around a little bit. I discovered that if I included a vertex normal in the format, everything rendered okay (and everything slowed down a bit, since now the normal had to be transformed).
So, I postulate that this is happening: When the DrawPrimitive call happens, DirectX goes ahead and transforms the vertices... and then it ALSO transforms the normals, which I have not specified (since I do my own lighting) right OVER my second set of texture coordinates.
I DO specify DONOTLIGHT on the drawprimitive call. I didn''t see a define for DONOTTRANSFORMNORMALS.
So can anyone help me? Is this a bug, or is there a flag I need to also set, somewhere?
My drawprimtive call itself is this:
DrawPrimitive(
D3DPT_TRIANGLESTRIP,
D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX2,
&vertexlist[0],
4,
D3DDP_DONOTLIGHT|D3DDP_DONOTUPDATEEXTENTS
);
(Note, please that the forum changes OR pipes into division symbols).
-- Goodlife
-----------------------------
Those whom the gods would destroy, they first drive mad.
--DirectX design team official motto
A strange error you get there. Have you tried disabling D3D Lighting? Note that with DX7 you disable lighting with SetRenderState(D3DRENDERSTATE_LIGHTING, FALSE), also the flags you send to DrawPrimitive() are no longer supported. Read about it in the remarks for DrawPrimitive() in the SDK Docs.
If D3D were transforming the normal even though it is not within the vertex structure it would destroy your diffuse color, not the texture coordinates, because the normal always comes directly after the vertex coordinate.
Another thing that you might be missing is that you must tell D3D to use the second set of texture coordinates for the second texture stage, otherwise it will use the first ones. You do this with SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 1).
That''s it for me, for now.
- WitchLord
If D3D were transforming the normal even though it is not within the vertex structure it would destroy your diffuse color, not the texture coordinates, because the normal always comes directly after the vertex coordinate.
Another thing that you might be missing is that you must tell D3D to use the second set of texture coordinates for the second texture stage, otherwise it will use the first ones. You do this with SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 1).
That''s it for me, for now.
- WitchLord
Hi Witchlord,
I never did solve this, but decided that the the speed loss was negligible.
Here''s what happened:
It destroyed my diffuse lighting, and the first texture coordinate after it, which corresponds, I guess, with three normals.
I just tried turing off D3D lighting with the render state, but it did the same thing, so I guess that wasn''t it either. Oh well, another DirectX anti-innovation bug.... sigh...
-- Goodlife
-----------------------------
Those whom the gods would destroy, they first drive mad.
--DirectX design team official motto
I never did solve this, but decided that the the speed loss was negligible.
Here''s what happened:
It destroyed my diffuse lighting, and the first texture coordinate after it, which corresponds, I guess, with three normals.
I just tried turing off D3D lighting with the render state, but it did the same thing, so I guess that wasn''t it either. Oh well, another DirectX anti-innovation bug.... sigh...
-- Goodlife
-----------------------------
Those whom the gods would destroy, they first drive mad.
--DirectX design team official motto
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement