PDA

View Full Version : massive state-switching



HamsterofDeath
12-18-2003, 12:12 AM
during the development of my 3d-engine, i came to a point where i need to look for help again :

the 3d-world of the game is a planet where you can walk around (the geometry is really a sphere, not just repeating landscape)

(all from now on is theory)
my problem is the texturing : every vertex has its normal, position, texcoord, used textures, and the blending-factors of its textures, so if a draw a quad or triangle of the planet, up to 3 textures are blended together, using linear interpolation between the polygon's vertexes/verticles/whatever (what is the plural of vertex ?)

this gives two results :

the good part :
smooth texture-changes -> looks pretty good

the bad one :
a lot of texture binds -> for every polygon, another texture may need to be bound to a texture unit, which is, as far as i know, slowing down the rendering performance.

so the question is : how to sort them ? build strips, ignore the bindings, or ignore the strips, and minimize the bindings ?

AdrianD
12-18-2003, 02:22 AM
the plural of "vertex" is "vertices".
texture binds are most time-consuming, so try to minimize them. use strips when you can, but sometimes indexed arrays with vbos are fast enough.

daveperman
12-18-2003, 04:19 AM
Originally posted by AdrianD:
the plural of "vertex" is "vertices".

does it really mather?




[This message has been edited by daveperman (edited 12-18-2003).]

Csiki
12-18-2003, 05:38 AM
Originally posted by daveperman:
does it really mather?

Yes, davaparman. http://www.opengl.org/discussion_boards/ubb/smile.gif


[This message has been edited by Csiki (edited 12-18-2003).]

HamsterofDeath
12-18-2003, 06:37 AM
vbos ...hm..
vertex array object doesn't match
what do you mean ?
---
i thought a while about what to optimize, and i think that this should be a good solution :
find all triangles that use the same textures. they can be executed with binding the textures once.
in this triangles, look for strips to
minimize the amount of vertices.

to go on, it looks like i need a tutorial.
the only rendering methods i've used so far are glBegin, display lists, and simple vertex arrays (one array for normals, one for texcoords etc)

i read about indexed vertex arrays to save memory, vertex array objects to load the vertex-data into the graphic cards memory and today, i've encountered the "interleaved vertex array", which was quite simple to understand.

as far as i know, the vertex array object is the fastest method. does it have any disadvantages ? can the vertices still be modified in this array ?
can these arrays be treated like any other vertex array, for example can you use indexed vertex array objects or indexed interleaved vertex arrays objects ?
if yes, how ?

this is important because i need the possibility to move my vertices around (to create waves etc.)

in terms of speed, the fillrate will be much more important, since i'm going to use
pass 1:
-> 3 texture units for blending
-> 1 for storing the blending factors
detail textures to the 3 textures already -> drawn
-> 1 unit for lighting (i can't use lighting on the first 4 units because of the blending stuff)
-> 1 more for shadows casted by clouds (although i don't know how to realize this yet. ideas ? the shadow doesn't need to be 100% accurate)

pass 2 (only near triangles) :
-> 3 for applying smoothly blended detail textures, matching to the 3 already rendered

i may need 3 passes for old cards, or even more for even older ones.