Lightmapping pipeline proposal

Hey all,

I didn’t want to resurrect a dead thread (see [url]Advanced lighting? Shaders?]) so I started a new one.

I’ve been thinking more about lightmaps on instanced geometry and stumbled across this answer by David:

I’ve been thinking about a pipleine which will apply a lightmap over, say, a city - made up of hundreds of the same building model. Normally you wouldn’t be able to lightmap a scene like this as each building would need a unique second UV set. However, could you possibly construct your city in Panda, export it to your favorite lightmapping program, get the lightmap and save it to a slimmed down egg which contains only UV information, then walk both hierarchies and copy UV information across?

I’m interested in this approach because I believe it could keep distribution size down (less data because of more instancing) and load time down (minus the time it takes to copy the UV stream across at runtime). I also like the idea because it means I don’t have to export an entire city from my modelling program if I want to make a change - I just change only the one asset.

Does this make sense? Would loader.loadModel() work on an egg with just a UV stream and no other data?

I’m not sure how that would work in practice. You can’t store just uv information in an egg file, and even if you could, there’s not a one-to-one correspondence between the vertices appearing in an egg file and the vertices of the final model (the egg loader sometimes has to replicate vertices to satisfy the egg’s demands, and it can also sometimes combine redundant vertices for efficiency, or completely skip over unused vertices). So there wouldn’t be a way to match up the uv information in your second egg file with the corresponding vertices loaded from the first egg file.

I’m sure you could solve this problem, but the solution wouldn’t involve egg files. You’d probably have to write a custom model loader to load your models from the format of your own devising.


Thanks for the insight, David! I’ll look into the method you’ve described. :slight_smile: