Archived

This topic is now archived and is closed to further replies.

Renus

Index Buffer: sharing of tex coords still possible?

Recommended Posts

Renus    122
Assume you would like to render a simple cube with different textures at each of its 6 faces. AN index buffer approach would be fine since it reduces the vertex data by factor 3. The VB format would be something like XYZ | TEX1. But this way I have to share the tex coord for each vertex - thats not what I want since one vertex has different tex coords for the three textures. I just found two ways to go, both with huge disadvantages: 1) dont use IB, just have the data in VB. This way I have to specify each vertex three times for the three different tex coords. What a waste! Surely not the way to go. 2) Use a Vertex Shader which defines that the vertex data comes from a first VB of format XYZ and that the tex coords data comes from a second VB of format TEX1. Now I can index them - but not independantly, so again I have to pass much more data than necessary. Do you know a better way? DX-Demo&3D code and docu avoid touching it, hopefully not for good reasons. Thank you for any help! - thomas

Share this post


Link to post
Share on other sites
Phobia    122
You could have one vertex for each corner of every face of the cube. You still have to use more vertices, but 24 is better than 32, assuming your using triangles to render the cube.

Share this post


Link to post
Share on other sites
ferceg    122
I have the same problem...
When (several years ago) I wrote a software engine, I had an
array for vertices containing the x,y,z coordinates
and some more info (transformed/not trasformed),
and a separate face (triangle) list. (A B C - index to vertices,
Av, Au, Bv, Bu,.... texture coords; they were ''instances'' of a vertex)
Recently I''ve started to study this d3d ''thing''.
I''d like to use a similar technique and I''d be unhappy to
duplicate vertices...

ferceg

Share this post


Link to post
Share on other sites
Renus    122
Ferceq,

I "solved" the problem meanwhile by using just one VB for each fvf without IB who in each frame gets the visible pos+tex data.
This way hardware TnL can be used and my efforts focused on getting the "visible" data from system memo and pass it to the VB (sorting by fvfs, within sorting by texture to reduce SetTexture() calls, within the VB data). This approach has still the backdraw of passing much more data than needed to describe the scene, but TnL does it fast (if I had a TnL card and I can manage the memory in parallel. Also, since I fill the VB dynamically, I have more influence on things like LOD (have 2 or 3 VB data sets for objects/tree leafs or whatever) or early culling (have VB data sets for noth/south/west/east view and pass just the two visible sides).

I still am interested in solutions that allow me to used IB and hence reduce the vid driver data flood while allowing TnL.


- thomas

Share this post


Link to post
Share on other sites