Advertisement

Lightmapping Question

Started by February 27, 2000 04:36 PM
2 comments, last by ThaUnknownProgga 24 years, 6 months ago
I was planning on implementing a system of lightmaps in my engine, but I was wondering something before I get really deep into the process. What I was planning to do with texturing is group every triangle together that uses the same texture so i could make that one call to IDirect3DDevice3::SetTexture and then make my DrawPrimitive call for those triangles. But if each triangle is going to have it''s own lightmap, what would be the point? It seems like no two triangles will ever have the same texture and I will therefore have to make a SetTexture call and a DrawPrimitive call for every single triangle!!! Is that the right way I should be doing this, or is there an easier/faster way?
You should try to bunch triangles together so that they can use the same lightmap texture. They can still be individually lighted. A planar polygon is an ideal example of triangles that should use the same lightmap. Even triangles that are not in the same plane can use the same lightmap, but that is going to take more thinking on your part to make that work.

An example of a lightmap shared by two triangles:
+------------+/ +----+     // /   /    + // /  /    // // / /    / / // //    /  / // +    /   / //     +----+ //            /+------------+


The triangles use different parts of the lightmap, but are individually lighted.
Advertisement
So then I should blend in real time, and not pre-blend the texture and lightmap? Then the only triangles I can bunch together are those that have the same lightmap and the same texture. I guess that still gives me the bunching of every two triangles. Is that right?
I don''t think preblending texture and lightmap would be a feasible option as it would require a huge amount of texturememory.

The only triangles that can be bunched together are the ones that use the same textures and lightmaps, yes. But if you design your lightmaps visely you can use the same map for many triangles.

Triangles that don''t have the same texture can still use the same lightmap, it should still give you a speed enhancement as only one lightmap has to be uploaded to the card.

You can also have a two level group. In the first grouplevel you gather all triangles that have the same texture, in the second you divide this group into those who use the same lightmaps. This would require two pass rendering of course, but if done carefully it should give an improved speed over separate multitextured triangles. (Remember that it is mostly only the older cards that have faster multitexturing than multipass singletexturing. The only advantage of multitexturing today is that vertices don''t have to be sent twice, and even that advantage is diminished by the increasing popularity of onboard GPUs (geForce, Savage2000 and future products))

At the very least you should put every planar polygon in a group, as most walls are made up of at least two triangles.

This topic is closed to new replies.

Advertisement