The lightmapping thing

Started by
5 comments, last by TheC00L1 17 years, 10 months ago
I'm not really sure how lightmapping is exactly done. Let me get this straight: There are generated textures They have shadows and shading on them Each texture belongs to a triangle? (wouldn't there be thousands of textures?) When you load a scene you load all these textures, seperately? Each individual triangle has to be rendered with his own texture? How would draw a lightmapping for a directx mesh? What about small faces in a scene, like the corner of a table. Thanx!
A wiseman once said nothing, but no one was there to hear it.
Advertisement
Your understanding is correct, except that we don't necesserarily have to use one texture for each face. We can "pack" all the lightmaps into a big texture and have the triangle vertices use texture coordinates to index the correct texels. For example, this is a lightmap of a whole level:

Image Hosted by ImageShack.us

All the triangles of the level just use the correct texcoords to sample the correct regions of the lightmap. Of course, along with the lightmap itself, the lightmap generation tool will also have to provide the correct texture coordinates for each triangle.
Cool, so for very large levels, i would split the the triangls, and have like 2 or 3 light maps in total, 1 for each part.

Thanx.
A wiseman once said nothing, but no one was there to hear it.
Quote:Original post by TheC00L1
Cool, so for very large levels, i would split the the triangls, and have like 2 or 3 light maps in total, 1 for each part.


Yes, although most cards today can handle textures up to 4096x4096. So unless the level is really huge, or the desired detail of the lightmap is also really high, or the lightmapper itself have some limitations, just 1 texture of those dimensions should be enough. Writing a lightmapper isn't an easy task though. If you're not doing this for educational purposes, you'll be better off just using an existing lightmapper(FSRAD is a free one, and I believe most 3D modelling suites have tools for generating lightmaps for models).
Wow, 4096x4096, yeah, that's plenty, i thought, like 512 was the max.


For lightmap creation, don't you just use raytracing, and/or raycasting for radiosity?

I'm sure it's difficult, and when i was designing a raytracer, it was by no means, fast.

where is FSRAD's main site?
A wiseman once said nothing, but no one was there to hear it.
Fluid Studios Homepage

It comes with full source code. Note that FSRAD reads and writes the geometry to specific file formats, so your application has either to support them, or you'll have to edit the FSRAD source and write your own importer/exporter for your custom format. It's not that difficult, you just have to figure out some parts.

As for speed, radiosity map generation is relatively slow of course(depends on the detail you want to achieve), but it only has to be done once, so it doesn't really matter that much.
Thanks, i'll go check it out.
A wiseman once said nothing, but no one was there to hear it.

This topic is closed to new replies.

Advertisement