Saturday, March 28, 2015

bake/unwrap shader with lighting

Somebody asked me how to unwrap the rendered result of a shaderfx shader to a texture. This may seem like a strange request, because why would you want to bake your lighting into your texture?

 But I have actually had to do this myself once when porting a xbox 360 game over to low-end mobile devices. We were a very small team and could not redo all assets and we really only wanted a single texture per asset.

So, here is how to do the shaderfx part of it. Lets say we want to unwrap a rendered texture for this horse model:

What we need to do is go into Advanced mode, then enter into the "Material grp". Add a new "Vertex Shader UV space" group node. Replace ALL (!) the output of the existing Vertex Shader grp with this new node.

 It will then unwrap the 3d model in your 3d view. From here, you could use other tools to grab the view result and save it as an image.

If you want to save this file with the model unwrapped in the screen, you have to save a NEW grp for the Material grp you just changed. Otherwise, your changes won't stick after re-opening the file.
You can save the grp by renaming its Class property to something unique and then using "Save Grp".

(One tip might be to make the Maya viewport black before saving the image, or if you need to create a mask, make it bright purple so it is easy to select the background color in something like Photoshop)


  1. Thank you for this great tutorial. This will definitely come in quite handy. I am having one issue though. Currently the Maya viewport stretches out the unwrap in the 3D view. As I scale the Maya application, I can see my unwrap stretching to fill the viewport. Is there any way to lock this to an exact 1:1 ratio?

  2. Can this be done with a Stringray PBS? I am having trouble figuring out how to apply this process to that.

  3. Yes I believe a checkbox-setting was exposed on the Stingray PBS node in the graph to do the same thing. (Not in front of Maya atm)

  4. Outdoor lighting blends contemporary style with the need to provide appropriate lighting in a functional manner. chandeliers