View Single Post
Old 19th August 2008, 02:52 PM   #9
lisa
Senior Member
Professional user
 
lisa's Avatar
 
Join Date: Mar 2005
Location: Phoenix, AZ
Posts: 917
Default Re: PLUGIN: Bake Texture Layout

Ooh. That's a big one, and I've got a lot on my plate already. I'm still working on a new sculpty exporter and a lightmapper. The lightmapper turned out to be a little more work than I thought, mostly because I decided I wanted global illumination. I'd like to get at least one of those out the door before I start any more personal side projects.

It's also a little hard to justify, since you can hook up the command-line ATI tool to AC3D's render button if you want an integrated normal mapper. Press F7, choose ATI Graphics NMF as the output format and ATI's NormalMapper as the render program. Click "Show Render button on toolbar". Add any parameters as desired to the render parameters. Click Ok. Now when you click the render button, AC3D will render normal maps.

*But* if someone wants to take a crack at it, I will happily provide whatever guidance I can help with.

For any budding game developers out there, this is a good one to cut your teeth on because you'll walk away not only with knowing how to make normal maps, but with all the building blocks needed for basic collision detection as well. Here's how I'd implement it if I were writing it myself:

1) Position the high resolution model and the low resolution model at the same location based on the user-set model centers. This can happen in-memory, it doesn't have to be visible in AC3D.

2) Create a scan-line triangle renderer to walk each texel in uv space of the destination normal map. (low-res model)

3) For each texel of the normal map, project a ray [*see item #4] from the surface of the low-resolution model both inward and outward and determine the intersection point, if any, with the high resolution model. The distance from the ray origin to the intersection is the displacement value. The surface normal direction at the ray intersection of the high resolution model is the normal vector to write to the texture.

4) Write a geometry management system to make it fast. (This is the time-consuming part of the project!) Normal maps are only interesting for models with thousands or millions of polys. If you try to do ray casting without a geometry management system it will be waaaay too slow to be practical... we're talking days to trace anything, not kidding. Something like a BSP, KD-tree, sphere tree or any one of a dozen other structures will do the trick, but you will *need* to implement one of these.

5) Convert the recorded displacement and normal values from floating point to a 0-1 range, and write them to the normal and displacement texture maps. Note: You won't be able to determine the 0-1 range for the displacement map until you know the max and min displacements. (You'll want to write those values out to a text file.) Save textures to disk.
lisa is offline   Reply With Quote