Jump to content

Illumination Baking


Recommended Posts

I've been playing around with texture baking this past week or so. So far I've had mixed results. You can play too if you want. :D I'm going to start rambling now about different things concerning baking and how I did it. So skip to the very end to see what's in the file. The best way to figure it all out is to look through the attached file. :P

Attached is a sample file with some illumination baking. Illumination baking is rendering out texture map with all the light's, texture maps, and procedural textures all baked into one map. As long as your lights/geometry don't move then you can just apply a texture map to your baked out object. (Constant illumination model.) And render away much faster. Baking is useful for buildings and background objects. It can be used for moving objects too but you need to render out a baked texture map for each frame. Baking is also useful for things like occlusion culling and normal maps. That way instead of having to use view dependent shaders (NDC shaders) you can just bake the info into a texture map.

The main drawbacks with texture baking, (or the draw backs that I have experienced), are UV Mapping. Your objects need to have well defined UV coordinates, that don't overlap. NURBS and Bezier objects handle baking pretty well if you texture using "Rows and Columns". But polygons and the like are troublesome because you can end up with seams like in this thread. Seams can be avoided but as all you texturers know, its tedious.

Another drawback is the way P is handled in VEX. Even though the Docs say P is writable for shading puposes...its NOT. So instead of doing "P = Pref;" at the begining of the shader you have to use Pref the whole way through. Which is a pain because a lot of the default VOPs use the global P. (Diffuse, Specular, computenormal, all come to mind). So this means that your going to have to roll your own illumination loops. Which isn't really hard, its just time consuming. In the example I attached I have a VOP network that does a Lambert shading model.

So to get this baking stuff to work, I make sure the "to-be-baked" geometry has good UVs. Then I make a copy and add two point attributes. Nref and Pref. Which are copies of N and P. Then I flatten out the geometry. When I shade I use Pref and Nref as my P and N. So now the calculations are happening on my phantom referenced geometry but the color values being store on my flatten plane. Snazzy.

One of the things that kept giving me trouble in the begining is the fact that Houdini's UI is a right handed coordinate system, but when it renders its a left handed one. (RHS Z points toward you, in LHS Z points away.) So I had to mirror the reference geometry across the XY plane. If I didn't all my lights would be rendered mirrored across the XY plane. Another problem I was/still having is with shadows. Right now Z-Depth shadows work fine. But the raytraced ones in the baked texture are off from the non baked. I'll fiddle with this some more when I get done my Occlusion culling samples. :ph34r:

In the file there are 2 cameras. One is a scene cam, the other renders out the Flatten Plane (UV Map). There are three Torus_* objects. The Torus_Baker is the object that get flattened out. The Torus_Regular is a torus with VEX_Mountain applied to it. It also has a Lambert shader appiled. (Actually it is the baking shader but if Pref isn't bound then the shader uses P). The Torus_Baked is the same as the previous torus but it has a different shader applied to it. The shader is just a texture map applied to a constant diffuse.

To see everything in action just go to ROPS.

1 - Render the Depth Map

2 - Render the Torus_Baker

3- Render the Torus_Regular

4- Render the Torus_Baked

You should get 2 pics in your image viewer. The second image is the baked texture, it should look like the first. (Although it never looks just like it, its normally pretty close.) I'm still working on making it match up as close as possible. I've found that making the geo more dense helps...but isn't the best solution.

anyway...have fun

jim.

[i'll proof read this tomorrow <_<]

Side note.... anybody know where I can get some Red Bull in Toronto? It appears that it hasn't been approved up here yet because of its Taurine content. :angry: But I've heard from people that its at some of the Chinese malls. Any ideas? Caffeine.... :wub:

Baking.zip

Link to comment
Share on other sites

  • 6 years later...

Hi, there i notice your post is quite old *2003*... so i'm shooting in the wind here by sending out a reply.

I'm having some texture baking issues and was thinking you might have some clues as to where the problems are coming from. i've started a WIPs that can be found here. My baked textures don't seem to be working out too well. I'm using the "UV Object and UV Attribute" extra Mantra ROP parameters... I also read on the odwiki about uvunwrapping. However, it seems like i'm getting shadows in the wrong areas of my baked textures maps. And some of the textures look horrid! It looks as though the lighting is totally wrong. If you could possibly think of any ideas where i could be going wrong, i would greatly appreciate your help!

Thanks,

Jonathan

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...