Bake Lighting to Textures with Mantra

   5654   6   1
User Avatar
Member
6 posts
Joined: Aug. 2014
Offline
Hey guys,

I'm trying to figure out how to bake some lighting information to texture hair cards. I got pretty Far with the BakeTexture ROP, but it doesn't seem to support baking reflections. I stumbled across this thread [www.sidefx.com] while trying to find a solution, but the example scene that brianBurke posted there throws and “Unable to evaluate expression (Undefined variable (/out/dispbake/soho_diskfile)).” Error when trying to bake.

Just to be clear, unlike that example scene, I'm really looking to bake scene lighting information including direct illumination, indirect illumination and reflections.

Looking into this, some people were talking about a mantra -u command which would be able to bake lighting, but I couldn't figure out how to implement that or if it was still supported.

Any help would be greatly appreciated! In addition to hair cards, being able to bake lighting of the scene has a ton of applications for optimization of heavy scenes, so I think this is interesting to a lot of people.
David Reinhold
Lead Crowd Technical Director at DNEG
User Avatar
Member
8177 posts
Joined: Sept. 2011
Offline
Baking lighting can be enabled with the checkbox on the bake texture rop. However, baking reflections doesn't make sense, as they are view dependent. The I vector used for baking is usually the projection direction, which is usually the normal. The result probably won't look very much like a reflection, but I don't see why it can't be tried anyway. Baking using proxy geometry has the limitation that only the values gathered using the baking material will make it to the output. A custom bake material is probably required to gather lighting in that case.
User Avatar
Member
6 posts
Joined: Aug. 2014
Offline
What an interesting reason. I hadn't considered that. Also I just found out that the reason I wasn't get lighting was because of the vm_uvlightpaths (“Exclude Light Paths”) which are -diffuse & -volume by default. I already had vm_bake_skipcf (“Disable Lighting/Emission”) disabled, but had missed the other parm. xD

So I guess other software/renderers that work with this feature are able to separate the render cam position this reflection is using from the output render pixel, but mantra assumes they are the same (which also makes sense somehow). I'm pretty noob at shaders and rendering haha
Edited by David Reinhold - April 18, 2020 13:53:04
David Reinhold
Lead Crowd Technical Director at DNEG
User Avatar
Member
8177 posts
Joined: Sept. 2011
Offline
Ray tracers work by sending the I direction recursively to each material hit. You'd have to make your own ray tracer that sends a different value for I to the hit. This is possible in Mantra, but pretty far out of the box.
User Avatar
Member
9380 posts
Joined: July 2007
Offline
jsmack
Ray tracers work by sending the I direction recursively to each material hit. You'd have to make your own ray tracer that sends a different value for I to the hit. This is possible in Mantra, but pretty far out of the box.


isn't that the correct way of baking however?
shouldn't just first intersection happen in projection direction, but the “I” variable passed to the evluating shader should be faked I from the provided camera, the rest of the path would behave normally

I haven't had a need to bake view dependent effects, but I'd assume it should be supported, if not, then it's either RFE or BUG
if it doesn't work that way, why is there a camera parameter on Bake Texture ROP?
Edited by tamte - April 18, 2020 14:47:57
Tomas Slancik
CG Supervisor
Framestore, NY
User Avatar
Member
8177 posts
Joined: Sept. 2011
Offline
tamte
jsmack
Ray tracers work by sending the I direction recursively to each material hit. You'd have to make your own ray tracer that sends a different value for I to the hit. This is possible in Mantra, but pretty far out of the box.


isn't that the correct way of baking however?
shouldn't just first intersection happen in projection direction, but the “I” variable passed to the evluating shader should be faked I from the provided camera, the rest of the path would behave normally

I haven't had a need to bake view dependent effects, but I'd assume it should be supported, if not, then it's either RFE or BUG
if it doesn't work that way, why is there a camera parameter on Bake Texture ROP?

I think the ‘I’ comes from the Lens shader, which is the uv unwrap lens shader in the case of the bake texture rop. I presume the camera parm is there for sending render properties stored on a camera, but I'm not sure which ones would be of any use when baking. I would be neat if it were possible to send an additional perspective camera for generating the ‘I’ used in view dependent effects. Then bake texture could be used for baking imposters too.
User Avatar
Member
6 posts
Joined: Aug. 2014
Offline
The camera parameter on the Bake Texture ROP also gave me hope that this was supported. I used this feature in a another software for texture memory purposes to “hack” heavy renders by baking everything to a flat shader in a small studio once. It's wasn't physically correct because other objects reflecting these objects didn't get the correct reflections, but it made some really huge scenes manageable texture wise. Think about baking 4-6 8 k maps down to a single combined one in the resolution of what you actually need for that specific shot.

Could be something worth adding as an rfe before they add texture baking to Karma.
Thanks for the insight guys this was super helpful.
David Reinhold
Lead Crowd Technical Director at DNEG
  • Quick Links