Archived

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

RZ

Lightmaps and glDrawElements..

Recommended Posts

Hi I sort all my polygons by textures before I render them so that I only need to switch textures as many times as the number of textures I have. Then I call glDrawElements() and draw all polys with the same texures at once. This has been working really good…until now. I have implemented lightmaps in my engine and now I really don’t know how to do the rendering part now.. Many lightmaps will be unique so Ill have to switch lightmap almost every polygon.. Do I have to go back to calling glBegin(GL_TRIANGLES)? I really dont want that.. Should I sort the polys by lightmaps first and then by textures maybe?… and then draw every polygon with the same lightmap and texure with a call to glDrawElements() maybe this will take too much time..i dont know.. Thanks for any suggestion on how to solve this… Edited by - RZ on August 12, 2001 3:04:11 PM

Share this post


Link to post
Share on other sites
most games stick a lot of the lightmaps in one texture eg quake3 i believe uses about 6 textures for all the lightmaps in a level. search for packing lightmaps into textures (or something similar)

Share this post


Link to post
Share on other sites
OK, this sounds exactly like a problem I faced when I first implemented lightmaps. To make it easier on myself, I used multitexturing, and had one lightmap texture per facee. This means you can set the base texture in the first texture, and the lightmap in the second, and just change the lightmap while drawing the polygons that use each texture, this reduces texture switching. Each polygon is done with a call to glDrawElements() but my polygons can have any number of sides, as long as they are convex, so I send a triangle strip, by no means is it done with GL_TRIANGLES

Packing lightmaps is a very good idea, haven''t got round to it yet though so I can''t help, but basic lightmap packing shouldn''t be too difficult.

Also check out texture arrays, I haven''t played around with them either, so I can''t help you there, but I think they offer quite a speed gain.

The problem with a lot of this comes when you start with a visibility system, the triangles you have to draw changes as the viewing position does, so you have to quickly sort by textures and lightmaps etc... which becomes much more of a challenge.


FatalXC

Share this post


Link to post
Share on other sites
Thanks for the suggestions
The thing is that I am using a visibility system.. right now I have an octree structure that I use for frustum culling and collision detection…
To build the octree I need all my polygons to be triangles and also the collision detection routine only works with triangles.

I haven’t found any information about “packing lightmaps”... so if someone have a link or tell me where to look ill be glad if u let me know

I have been trying to sort the textures and lightmaps so that I can use multitexture and glDrawElements() but the way I’m doing it is way to slow and many times I end up with a polygon with a unique lightmap and drawing one triangle using glDrawElements() cant be good!?

I think it would be faster to just sort polygon by texture and then using multitexture draw every triangle with Begin(GL_TRIANGLES) ..but I really like vertex arrays and glDrawElements()

Share this post


Link to post
Share on other sites
Wouldn''t it be possible to put all textures into one huge texture and change the UV koordinates to fit? I know that would kill the Voodoo compatibility, but those won''t be around too long anymore anyway soo...

cya,
Phil

Visit Rarebyte!
and no!, there are NO kangaroos in Austria (I got this questions a few times over in the states

Share this post


Link to post
Share on other sites