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

Where to store Matrix index and other info in vertex ?

Started by Zaph-0 Dec 14, 2009 at 11:04 AM 1 replies 900+ views
Original Post
Zaph-0
Zaph-0
Hi, I am trying to render a complex object consisting out of several subobjects (each with its own set of vertices) with 1 rendercall and am wondering how I should handle the animation (and therefore different matrices) of the subobjects. I think I will give every subject its own transformation matrix that I set before rendertime and index which one to use from the vertexdata. I considered using D3DFVF_XYZB1 for that but using a whole float for a simple index seems kind of wasteful. Especially considering that I might want to give other data along as well (materialtype for the supershader, etc...) and do not want a vertex to be bigger that 32byte so I considered using the RGBA 4byte encoded specular or diffuse color instead. I could put which matrix to use for each subobject into the R part (have to multiply it with 256 since it ranges from 0 to 1, though) and maybe the materialtype, lights, etc. into the other GBA parts. Is that acceptable, will this maybe cause huge performance loss or did I miss something completely ? Thanks for any advice on this. ^_^
Adam_42
Adam_42
I'd suggest not using an FVF at all. Use a vertex declaration. You can then use D3DDECLTYPE_UBYTE4. See:

http://msdn.microsoft.com/en-us/library/ee421778%28VS.85%29.aspx

http://msdn.microsoft.com/en-us/library/ee416463%28VS.85%29.aspx
Zaph-0
Zaph-0
Thanks, that is exactly what I was looking for.

^_^

Topic Locked

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

Sign in to reply to this topic.