Lightmap and VARs

Started by
6 comments, last by The_Fallen 21 years, 11 months ago
Hi, I''m drawing my scene using Vertex Array Range (NV extension). But I just implemented lightmaps (there is another thread) and there is another prob: With lightmaps every single polygon has got his own texture (the lightmap of course). So what''s the best way to draw it now? Do I have to draw every polygon alone to be able to switch the lightmap texture between two polygons? That would be awful! No other way? thx, fallen
Advertisement
quote:
No other way?

Sure: cluster lots of small lightmaps into a big texture. Access the individual lightmaps though customized texcoords. That way, you don''t have to switch textures very often, and you can group lots of lightmapped faces into a single DrawRangeElements() call.

/ Yann
Yeah, thx, I already had this idea, but there is one problem: I''m loading the textures more or less "on the fly". I''m using an octree and only the textures of the current visible nodes are loaded.
Hmm, perhaps I could create one huge lightmap for every node in the octree... That would be an idea, so there would be one more texture switch per node.
Any better ideas?
>>Any better ideas?<<

not really as Yann saiz, u will need to do what most apps that use lightmaps (quake2/3 UT etc) + group all all the lightmaps in to a few texture IIRC q3a uses 6 lm textures per level or 128x128 size (remember lm textures are usually much lower quality than the decal textures)



http://uk.geocities.com/sloppyturds/gotterdammerung.html
I think you shud use the GL_ARB_Multitexture Extension to solve you simple but complicated problem, im writing a Quake3 BSP Map Loader, and im using VARs and LightMaps easily with this extension.

check out the OpenGL Extension Repository at
http://developer.nvidia.com/

plus this might give you some ideas
http://www.gametutorials.com/

and search Google (www.google.com -- just in case)!


Hope that helped..

..:: SiLv3r.MaC3 ::..
Yes, of course I wanna use the GL_ARB_Multitexture extension, or is there another (perhaps faster way) of multitexturing?
But there is another problem: With the lightmap I''ve got one new pair of texture coordinates. My text coords for the normal textures are cached like this:
glTexCoordPointer(2, GL_FLOAT, sizeof(CVertexArray), &vaScene->u);
But what to do with the second pair of coords? I could store them in the array, too, but then I would have problems drawing the scene with glDrawElements, wouldn''t I? Do I have to use glArrayElement to draw every single vertex and set the correct lightmap uv-coords? Or can i include them within my glTexCoordPointer call?
You can store them in your vertex array with everything else. There is theoretically no limit on the number of texcoord channels you can interleave into a VA.

To access them, do the following:

// texcoords for unit 0
glTexCoordPointer(2, GL_FLOAT, sizeof(CVertexArray), &vaScene->u0);

// texcoords for unit 1
glClientActiveTextureARB(GL_TEXTURE1_ARB);
glTexCoordPointer(2, GL_FLOAT, sizeof(CVertexArray), &vaScene->u1);
glClientActiveTextureARB(GL_TEXTURE0_ARB);

// more units can follow here...

// Draw the scene
glDrawElements(...blahblah...);

/ Yann

Thx! :D That is, what I was looking for! =)

This topic is closed to new replies.

Advertisement