UDN
Search public documentation:
ExampleMapsAdvLighting
日本語訳
Interested in the Unreal Engine?
Visit the Unreal Technology site.
Looking for jobs and company info?
Check out the Epic games site.
Questions about support via UDN?
Contact the UDN Staff
Interested in the Unreal Engine?
Visit the Unreal Technology site.
Looking for jobs and company info?
Check out the Epic games site.
Questions about support via UDN?
Contact the UDN Staff
Advanced Lighting Tutorial
Document Summary: A useful guide to performing some tricks with lighting in Unreal. Best for advanced users, since knowledge of many aspects of the engine is a requirement. Document Changelog: Last updated by Michiel, style changes and what not. Previous update by Tom Lin (DemiurgeStudios?), for document summary. Original author was Jason Lentz (DemiurgeStudios?).
Introduction
This document assumes that you know the fundamentals of using Lights, Projectors, Static Meshes, Particle Systems, and Materials. In the example map are demonstrations as well as explanations on how to create various lighting effects mostly using some combination of the actors listed above. In the example map, the effects are divided into indoors and outdoors effects. Inside you will find triggerable fluorescent lights, neon lights, caution lights, light beams through a window, and moving lights through grates. Outside you will find trees with moving canopy shadows and beams of light, wavering torch lights, volumetric ground frog, water caustics, and rolling clouds. Within the document though, these effects are categorized by how they are created. You will need the UDN content for some of the examples.Projectors + Shaders
Tree Canopy Shadows
You can use projectors to create realistic shadows and depending on the type of shadow you are creating will obviously effect the type of projector you will create. In this section you will see how to create a shadow for a single tree as well as for a forest of trees.Single Tree Shadow

bShadowCast
and bAcceptProjectors
to False
. Then to create the Projector Texture here are a few steps to quickly creating an accurate shadow texture:
- Set up the tree in the level that is relatively free of other near by StaticMeshes (you can use groups to hide them)
- Set the texture of the tree bark to black (this is only temporary)
- Turn off the terrain in the perspective viewport
- Set the viewport mode to BSP Cuts
- Position camera view at the angle of the sun and take a screen shot into a power of 2 sized image

- Select all of the white (non tree) and delete
- Desaturate the image
- Paint over where the leaves cover the bark with solid black
- (This will create a solid shadow where the trunk should be casting one)
- Apply a Gaussian blur to the image
- Create a layer of grey (RGB values: 127, 127, 127) behind the shadow layer
- Save and import the texture into Unreal Ed


Forest Canopy Shadow

- Turn off the terrain in the perspective viewport
- Set the viewport mode to BSP Cuts
- Orient the camera over the trees of your forest and grab a screenshot into a power of 2 sized image
- Select all of the white (non tree) and delete
- Desaturate the image in Photoshop
- Apply a Gaussian blur to the image
- Create two layers of grey (RGB values: 127, 127, 127)
- Set one layer above the shadow layer with 50% opacity
- Leave the other layer at 100% opacity and set it behind the shadow layer
- Now around the edges create a 127, 127, 127 grey border that blends to the center
- This makes the edge seams less noticeable.
- Save and import the texture into Unreal Ed

Ground Fog
Note: the ground fog projectors may flicker in older builds.

TR_ConstantlyRotating
with a Yaw Rotation of 1000 for a subtle rotation. Then use the U and V Offsets to center the rotation about the center of the image (1/2 the dimension of the base texture).
For the projector properties, you will want to set them as follows:
- Projector -
-
bClipStaticMesh
:True
This will cause the projector to cast only on the bottom portion of meshes that protrude through the ground fog. If you have BSP protruding through the ground fog, you will also want to setbClipBSP
toTrue
. -
bGradient
:True
this will allow the projection to gracefully fade out at the edges of the ground fog. -
FOV
: will vary You will want to play with this setting some, but essentially, you want a LARGE setting for this value (between 150 and 179). The FOV for the ground fog in this example map is set to 160. -
FrameBufferBlendingOP
andMaterialBelndingOp
:PB Add
Both Blending Ops should be se to Add because the texture has been made to use black as transparent. -
MaxTraceDistance
: will vary This depends on the depth that you want your ground fog to be. A good measure is to set the Projector at your desired height and then increase theMaxTraceDistance
until it passes through your terrain/ground surface. You can also make the ground fog appear darker by further increasing theMaxTraceDistance
.
-
Rolling Clouds
This effect combines Projector with two material modifiers, a TexPanner and a TexScaler. First you will want to set up your base texture though. Take your cloud texture from your SkyZone then desaturate the image so it is just a gray scale image. After importing the desaturated cloud image back into Unreal Ed, create your TexPanner (which you should be identical to the TexPanner you are using for your sky clouds just using the desaturated cloud image).

