Showing posts with label After Effects. Show all posts
Showing posts with label After Effects. Show all posts

Friday, August 15, 2008

Relighting with Normals Passes

I recently received an email asking me to put up an old tutorial from my website on relighting with normals passes. This tutorial uses Maya and After Effects, but should be easily transferred to other apps. This technique can be used in conjunction with an occlusion shader to create ambient light, or can be used to add to/alter the diffuse lighting that is already rendered.

Start off with a normals render light this. I used Mental Ray's occlusion shader to render out the normals.



Drag it into a comp and apply a channel mixer effect to it. Set the channel mixer to "monochrome"



This makes it so that only the top four sliders effect the image. Basically, just take the "Red-" preface off of each slider label.
So what you get is a greyscale image based only on the red channel. In the normals pass, Red is the normals value along the X axis, where the more a normal faces the positive X direction, the more red it gets. (note: the x axis can be either the world x or the camera x, depending on the type of normals pass. This pass was done in world space.).


If we turn the red channel down to 0 and the green channel up to 100, we get the Y axis normals, like this.


and the Z axis is of course, blue.

Now, if we set a channel to the negative, we have to compensate with the "constant" channel. Here, we see a negative green channel with compensation.




See how it looks like it's lit from underneath, instead of from above.

So let's play with some sliders. Say I want to create a bit of a side light/rim light. Well, thinking in terms of xyz, I would want the light to come from a little bit behind, so I set the blue (Z) to a negative value. I want the light to be a bit above and to the screen right of the character, so I set the green(Y) and red(X) to a positive value. I don't really need to use the constant slider, because the red and green channels are doing the job of compensating here.



So let's say this is what I want the light to look like.



Now I bring in a color pass and multiply it over the normals pass.



and there you go. Basically you have a diffuse render now.



This method has been extremely helpful on a lot of jobs I've done. I've even done some jobs using only normals passes for lighting, and just rendering out shadow and occlusion passes once I'd set up the "lights" how I wanted them. However, there are a few areas that you can get caught up if you're not careful. One of the biggest is premultiplied alphas. The best workaround I've found is to ignore the alphas for the main passes (color, normals, occlusion) and then precomp them together, applying an alpha to the precomp via track matte or the set matte effect.

I hope this helps you out. If you think of any other ways to use the normals, or of a better way to get the same effect, drop me a line or a comment. And if there are any techniques you'd like to see, let me know and I'll see if I can come up with something.

Friday, May 30, 2008

Subtractive Reflection Pass Method

My first new tutorial since moving from a website to a blog! This calls for a celebration! Is 10 a.m. too early for a beer?
I was on a project with a pretty ridiculous deadline for the amount of work to be done, and of course, a ton of time was wasted trying to get approvals from the clients. After searching around for a good way to make a reflection pass, I found myself S.O.L. The best methods I found still involved a lot of setup, and hardly seemed worth the effort in the end. The worst part is, I had done a shot that was similar to what I was trying to do, but I couldn't remember how I had done the reflections. At the time, I had been running on no sleep for 2 days, so it's easy to see how I might forget anything I did. Then, suddenly, it happened. I remembered!! Subtractive Reflection Pass! At least that's what I call it. Basically, I render the scene with an approximation of the lighting, and turn on raytracing and specularity. Then, I render it again and turn off raytracing and specularity, and subtract one render from the other in After Effects.
Here's how it goes. We'll use a simple scene to illustrate. I'm going to use Photoshop, but it works the same in After Effects.

First render the scene with all the reflections and specularity you want.



Next, turn off reflections and specularity and render again.



Layer one render over the other, and change your blending mode to difference



And this is what you're left with.



And you can see, yes there are some drawbacks to this method. Namely, the areas where the reflection clips to white on a white object, such as in the checkerboard area. However, this usually isn't a real problem, and if it is, you can always change the objects color to a darker color to help avoid this. I have yet to try it with a floating point format, like HDR or EXR, but I think it might be worth looking into.

So now you have a separate reflection pass for use in your comps. I just recently used this technique on an ad for a Speed Racer happy meal tie-in. It was a huge time saver!