Learn how to remove uneven lighting from a texture image. Find out how to use a Blur node for a low-pass filter, a Color Multiply node for texture contrast, and ColorLookup to soft-clip negative code values.
- [Steve] Hi, this is Steve Wright, welcoming you to this week's Nuke Nugget, how to remove uneven lighting from a photo, in order to use it for a texture. Whenever a surface is photographed, it will normally be unevenly lit. However, when used as a texture, we want the texture, but not the big, then, lighting from the photo. Here we'll see how to remove the uneven lighting, but keep the texture. Now, we'll be using techniques similar to the boat map techniques we saw in episode 14.
So, here we'll start with this concrete texture and I did a tile here, two by two, just so you could see how the edges don't line up due to the uneven lighting. Okay so, first, let's start by adding a blur node. Now, let's label this guy as our low pass filter. And, there's an opening gambit. Let's set it for about 20. So, that's removing the high frequency detail passing through all the low frequency which is, in fact, the lighting changes.
And we'll come back and dial that in later. Next, clicking right here, typing m on the keyboard, add a merge node. Now, first we set the merge node to minus. And let's label this guy while we're here. This will be our extract texture. Now, what we have to do is subtract the low pass filter from the original photo. So, we have to hook a to the original photo and b to the blur node.
Then, we're going to get our texture. Now, a very important point about this texture. As we cruise in here and we look at the code values, you see these black areas? Well, there's negative data in there. That's not black. There's picture information. So, we have to be very careful that we keep all of the picture information. Cause when we did this subtraction here, the difference between the original and the low pass filter is some of the pixels were brighter, some were darker.
So, we don't want to lose anything. We are nuke compositors. We lose no data. Alright then, next step. Right here, select the merge node, come to the color tab, and add a math multiply. Okay, now let's label this node as contrast. Why contrast, you say. Well, I'm going to cruise in here, if I multiply the code values greater than one, you can see it's getting brighter.
But also, look into the blacks here. My code values are getting more negative. So, let's watch this. See, those code values are getting darker and the lighter ones are getting lighter. Hence, contrast. So, I'm going to reset this back to default. We'll come back and dial this in later. Next, we need to set the overall level, so let's add a grade node here. Now this is very important. We must turn off the black clamp. Otherwise, we're going to lose our negative code values.
Let's label this brightness. Now, we use just and only the offset, no other adjustment. Going to re-home the viewer. If I set the offset, I am restoring the original brightness of the picture that was removed when we did the subtraction of the low pass filter. So, we're replacing the uneven lighting of this guy with the uniform value from this guy.
Now, if you'd like to get the brightnesses about equivalent, we can do this. Put it up to the viewer wipe controls. I've got one side hooked to the read node, the other to the grade node here. And then, we can dial in the offset until we get a matching level of brightness, like so. And of course, you got to pick what you want to match, cause ours is even, the original is uneven. Okay, so let's say we like that. Now the last item is, you see these black holes? Well, they're in the original photograph, but when we did our thing, we want to be able to keep the data that's in there.
There's picture information in these, in these dark spots here. If I cruise in here, for example, we'll look in this guy. You can see, I've got some code values in here, very small, but there's picture content. Alright so, what we need to do is find... Let me go back to my original grade node here. What we need to do is find the darkest ones so that we can lift it up and put it into the positive code values, but we do not want to clip.
We're going to keep every pixel of information. So, to find the darkest guy, the most negative hole, I'm going to add another temporary grade node here. Now, this is a throwaway. Viewer is hooked up to that grade node. I'm going to use the offset to raise the overall levels. Okay, to help let's turn our viewer gamma up really high. So, you see, if I raise the offset up, my holes go away.
So, I slide back, looking to find the first one that turns black for me. And okay. I'm going to call this guy right here. Okay? Alright, so I found my target. I do not need this node anymore. Right now, viewer gamma back to normal, we can see that the code values in here are quite negative. So, I want to raise these guys positive without clamping or clipping. And we can do that with a color lookup node.
Let's select the grade node, color, color lookup. Let's turn on the master LUT. Now, if we zoom out, these are the color bars for where my cursor is. In fact, if I move them around, you can see the bars are dancing all over the place. So, I need to move this control point here, the black point, just to the left. That will pull these up into a positive code value, ever so gently, of course.
Now, if I just grab this and start moving it, you see the darn points start moving around. You see? So, that's not helpful. So, what we'll do is turn on the pause feature. That way the viewer won't update while I'm moving my curve. Okay, so let me put that curve point just to the left. Okay and then I'm going to give it a little bit of a slope here. So there's my soft clip, okay, very gentle. If I zoom out, I've applied a bit of a curve to the entire picture.
If I'd like back off on that a little bit, I can add another control point here, for example, and then bring that over here. And that way, this part of the curve will be perfectly straight and then this part here is just for getting my blacks tucked in real pretty. Okay, we can turn our pause off, return to our picture. Let's re-home our color lookup, so we can get the big picture of what's going on here. Remember, this is the zero code values right here.
So, we've pulled these negatives up. So, let's label this guy fix holes. Okay. Now we're ready to dial it in. We can come up to the multiply operation, for example, and if I increase the value, I'm going to get more contrast in my texture. If we go to the blur node, our low pass filter, if I reduce that, I'm going to lose detail in the texture.
If I increase that, I'm going to get more detail. I'm also going to get back in more of that lighting. If I keep going, I'm going to restore the original uneven lighting, so let's not do that. Keep in mind, if you adjust this or this, you have to go back to the color lookup because you would have changed the negative code values. Okay, so let's see how we did. Now, we originally had this tile set to the original picture. So, what happens if I copy that, put it down here, and look at our new picture.
Oh, look at that. We have removed all of the color and the uneven lighting. Now, if you really want to tile this, you're still going to have to go in and paint out the seams, of course, cause we haven't fixed the seams. That's a painting problem. Well that was fun. So, let's try it on another picture, which we can do, actually, very quickly. And see, I have a lot of uneven lighting here and when I tile it, wow. So, all I'm going to do is go grab this entire stack, copy this, and then bring it over here and paste it.
We'll do this guy in one minute flat. Okay, so starting with our original picture, we go to our low pass filter. Again, adjusting the amount of blur, adjusts the amount of detail that comes through. Here's our subtraction. There's our texture. Here's our multiply. We want to adjust the contrast, okay. Here we go. I'll put that back to default. Here's our brightness. Again, that looks pretty good. We'll just go with that. Now, we have a different set of black holes now.
So, I'm going to have to dial in my color lookup. So, let's just reset this guy back to default. Same technique. We'll do it one more time, just so everybody can get it. I'm going to add a temporary grade node, shift g, hook my viewer up to this guy, blast my viewer gamma up, and in this grade node, I'm going to adjust the offset until all my black holes go away, then back down to see who the first one to reappear is.
Okay, well let's say it's this guy here. So, I'm calling this as my most negative code value. Alright, we'll delete that. Go to the color lookup. I can bring my viewer gamma back to normal. And let's drop in a control point. There we go. There's my negative code values. We'll turn on the master curve in the color lookup. So, here are the lines indicating where that point is, so I'm going to again bring the control point after I turn on the pause feature in the viewer.
I'm going to bring that control button just below them. Give it a bit of a slope. There we go. Okay and then we'll turn our pause feature back on and admire our handiwork. Again, if I adjust my contrast or adjust the brightness, I have to go back to the color lookup and tweak it in. So, let's see how we did. Again, this is our original tile here. So, let's copy that, put it down here, hook it up, and compare.
Oh, there we go. Very nice. Okay. So, there you have it, a really slick method for removing the uneven lighting in a photo and still preserve the texture. Be sure to check in next week, so you don't miss out on my next Nuke Nugget.
What kinds of NUKE tips do you need? Join the Steve Wright's NUKE NUGGETS group on LinkedIn, and post your requests there.