Skip to main content
GameDev.net gamedev.net
🔒 Locked

Can I do this?

Started by d000hg Aug 4, 2002 at 7:23 AM 4 replies 200+ views
Original Post
d000hg
d000hg
I''m changing my terrain engine to use index buffers, since every point on the map is used by 6 triangles (apart from the edges). One problem I have is it doesn''t work above a certain number of polys in scene, but that''s not the point here. The thing is, while the same vertex is used by many triangles, the texture coords at that vertex are NOT identical for each triangle. I want to know If I can put the colour and position information in one vertex struct that is used with an index buffer, and just the texture coords in a second vertex struct that is used without indexing. i.e
struct VERT
{
float x,y,z;
DWORD Diffuse;
};

struct TEXCOORD
{
float u,v;
};

VertexBuffer1=Lots of VERTs
VertexBuffer2=Lots of TEXCOORDS
IndexBuffer=Lots of indices

SetStreamSource(0,VertexBuffer1);
SetIndices(0,IndexBuffer);
SetStreamSource(1,VertexBuffer2);
 
If I do this, how do I tell the texture stages which Vertex buffer to get texture coords from (My texture is on stage 1, not stage 0 if that matters) Thanks
Read about my game, project #1 NEW (31st July): There is a new demo, demo #2 at my site. Please try it out.
John 3:16
VolkerG
VolkerG
No, you can''t do this. In D3D (and OpenGL, too) the texture coordinates belong to the vertices. There is always a 1:1 mapping between the elements of the vertex streams.
d000hg
d000hg
Why would you ever want more than one stream then?



Read about my game, project #1
NEW (31st July): There is a new demo, demo #2 at my site. Please try it out.


John 3:16
Sheep
Sheep
Good question d000hg. I use 2 streams for keyframing so I can tween the 2 vertex buffers together, but I am sure there are other uses for multiple stream sources.
tok_junior
tok_junior
The streams are for vertex shaders, where you can use it for example blending of vertices or whatever you feel like. It''s also used for drawing patches.
The reason you can''t throw different texcoords at the same vertex lies somewhere in the hardware, but i haven''t really gotten an answer to why yet Just split the vertices when you initialize them, it doesn''t really strain the hardware (usually).


--
MFC is sorta like the swedish police... It''''s full of crap, and nothing can communicate with anything else.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.