Home Technical Talk

Blender: Radiosity baking helper script

KDR_11k
polycounter lvl 18
Offline / Send Message
KDR_11k polycounter lvl 18
Since Blender's radiosity code is long overdue for a rewrite and still stuck in the NAN age, I've written a little script that makes it possible to bake radiosity to a texture.

The problem was that radiosity doesn't keep UV data and alters the mesh. Due to the floating point error the vertex coordinates don't stay the same. Because it adds vertices and you might have other scene elements that aren't part of your model in the radiosity scene (like, say, a light source) vertex indices won't work. I think there is a "radiosity bake" script out there that attempts to work with vertex indices but that's pretty much futile since there's no gurantee they'll stay the same after the radio pass.

This script copies the vertex colors from one mesh to the nearest vertices in another mesh. The two meshes don't need to have the same shape or number of vertices, it uses proximity to do its job.

Usage is easy, just select the source object, then the target object and run the script (don't select anything else, might get unpredictable!). The active object (a bit brighter than the rest when you select multiple objects) receives the colors, the inactive object gives. The script uses the meshdata positions so any transformations to the object get ignored. When you get weird results, try making sure the object centers match (radiosity recenters your model) by using Centre Cursor and remove any scaling/rotation by using CTRL-A.

If you haven't installed a script before, you do that by throwing the .py file into your Blender/.blender/scripts/ directory (might be located in your home directory instead of the Blender directory). In this case you need to remove the .txt extension since my host blocks hotlinking files.

There should be a proper vertex color bake-to-texture script somewhere out there, the one I use is rather messy and ineffective.

Script

Replies

Sign In or Register to comment.