ProjTexture
to the newly created TexScaler and place the Projector above your level with its FOV
set to 1. Then increase its DrawScale
and MaxTraceDistance
until the frustum encompasses the entire level. In the example map, the Projector is set to cast its shadows in the same direction as the sunlight; it's a minor touch, but it prevents shadows from being cast on surfaces that are already receiving a shadow from blocked sunlight. You can copy and paste the Rotation settings from the sunlight Movement Properties for a quick and accurate duplication of its orientation.
Wavering Torch Light

LightColor
properties, assign an appropriate color to the light and then tweak the brightness until it looks right.



OscillationRates
as well as different U and V OscillationAmplitudes
to create a more random appearance for the flickering. For both OscillationTypes
you will want to set it to OT_StretchRepeat
. For a final touch, offset the texture halfway in the U direction and a full 256 in the V direction (for a 256x256 texture). This causes the StretchRepeat
to be exaggerated at the top of the texture which in this example is used as the far edge of the torch light.
Now assign the TexOscillator to the ProjTexture of a new Projector. Set its properties as follows:
- Display -
-
DrawScale
: will vary In this example a DrawScale of 0.25 is used to make the projector more manageable and able to be more directly targeted at one specific area without projecting through the floor.
-
- Projector -
-
bClipBSP
andbClipStaticMesh
:True
This will prevent the projection from tiling across BSP and StaticMesh geometry. -
bGradient
:True
Setting this to False will amplify the effect of the flicker and also create sharper edges to your projection, but the flame flicker should be a subtle effect that fades with distance from the light source. -
FOV
:100
You may want to play with this setting, but it will help to distort your flame projection as it appears to cast from the flame source. -
FrameBufferBlendingOP
:PB_Modulate
This should be left at its default setting as it will be Modulating theProjTexture
against the wall and the light casting on the wall from the colored light you set up earlier. -
MaxTraceDistance
: will vary Since Projectors are not occluded by anything you will want to set the MaxTraceDistance so that it does not project onto anything on the other side of the surface that is being lit by the torch.
-
ProjTexture
behind the torch flame. This will cause the Projector to cast on the wall behind the torch as well as on the ceiling.
To improve this effect another similar projector with an inverted ProjTexture
can be created and cast down towards the floor to create the shadow of the torch.
Caustics
Underwater



OscillationRates
are set to 0.2 and 0.3 respecitvely, and the U and V OscillationApplitudes are set at 0.01 and 0.02 respectively. The OscillationType
for both U and V directions is OT_Stretch
. This creates a subtle and irregular waving motion applied to the TexScaler .
Combiner: With a CombineOperation
of CO_Multiply
with the TexOscillator in Material 1 and the base texture in Material 2, this creates a greater sense of depth.
TexRotator" The TexRotationType
is set to TR_ConstantlyRotating
and it is given a rotation of Yaw = 512. This final modifier material creates a sense of movement to the resulting texture making it appear as if the water if constantly flowing by as it reflects and refracts the flowing water.
Again this is not the only way to create a convincing caustics effect. Different materials may be used in different ways to create the effect you are looking for. Try experimenting and see what you can come up with on your own.
Once you've finished creating your caustics Shader, you can apply it to a projector. You will most likely need several projectors unless your underwater area is easily covered by one large square projection. You will want to place the projector below the entire underwater area and point it upwards. Below is a list of the settings you will want to change with explanations as to why.
- Display -
-
DrawScale
: will vary This will vary on the size of your projection. Set it to that it encompasses the entire underwater area.
-
- Projector -
-
bGradient
:True
This will cause the caustics effect gradually fade out towards the edge of the water, avoiding sharp seams along terrain triangles. -
bProjectOnBackfaces
:True
Because you are placing the projector below the terrain pointing up, you will need to set this to true so that the Projector will show up on the Terrain. -
FOV
:1
This projection should not be distorted with a wideFOV
, so by setting it to 1 it will project without any noticeable distortion. -
FrameBufferBlendingOP
:PB_Modulate
This will multiply the color of the projector on to the surface of the terrain allowing it to brighten any color values of the projector over 127 and darken any color values of the projector under 127. -
MaxTraceDistance
: will vary This value will also depend on the size of your underwater area. After you've placed your projector(s) just below the lowest point of your underwater area, set theMaxTraceDistance
so that the projector projects just up to the surface of the WaterVolume.
-
Above Water

