Search public documentation:
UE3 Home > DirectX 11 in Unreal Engine 3 > Image Based Reflections
UE3 Home > Materials & Textures > Image Based Reflections
UE3 Home > Materials & Textures > Image Based Reflections
Document Changelog: Created by Daniel Wright.
Image based reflections is a feature of the DirectX 11 rendering pipeline in Unreal Engine 3. This technique is used to render realtime whole scene HDR reflections in the GDC 2011 Samaritan demo. The technique works by reflecting an approximate version of the scene at each pixel, which makes it more efficient than previous reflection techniques, such as scene captures. The approximate version of the scene is made up of 4 main components:
- ImageReflectionActors (Textured quads)
- Lights with bUseImageReflectionSpecular enabled
- Coarse static shadowing from opaque surfaces
- Dynamic shadowing from dynamic objects, reflected about a ImageReflectionShadowPlane
AllowImageReflections and AllowImageReflectionShadowing must be set to True in your game's engine ini. Then enable bUseImageBasedReflections on the materials you want to reflect, and place some ImageReflectionActors's so there is something being reflected.
- Add some static meshes or BSP
- Create a new material, connect a Constant node with a value of 1 to the Specular input, change bUseImageBasedReflections to enabled, assign this to your scene's meshes
- Make sure the editor is in Lit mode, it will switch to Unlit automatically if there are no lights, and then the reflections won't show up
- Drag and drop an ImageReflectionActor from the Actor Classes tab on top of the geometry you have placed
- Align the camera so that you can see the reflection. By default ImageReflectionActor's are one sided so you may have to rotate the camera around to the other side to see the reflection.
Image based reflections have the following feature set:
- HDR reflections
- Any surface can reflect, not limited to a plane or point.
- Varying glossiness across a surface is supported. This is useful for things like a wet road where a puddle will have a mirror reflection, and the rest of the road will have a glossier reflection.
- Anisotropic glossiness - reflections are streaked more in one direction
- Dynamic components - all parts of the reflection except the static shadowing can be changed at runtime
The following material properties affect image reflections:
- bUseImageBasedReflections - enables or disables image reflections on this material
- ImageReflectionNormalDampening - dampens the normal used by image reflections. This is useful because wet surfaces tend to have a bumpier normal for bouncing diffuse lighting, and a smoother normal for specular reflections. Larger values make the normal smoother (more like the underlying vertex normal) and a value of 1 means no dampening at all, use the supplied Normal directly for reflections.
- SpecularColor - Scales the reflection contribution
- SpecularPower - Controls material glossiness
ImageReflectionActors are the most basic element of the scene that is reflected with image based reflections. These define a textured quad with a few other properties:
- bEnabled - whether the reflection is enabled or not. This can be controlled through a Matinee toggle track.
- bTwoSided - whether the reflection will be seen from both sides
- ReflectionColor - RGB tints the ReflectionTexture values, A controls brightness. This can be controlled through a Matinee LinearColor track.
- ReflectionTexture - texture that will be applied to this quad in the reflection
- Size must be 1024 * 1024
- Format must be DXT5
- Texture group must be TEXTUREGROUP_ImageBasedReflection. This texture group has special mip generation settings that blur the mip maps so that they do not appear blocky when magnified.
- DepthRange - controls the world space depth range that will be captured into the texture. When selected, a wireframe box shows how big the current range is.
- ColorRange - used to pack HDR source values into the LDR generated texture. The default is 4, meaning that the largest color value that can be represented in the captured texture is 4.
WorldInfo has some properties that allow specifying reflections coming from an infinitely distant hemisphere over the level. This is useful for adding some ambient reflections that appear that they are coming from the distance, and to bring out the detail that the shadowing methods provide.
- ImageReflectionEnvironmentTexture - Panoramic environment texture for image reflections. The texture should be laid out so that the horizon is along the bottom (v = 0) and straight up in world space is along the top (v = 1). The u direction of the texture then corresponds to rotation around the Z world axis.
- ImageReflectionEnvironmentColor - Color to be multiplied against ImageReflectionEnvironmentTexture, alpha controls brightness.
- ImageReflectionEnvironmentRotation - Angle to rotate the environment texture around the world Z axis, in degrees.
Lights have a new property called bUseImageReflectionSpecular. When enabled, their light will be reflected in a way that provides:
- Long, streaky highlights like you typically see on a rainy night
- Highlights that are not clamped to the influence radius of the light
- Energy preserving specular (glossier areas have a dimmer reflection, mirror-like areas have a brighter reflection)
Shadowing of the reflections is required to prevent light leaking. The primary method for shadowing the reflections is a precomputed method from the scene's opaque, static surfaces, which is generated by Lightmass during a lighting build. To use these shadows, enable bEnableImageReflectionShadowing in WorldInfo, make sure you have a lightmass importance volume surrounding the area that you want shadowing for, and build lighting. You can exclude individual objects from shadowing the reflections by disabling bCastStaticShadow on the component. Simple scene showing how static shadowing operates. Shadow penumbra size is dependent on distance from the reflection point and material glossiness.
Movable actor types (InterpActor, SkeletalMeshActor, etc) won't be included in the static shadowing method, so they will appear to float above the ground. The only dynamic shadowing supported for reflections is through a planar reflection, which you specify by placing and aligning a ImageReflectionShadowPlane actor. The most common use case for this is to place the plane at the ground. On the left, the scene without any dynamic object shadowing. On the right, a ImageReflectionShadowPlane has been aligned with the road and the dynamic objects are now grounded.