Sunday, July 21, 2013

UDK Lantern material tutorial


Finally! The promised lantern tutorial! I'll show you step by step how to make a flickering lantern material, and I've included my textures and model. I assume you already know how to work with the material editor. I you don't, come back when you do. ;)
I love it when tutorials start with the result you'll get, so:


You can download the resource files hereNow, let's get started! :)

1. Specular- and normalmap
Let's begin with the easy part! After you've imported the textures and model, start by making a new material and plugging in the specular- (Lantern_S) and normalmap (Lantern_N)  in their respective slots. Ta-da! Already done with this part.

2. Diffuse
To make the lantern easy to customize, I made a plain base texture that can be combined with symbols and colors, like this:


Just add a Multiply node and plug in the symbol texture and the base texture (Lantern_D). I made the symbol texture a parameter, so you can easily change it in a material instance. Then take that result and plug it in another Multiply node, together with a Constant4Vector (a color, so to say). Again, parameters are your friends! Plug the result into the diffuse slot and you're ready.

3. Basic emissive with a switch
First, take the result from the diffuse and multiply it with the mask texture (Lantern_Mask). For the "on/off switch", plug the result in another Multiply node and attach a constant, and make it a parameter. Like my comment says "0 for no emissive, 1 for emissive". With this, you can also make lanterns that are not on!


4. Some tweaks
I felt that the light wasn't bright enough, so I added a Brightness parameter (just a Constant). Multiply it with the result from the diffuse and then plug it in like in the previous step.
Another tweak I made is the possibility to desaturate the mask, as it doesn't look good with blueish lanterns. Just add a Desaturate node and a constant parameter. Attach the mask to the first slot and the constant to the second, and plug it in again. For the constant: 0 is full color, 1 is grayscale.


5. Make it flicker!
Okay now, pay attention! ;) You will need to add a new Multiply node, attach the result from the diffuse and then plug it in to the previous Multiply node (where the diffuse result originally was). In the other slot, you can insert the flicker texture. In that texture, attach a Panner. You can play a bit with the values, but mine were around 0.01.



Normally, your lantern should already flicker now, but every lantern has the same flicker pattern. To solve this, I attached an Object World Position node to a Mask (RG) and plugged it in to the Panner Coordinate.
The next step isn't really needed, but if you want to be able to easily change the flicker speed, copy the nodes on the image: Multiply a Constant (parameter!) with the Time and plug it in the Panner's Time.

6. Done!
This is how the material looks! ;) Make some Material Instances, play around with values, and have fun! :) Good luck!


If there's anything unclear, feel free to let me know in the comments.
You can use my resources for non-commercial purposes, but please give credit ;) If in doubt, send me an e-mail. Hope you liked it! :)

Greets,
Marcia

No comments:

Post a Comment