View Single Post
Old 26th May 2010, 05:28 PM   #20
lisa
Senior Member
Professional user
 
lisa's Avatar
 
Join Date: Mar 2005
Location: Phoenix, AZ
Posts: 917
Default Re: PLUGIN: Render to Texture: Light Maps, Normal Maps, AO

Quote:
Originally Posted by lordfly View Post
Hmm; I suppose that's where I'm having the issue. Correct me if I'm wrong, but doesn't "proper texturing" include having the same textures going over multiple surfaces? For instance, say I have a tree made with multiple branches; they are all made of the same material (in this case, bark). Rather than having each surface have a unique texture (and thus eat gobs of memory), aren't you supposed to share pixels between surfaces to cut down on texture memory? Obviously this doesn't apply if you're doing static renders, but I'm pretty sure you have to do that for game rendering.
Not so. Most games that use lightmaps use two sets of UV coordinates, one for the diffuse map and one for the lightmap. These are combined at runtime using either a multitexturing shader or multipass if all you have is a fixed function renderer. e.g. GL_ARB_multitexture if you're writing something using OpenGL or SetTextureStageState if you're using DirectX. The render-to-texture plugin will allow you to bake both together in case your engine doesn't support multi-texturing, but that's not the normal way it's done. These are normally different maps.

The first set of texture coordinates is for the diffuse map, and is as you describe: overlapping as much as possible to use texture space as efficiently as possible.

The second set of texture coordinates is specific to the lightmap. It's a unique atlas, and the lightmaps are *extremely* low-resolution. It's not uncommon to pack an entire scene onto a single 1024 lightmap, or small 32x32 or 64x64 textures for individual objects. Shadows are normally a little blurry anyway, so the maps can be pretty tiny and still look great. This keeps this method pretty efficient even though it uses more UV space.

AC3D only supports a single set of texture coordinates for a model so if you're building models for a game, you'll want to create two versions of the model file and combine them in your export utility. [Multi-coordinates is definitely on my wish list :-) ] If you're fixed function, keep them as separate models and arrange it as a second pass. e.g. Render the first model as usual, then render the second model with alpha blending and a tiny z-buffer offset to blend the shadows in.
lisa is offline   Reply With Quote