Вы находитесь на странице: 1из 10

UDK SUN

Page |2

CHAPTER 01
Introduction

Hello everyone, my name is Julio Juarez and I will be walking you through the process of creating a sun using the material editor inside UDK. The advantage of using this technique is that this feature can be added to any sky dome material you have previously designed. I'm not going to explain how to make the sky dome or material for it, but I will cover how to add a sun to previously designed materials, and explain how to use it.

For more information on how to create a sky dome and its initial material please visit 3DBrushwork.com/tutorials for more information.

3DBrushwork.com

Page |3

CHAPTER 02
Adding the Functionality

For simplicity sake, I'm going to use the same material that was made on a previous tutorial (UDK Animated Sky dome). You can do the same, or open a previously designed material of your own.

Add the following nodes in the material editor workspace: one 'Camera Vector' node, one 'Light Vector', and one 'Dot' node.

Connect the nodes as seen in screenshot. These three nodes will make sure that the lighting information gets accurately calculated when generating the sun disc.

3DBrushwork.com

Page |4 Then we will need to add: One 'multiply' node and one 'constant' node (shortcut '1' and clicking on an empty space).

Connect the nodes as seen in screenshot. To control the color and limit the size of the sun disc we need: One 'vector parameter' node, one 'constant' node, one 'scalar parameter' node, one 'multiply' node, and one 'sphere mask' node.

Connect the nodes as shown in the screenshot. Select the 'Sphere Mask' node and in its parameters, change the 'hardness percent' to '0'. Select the 'vector parameter' and In its settings change the parameter name to 'Sun_Disc_Color', and set the default values to R:8 G:6 B:2. Then select the 'scalar parameter' node that is connected to the 'radius' input of the 'sphere mask' and in its settings change

3DBrushwork.com

Page |5 the parameter name to 'Sun_Disc_Size', and change its 'default value' to '0.01' for now. Finally, select the 'Scalar' node that is connected to the 'b' input of the 'sphere mask' node and change its default value to '1'. Go ahead and plug in the results of the last 'multiply' node to the 'Custom Lighting' channel. Also make sure that on the material properties the 'Lighting Model' is changed to 'MLM_Custom'.

Apply the changes to the material. Currently, the sun disc responds to the position of your directional light source. Yet it's very sharp, the next step is to add a rim/glow that will soften the effect.

NOTE: If you can't see the sun on the sky dome, please visit chapter 4 for reference.

3DBrushwork.com

Page |6 To add the glow around the sun disc we need to copy and paste several of the nodes, then edit their parameters. Copy and paste the nodes that are shown in the following screenshot:

Connect the nodes as shown in the screenshot. Select the new 'vector parameter' node and change the 'parameter name' from 'Sun_Disc_Color' to 'Sun_Glow_Color' and set a temporary color. Now select the new 'scalar parameter' and in its settings change the 'parameter name' from 'Sun_Disc_Size' to 'Sun_Glow_Size'. Important to note that the 'multiply' node is also connected to input 'a' of the new 'sphere mask' node.

Connect the previous results to a new 'add' node.

3DBrushwork.com

Page |7

Go ahead and plug in the results of the last 'add' node to the 'Custom Lighting' channel.

This is a screenshot of the network, results are plugged in to the 'custom lighting' channel. Save material and package. Download High Resolution Screenshot Here

If you haven't done so before, right click on the material on the content browser, and select 'create new material instance (constant)'. Give it a name, and hit 'ok'. Then apply the newly created instance to your sky dome static mesh.

3DBrushwork.com

Page |8

CHAPTER 03
Using the Material
Don't be alarmed if you see two suns on your sky dome, that means that multiple lights are affecting it. The only thing we need to do is make sure only one light affects it via 'lighting channels'.

Select your sky dome and go to its properties (F4). Expand 'static mesh actor', then 'static mesh component', expand 'lighting', and under the 'lighting channels' check 'skybox' and uncheck 'static'. This will make sure no lights will affect it, only lights that have the 'skybox' lighting channel enabled. Sun will most likely disappear for a second.

3DBrushwork.com

Page |9

Now select the light that will be you're primary light, and go to its 'lighting channels' and check 'skybox'. This will fix the issue with multiple sun discs.

Now the fun part! Feel free to play around with the customizable settings we created for the material instance to create entirely different sun looks in a matter of seconds. Important things to note about the Material Instance. 'Sun_Disc_Size' and 'Sun_Glow_Size' use really small numbers, so anything above '.01' will produce a very large sun. 'Sun_Disc_Color' most of the time will be above the value of 1, for the exception if creating moonlight, or lighting from a planet.

3DBrushwork.com

P a g e | 10

CHAPTER 04
Troubleshooting
Why can't see the sun disc when I apply the material? A reason for that could be that 'MLM_Custom' was not chosen as the lighting model within the material properties. I can see the sun disc, but it doesn't move with the directional light. Check if the sky dome static mesh 'accepts lights', and that the 'lighting channels' are set correctly (see chapter 3). Sun is not giving out rays of light. Make sure 'light shafts' are enabled on your main directional light, which is the same light that would be producing your sun disc.

For any more questions our inquiries please e-mail me at: Julio@3dbrushwork.com Thank You.

3DBrushwork.com

Вам также может понравиться