Software used
Maya 2011, mental ray
What you will learn
In this tutorial, we will tackle a lighting challenge with small-scale production needs in mind. Intended for small-scale productions, this tutorial walks through one lighting and rendering workflow that introduces new tools, techniques, and workarounds. We will exploit the environment-sampling power of portal lights, build a fake GI solution with projected light fields, and use MEL scripts to automate tedious tasks. These methods won't work for every scenario, but they can be very useful tools for the guerrilla CG filmmaker.
In this lesson, we're going to create the ambient light for our train station scene. Now, before we really get into the nuts and bolts of this, I want to back up for a second and just talk a little bit about some of the workflow choices that I've made so far. You may have noticed that I haven't really talked a whole lot about render layers and compositing, particularly, for this scene. There's a good reason for that. I go back and forth on just how much I want to get out of a renderer and how much I want to get out of a compositer. It really depends on the scene, it depends on the project that you're working on. But for me, the ground line has been I don't want to rely on compositing in order to get a good image. Compositing is very good at certain things that the regular renderer isn't so good at-- getting depth of field, motion blur, lighting effects like bloom and lens flares. Those are the sorts of things that we can use to make the image better, but we don't want to rely on that too much in terms of getting just a good image. The other thing is that to really, really harness the power of compositing, you need to have a pipeline that really supports it and that is able to kick out those kinds of-- the renders that you really need, with all of the mats and the AOVs and everything else. And when you're working on a guerrilla production, you don't have that support structure in place. So I tend to find that I create a good looking image inside of the renderer, and then I use compositing to try to make it that much better. So that's kind of my philosophy behind the workflow in a guerrilla production like this. So we've already created the direct light inside of the scene, and now the real fun begins. Because the real trick of all this, the reason why this is a guerrilla production as opposed to a regular production is because we're going to be faking some of the processes that otherwise would be very, very difficult. Or not necessarily difficult, but very time consuming to achieve. Specifically, bounced light, ambient light, and the sort of effects that you would get from Final Gather or Global Illumination. So just like we did in a previous lesson, I'm going to go ahead and take a render with this last frame. And I'm going to turn on Final Gather in order sort of get a baseline to compare to later. I'll bring out my Render options, go to Indirect Lighting, let that load, turn on Final Gather. And I'm going to turn up the point interpolation a bit to get a smooth result, and the rest of this should be fine. I might even turn up the accuracy just for this example. So I'm going to go ahead and hit the Render button and pause the video and come back whenever that's done. So here's the render without Final Gather, and here's the render with Final Gather. So essentially, you see that we're getting nice bounced light coming up on the back wall. We're getting nice bounced light up in these shadows where previously we had nothing but black. And honestly, this result is looking very, very nice. And I can pretty much guarantee that once you put this kind of result along with all of those textures and materials and glossiness, it really just shines and it looks really great. But again, we've also essentially gone from a three minute render to a four and a half minute render, which may not be too much. But once again, once we had in the materials and the textures and reflectivity, especially, those numbers will begin to skyrocket as you add complexity to a scene. Especially once we put the train back in and everything else. So the challenge now is to figure out a way to fake the result that we're getting from this. And the first part of that is to figure out, well, what exactly is this contributing? What exactly is the difference between this and this? How do we quantify that in a way that we can actually begin to fake it? And there's an easy way to do this using the Mia Material X Shader, which I've actually used for just about everything in this scene. So what I want to do is go ahead and go to my Hypershade real quick. Let that load up. And I'm going to create a new Mia Material X. So scroll down to Mental Ray, Materials, and I wanted Mia Material X. I'm going to leave this on all of its defaults. And I'm also going to create a regular Maya surface shader. What I'm going to do with this is actually pipe one of the composite results from the Material X into this surface shader. so I'm going to middle mouse button drag onto it, go to Other. I'm going to scroll down until we get to the Final Gather Result, which is going to be with the rest of the results down here. Let's see. That's actually Indirect Result is the one that I'm looking for. If I go ahead and hit Indirect Result, I'm going to plug that into the outcolor of that surface shader. Now, these are all temporary, so I'm not going to bother naming these shaders right now. And what I'm going to do is just create a plane in the middle of my scene. Just zoom out to the top here and create this plane so that it pretty much encompasses the space. I'm going to go ahead and apply that new surface shader to it. Now, what should happen here is whenever I render, this plane will only show exactly what is being contributed via Final Gather. What I'm also going to do is make sure that inside of the Attribute Editor for this object, inside of Render Stats, I turn off Casting Shadows, Receiving Shadows, and all of these others-- Visible and Reflections and Refractions-- just so that I make sure that this is the only thing that I'm getting in the scene. And it's not sort of creating a double result because of it sort of affecting itself. So this is now not affecting anything in the scene. It's only receiving Final Gather. It's only going to show what we get from Final Gather. So I'm just going to actually move my camera up a bit so we can kind of get a bird's eye view of what's going on here. And I'm going to take a render, pause the video, and come back whenever it's done. And this is the result that we get. You can see that if you only have the Final Gather results showing up, you can really see sort of where the splotchiness of the Final Gather is coming in. Because these pixels are sampling a small, super-bright area, they tend to speckle out like this. And there's a lot of workarounds for this if you wanted to work with Final Gather. But in this case, I've found that it's a little bit easier to go with a fake method than to tweak and create sort of an airtight scene. I'd rather be sloppy with my modeling, sloppy with the setup for everything, and sort of have a hack and slash solution that looks really good, than go through and do everything sort of properly. But again, sort of taking a look at this, we're not really looking at the fine details. We're looking at sort of the broad strokes here. What are the base color values that are being added into this scene? And you can pretty much see it's more or less a gradient between sort of this little bit cooler bluish on this side that just fades right into this very warm orange on this side that just comes right off of this window. You can also start to see, it gets cooler on this side as well. If I were to grab another camera angle, you would see that there's a lot more of that blue coming in on this side as well. So pretty much what I'm going to do is just use a ramp to create the exact same colors. Just to make sure here, too, I'm going to take another render from a different angle. I'm just going to grab this card that I created. I'm going to move it up to the ceiling. And do the exact same thing with the camera pointing upward, Just so we can see what's going on with this. And I'm going to go ahead and start that render and pause the video. So here again, you can really see that there's just sort of this nice gradient between this cooler color on this side and the warmer color up here. Now admittedly, we are going to lose a lot of these little bounce light effects that are coming off of the columns and by the windows, but to me, that's a fair sacrifice. If we really need something like this, if it just doesn't look right without it, it's easy enough to go through and create a few area lights that are light-linked to specific objects that create those highlights without having to go through the entire process of creating and sort of maintaining Final Gather. So in this particular instance, what I'm going to do is actually leave this image up so that whenever we create our ramps, we can create something that's very accurate to this image. I'm going to go ahead and save that. So if we take a look at what we have saved, we still have the first render that we did with Final Gather, to use as a benchmark. We've also got this that shows this color transition. All right. So the first thing I'm going to do-- go ahead and delete this guy out. I'm going create a gizmo that I can reuse later when placing my ramps to create light fields inside of the scene. So what I'm going to do is just zoom in on the actual grid, which is very tiny in my scene, and I'm going to go to the Hypershade. Inside of the Hypershade, I'm going to create a new ramp. Let's just go to Textures inside of the Maya rollout. Right click on Ramp and create as Projection. I'm going to go ahead and make sure that inside of my view port I've got textures turned on, which will give me this little green guy right here. The other thing that I want to do is go ahead and create a plane that I can use. So just click Poly Plane. And we go to my side view. Zoom in real quick, and just draw this guy in. Doesn't have to be real accurate, I just want to put him right smack dab in the middle of the scene. And move him over to be sort of on top of this projection real quick. I'm just going to scale this down a little bit. So that should work fine. I'm going to go ahead and parent this underneath the texture node, the 3D placement for this. So whenever I were to rotate this or move it around, it will stick to it. I'm going to go ahead and also create a group node for this. So I just hit Control-G to group. I'm going to open up my Outliner. Where are you, Outliner? Window, Outliner. And I'm going to rename this to be Texture Gizmo. So whenever I want to create a new light field for my scene, I can go ahead and duplicate this, and duplicate special in order to get all of my shader information out of it. So what I'm going to do is just going ahead and scale this guy up until he encompasses the scene a little bit. Just move him over somewhere where he's going to be a little bit less obtrusive. So he's just sitting right up in the sky and I can duplicate him at my leisure. The other thing I'm going to go ahead and do is just go ahead and create a surface shader that I can apply to this guy. So go down to the Maya Surface menu, create a Surface Shader, and plug this ramp into it. On default. And this shader will get applied to this card that we've created. So now, if I were to hit 6 on the keyboard, you can see exactly what we're getting with this scene. So if I move this guy around, he's going to essentially have that texture applied to him. Excuse me, this ramp shouldn't be plugged in, the projection should be plugged in. Not default. So now we're getting exactly what we want. So if I move this card around, he won't update according to where this projection texture is. so if I move the projection, what we should see is it will stick to it. All right. So I'm going to go and create the first light field that I'm going to use to control the overall broad strokes of colors for this scene. So I'm just going to select my Texture Gizmo group, go up to Edit, Duplicate Special, and make sure that Duplicate Input Graph is turned on, and hit Duplicate Special. So essentially, what this has done now is created a whole separate group that I can use when placing this. So I'm going to move this guy over and he's going to essentially provide the basis for the gradient that we were seeing with the previous render. So I'm going to just move him over. Maybe go into my top view so that I can see what I'm doing on top. And make sure that this is rotated correctly. It looks like it's sitting pretty. It's looking pretty good. The other thing that I want to make sure that I'm doing here is setting up my texture repeating properly. I don't want to have any textures repeating on this. So I want to go into my Place2dTexture node. If I bring this up over here you can see it. I want to make sure that Repeat U and Repeat V are turned off. I want to turn off REP in both directions. Don't know why it got rid of that there. I'll have to take a look at this real quick. Just to make sure that I'm actually still getting that texture. It Doesn't. Seem like I am. Let's turn REP back on. I may have chosen the wrong function there to change. Bear with me, ladies and gentleman, real quick. Back in the Place2dTexture node. Turn on REP but turn off Repeat UV. And that should give us exactly what we want, I believe. Or maybe not. I tell you what, I'm going to go ahead and pause the video, and as soon as I figure this out, I will be right back. So has anyone guessed it yet? It's because I had the wrong texture node selected. And I've been essentially using this texture applied on here. So it turns out that my entire gizmo idea didn't work out as well as I'd hoped. I guess that's kind of just what I get for trying something new in the middle of a tutorial. But the same theory is sound, so I'm going to just go ahead and use this guy, and use him as my primary source for colors in this scene. So I'm going to go back to my top view, hit 6, scale this guy up until he's encompassing the scene. I'm just going to go ahead and use that default color for the moment, just to make sure that we are applying things correctly. Now, I could go through and use the User Mode Area Lights like we looked at in a previous lesson, but those actually don't work with Mental Ray shaders, specifically the Mia Material X shader. But there is a very convenient and just about as easy way to get the same effect using those shaders themselves. Inside of any given Mia Material X shader-- so if I go ahead and grab the shader that's applied, our base shader. If we scroll down to Ambient Occlusion, we have the ability to use a built-in ambient occlusion on each individual shader. So you have Sample Values-- this just like plugging in the Ambient Occlusion node from the Hypershade, but it's being applied to each material in the scene. So if I want to plug this texture into it, what I can do is go through and grab the projection node that I had. I think it's under Utilities. I tell you what, I'm just going to grab this guy, and make sure that I focus on it. And show my connections real quick so I can see what's going on. And this projection is what we want to apply to this material, the base material. So back to base shader. And I want to apply this projection node to the ambient light color. I'm going to go ahead and turn the ambient shadow color down to zero. And the distance, because this is a very large scene, I'm going to turn to about 200. Now, the trick with this is that this needs to be applied to every shader in the scene, every Mia Material X in the scene, which is very helpful because every material in this scene is an Mia Material X. So it's very easy to go through and write a script that'll apply it to everything. So that's something that we'll take a look at a little bit later, as soon as I make sure that this is actually working. I'm going to come back in and I'm going to go ahead and, first of all, make sure that Final Gather is turned off. Turn off Final Gather. And I'm just going to go ahead and take a render of the scene. I'm going to pause it and come back. And here is our psychedelic sherbet land render that we get. And since we're not specifically trying to go for the whole LSD-inspired look we're going to go ahead and start tweaking these colors a bit. You can notice that there's one shader in here that I neglected to change to the base shader, so you can see how that's affecting the scene, or not affecting the scene, as the case may be. So let's go ahead and get some proper colors in here so we can really start to see how this is being affected in the scene. So I'm just going to go back to this render that we had of the ceiling so we can get a really accurate result of what these colors would be in a real scenario. So I'm going to go ahead and go back up to this ramp that we have. Delete the middle character, the middle ramp node, anyways. And we know that blue is on the far end, I believe. Yeah, blue is on the far end. So this color is now going to be-- I'm going to use my eyedropper selection. I'm going to select this far color. And again, this isn't going to be perfectly accurate, but for our purposes, it's probably a good enough starting point. So I'm going to go ahead and use my eyedropper and select the far point here. So we can see, we're starting to get just sort of a gradient of color across the spectrum. I already know that I'm going to want this to be a little bit more saturated, so I'm going to go ahead and push this towards a little bit more of the purplish-- I'm actually going to push this more towards blue as well. This again, just kind of comes down to how are you going to use your artistic eye to establish your scene. And I know that I'm going to want this to be a little bit more on the purple or blue side. I'm just going to push it that direction, make it a little more saturated. Maybe even give it a little bit more brightness. The other thing we need to make sure that we do in this situation is to gamma correct this color as well. So I'll go ahead and go back into that node in the Hypershade. So in here. Grab this projection, and I'm going to go ahead and create a gamma correction node for this. I'm going to use the Kludge Tools for this. Go ahead and bring back up Kludge. Go to the Digital Tutors and Insert Gamma Node for Selected. So now, if we go ahead and take a render, what we should get is something a little bit closer to what we want in the final image. So I'm going to go ahead and render it, pause the video and come back. And this is what we get with our first pass of faked Final Gather. And it's actually not looking that bad, I must say. If we compare this to the actual Final Gather render image, you can see that there are considerable differences between the two, but not insurmountable differences. And we're having about half the render time because we don't have to go through that process of calculating the Final Gather map. And even in this case, I actually kind of like some of the detail that we get from using the ambient occlusion. It gives it a little bit more of an artistic stylized feel, as opposed to something that's a little bit more realistic. Again, we're losing some of the detail that we get from using a real Final Gather approach, but again, it comes down to a trade-off. If I had my druthers, I would use full GI and Final Gather for every shot that I do, and it would come out beautiful and wonderful, but it would also take forever to do. So it really is just about that trade-off and sort of living with those consequences as you come across them. So the next step here, I guess, will be to sort of address some of the differences between these two images. Sort of the first thing that I notice is just the brightness on this back wall. I really want to match that sort of bounced uplit look. So I'm going to go ahead and create an area light and constrain it to this particular piece of geometry. And you guys all know how to do that, so I'm going to go and pause the video and come back as soon as it's done. So this is the result that we get with that extra light being linked into these back parts on the wall. So if we just take a comparison between these two, you can see we're getting a much nicer result on that side. So I'm going to go and delete this image from our kept images and keep this one. So now we can take a look at a few of the other major differences between these two sets. The first thing that I noticed, really, is a change in intensity between the main corridor here and these hallways that back off into the distance. There's just not a whole lot of bounced light coming through here. If we were to turn up the number of bounces, you might get a little bit more of a contribution over there, but I really want to start to eliminate a lot of this light that's being incorrectly applied back here. In order to do so, I'm going to go ahead and create a new texture that's applied as a ramp. So I'm going to go back into my Hypershade one more time. Unfortunately , my gizmo idea didn't work out. I was originally going to script that in, but since it's a non-starter, it's probably not going to be something that I can work on. So I'm going to go back to Window, Rendering, Hypershade. And I'm going to go ahead and clear my graph real quick. And I want to start with a fresh ramp. So again, create a ramp. Actually, I'm going to delete that, and right-click, and Create as Projection. So I've got my projected ramp one more time. We'll make this a ramp that fades between black and white to start with. Call this white, call this black. And go ahead and put this ramp into position. So I've already got one ramp that's facing downward. If I want to add something that is changing the intensity of that ramp, I could put it on top of it. But just for organizational sake, I'm going to put it over to the one side. So let me go ahead and grab the Place3dTexture node for this. Close this down. I'm going to close down all of these windows actually. Close that, close that. All right. So I grab my Place3dTexture node and move it into place. And just scale it until I can actually see it coming up in the scene. Go ahead and scale it up enough so that it encompasses the scene a bit. Go ahead and scale it down just so I can get a good bead on what size it is here. And that's looking pretty good. Leave it there. And I'm going to go ahead and make this ramp a horizontal ramp. Usually, the way that these projection nodes work is that this bottom corner is also the bottom left-hand corner of whatever the Place2dTexture node is. So you can always tell what direction your ramps are going to go for. I'm going to go ahead and delete this card out. We don't need it anymore. So going into here, go ahead and grab the image that this is associated to. And I'm going to make this ramp into a horizontal ramp. It's right now on vertical, I want to make it horizontal. Now, I've already got one side set up pretty much how I want it to, because I want it to fade off to black on one side. I also want it to fade off to black on the other side. So I'm going to make a new blacks swatch here. And it's going to be white in the middle. Let me go and create a couple of white swatches as well that I can use. And now we can, essentially, control the fall off on either side. I want to make sure my interpolation is set on Smooth. That's going to give me the nicest results in terms of where this light is falling off. Go ahead and delete this middle one, I don't need it. And I'm just going to start moving this over a bit. I'm going to use it this way. So what I'm going to do is take this projection node and essentially multiply the two together from the previous texture that we made. Just going to grab this ramp that we made that's defining the color in the scene, and this one, which will define intensity in the scene. So I'm going to get this and this. Go ahead and show the input and output connections. Bring these two guys down. And I'm going to multiply these together. Go ahead and go into my Multiply node. Grab this guy. Create a Multiply-Divide node. Input one, input two. And I can go ahead and plug this into the Gamma Correct on Value. So now this is plugged back into that shader exactly the way that we want it to. So I'm just going to go ahead and take a render of this and we can start tweaking the location of these ramps that we made. So I'll hit Render, I'll pause and come back. So you can see that we're starting to get a nice fall off in the amount of ambient light coming back into this corridor. We can tweak the position of this ramp and just have a lot of creative control over exactly how far and how much we want this to fall off. So going back to the Final Gather version, you can see that the number of differences between these two things is starting to diminish quite a bit. So I'm going to just do a few tweaks. I'm going to change the location of this fall off to better match the Final Gather version. And I'm going to reduce the overall contribution a bit, to get sort of a more rich, less washed out feel across the scene. And we'll take a look and see what we can get with that. I'm going to go ahead and pause the video, make those couple of tweaks, and see what we get. So a couple of tweaks later, and the image that we're getting, when compared to the original Final Gather image, I mean really, the differences are subtle enough that it really won't matter in the end, in the final image. And I'm actually kind of liking some of the effects that I'm getting, some of this sort of nice gradient on this back wall that I'm just not getting with the original render. And this is infinitely more tweakable. I mean, if we wanted it to be so that the balance light was more intense towards the floor than on the ceiling, or if we wanted a completely different color set on the ceiling than on the floor, this is actually a really nice way to do it. But what we really need now is a way to create this same ambient lighting scheme with all of the other materials inside of this master node-- inside of this master layer. So I'm going to go ahead and turn off Textures so that I have a clean slate here. And I'm going to go ahead and bring up my Kludge Tools, which will be a button up here. Go ahead and do that. Now, luckily for you guys, I have already done the hard part of this and come up with a script that will automatically apply any given selected node to all of the ambient occlusion of all of the shader in our scene. In order to do so, we first need to enable the AO on all materials. So I go ahead and hit this button, which says Enable AO on all Mia Material Xs. Give it a second to work, and that should do it. So if we now go ahead and grab any one of these, we should see that Use Ambient Occlusion is turned on. Now previously, whenever I was first setting everything up, I already went ahead and turned on my distance to 200. Normally, actually, I would probably just go ahead and scale the scene down before I would actually do this. Whenever I was first putting together the scene, I was going to be using Photons and Final Gather, and having a proper scene scale is actually really important whenever you're working with those things. But ultimately, I decided to fake it, which was the end result of this tutorial. But the scene scale remains, so I kind of have to have these ridiculous numbers inside of my distance. But it's now enabled on all of these shaders. And all I have to do is select this Gamma Correct node and hit Assign Selected to Mia Material X Ambient Channel. That button has now been selected. And if we go ahead and grab, let's say, this back wall material, and graph the network, you'll see that this Gamma Correct node has now been applied to the ambient channel inside of this particular shader. In fact, it has now been applied to all of the shaders. Any of the Mia Material Xs, anyways. So to go ahead and take a look and see what we're getting, to see if we're getting any problems, I'm going to go back into my master layer-- enable Render real quick on that-- and I'm going to take a render and see what we get. I'm going to pause the video and come back. So looking at the render with all of the shaders applied, you can see that probably this back wall needs a bit of tweaking in terms of the light contribution and the shaders applied back there. But on the whole, it's really not a bad result. I mean, considering that this is just a little over five minutes, we've got a 720 render that's coming out with a really nice Final Gather-like result without using any real Final Gather. So in this lesson, we've taken a look at how to add ambient lighting to our scene without using any calculated Final Gather or Global Illumination. In the next lesson, we'll bring the train back in and start looking at some of the details in terms of optimizing reflections and light mapping in the scene.