bProjectOnBackfaces
must remain at False so that the caustics do not cast through the bridge and appear on the top side. Below is a list of the settings you will want to change from the underwater projector with explanations as to why:
- Display -
-
DrawScale
:1
This setting should remain at the default setting of 1 and you can use the FOV to make the Project cast an appropriately sized projection.
-
- Projector -
-
bGradient
:False
Because you want the project to project evenly on the entire underside of the bridge, you can leave this setting at its default value ofFalse
. If set toTrue
, the projection may not even show up at all in parts. -
bProjectOnBackfaces
:False
As mentioned earlier, this should be left at the default setting so as to avoid projection on to the top side of the mesh. -
FOV
: will vary Play around with this setting so that it displays only on the exposed underside of your mesh. An FOV that is too large may end up causing the projector to cast on triangles of the topside of the bridge that are facing downwards. -
MaxTraceDistance
: will vary This value will also depend on the size of you're the mesh you are casting on. You will want to also play with this value in conjunction with theFOV
setting. Be careful not to set it too far so that you don't end up projecting onto the top side of your StaticMesh.
-

Projectors + Emitters
Light Beam through Window

UClampMode
and VClampMode
to TC_Clamp
.

- Projector -
-
FOV
:1
-
FrameBufferBlendingOp
: _=PB_Add= -
MaterialBlendingOp
:PB_Modulate
-
MaxTraceDistance
has also been decreased to prevent the Projector from showing through into the next room.
To complete the light beam effect you will need a particle system that runs through the Projector. In this example map a Particle System with a fog and a dust emitter is used. Be careful that if you have multiple projectors in your level that you don't have your particle system running through both of them. Currently Particle Systems will disappear if they pass through the frustum of two different Projectors.
Note: This effect may disappear if two Projectors project onto the same particle system with out overlap. This is a known bug with Emitters in conjunction with Projectors in the 2110 build.
Mesh Effects
Tree Canopy Light Beams




bShadowCast
is False
, and bAcceptsProjectors
is False
.
Lastly, orient the light beam to have the same rotation as the sun light with the square plane at the top of the beam. The rotation property can found under the Movement rollout), and then place in the canopy holes and resize accordingly.
Neon Lights

bUnlit
to True.
For the Projector, set the properties as follows:
- Projector -
-
FOV
:1
-
MaxTraceDistance
:32
Or something just larger than the depth of the neon light StaticMesh. -
FrameBufferBlendingOP
:PB_Add
which means that Black will be transparent in the projective texture.
-

LightRadius
and small LightBrightness
(8 and 16 respectively in this example map). These lights are not so much for lighting up the sign, or the surface behind it, but they are for casting a neon glow to anything that nearby or that passes by.
Rotating Caution Light



- Display -
-
bAcceptsProjectors
:False
-
- Events -
-
Tag
: NameOfYourMover
-
- Movement -
-
bFixedRotation
:True
-
RotationRate
: YourRotationSpeed (8192 in this example)
-
- Display -
-
DrawScale
: SetAccordinly The projection should fit within the side of the translucent hull.
-
- Movement -
-
AttachTag
: NameOfYourMover
-
- Projector -
-
bClipBSP
:True
This prevents the projector from tiling on BSP -
bClipStaticMesh
:True
This prevents the projector from tiling across StaticMeshes. -
bGradient
:True
The projection will fade out over distance. -
bProjectOnAlpha
:True
IfFalse
, the projection will be very harsh on the translucent hull, and it will also show up poorly on any other textures with alpha layers. -
bProjectOnBackFaces
:True
This will light up the translucent casing of the caution light. -
FOV
:25
This number is up to the level designer, but 25 was chosen so as to limit the Projector for casting through the floor -
FrameBufferBlendingOP
:PB_Add
(remember that this means your projection will cast black as transparent) -
MaxTraceDistance
: MayVary Set this accordinly to your level
-
Moths Casting Shadows

Special Projectors
Special Projectors can also be added by your programmers depending on what you want. This example shows a FluorescentLight Projector that was added to the UDNContent code. To add this TriggerLight into your build, just copy the "UDNContent.dll" and "UDNContent.u" files into your system folder. You can download these files here. The new classes are explained in this document.Triggerable FluorescentLight Projector

bDymanicLight
the light will cast through geometry hitting surfaces it shouldn't. Without bDymanicLight
though, the light portion of the FluorescentLight Projector will not work.
The fluorescent lights in the example map are set up in the following manner. First of all you will want to create a MaterialSwith material and a MaterialSwitchTrigger for the light texture. To do this import two textures, one for the lights on, and one for the lights off.



