You copied the Doc URL to your clipboard.

Combining reflections from a distant environment

When you render reflections from static and dynamic objects, you might also have to consider reflections from a distant environment. For example, reflections from the sky that are visible through a window in your local environment.

In this case you must combine three different types of reflections:

  • Reflections from the static environment using the local cubemap technique.

  • Planar reflections from dynamic objects using the mirrored camera technique.
  • Reflections from the skybox using the standard cubemap technique. The reflection vector does not require a correction before fetching the texture from the cubemap.

To incorporate the reflections from a skybox, use the reflection vector reflDirWS to fetch the texel from the skybox cubemap. Pass the skybox cubemap texture as a uniform to the shaders.

Note

Do not apply a local correction.

To ensure the skybox is only visible from the windows, render the transparency of the scene in the alpha channel when you are baking the static cubemap for reflections.

Assign a value of one to opaque geometry and a value of zero where there is no geometry, or the geometry is fully transparent. For example, render the pixels corresponding to the windows with zero in the alpha channel.

Pass the skybox cubemap _Skybox to the shaders, as a uniform.

In the fragment shader code in Combining reflections shader implementation, look for this comment:

// Lookup the planar runtime texture

Insert the following lines before the comment:

float4 skyboxReflColor = texCUBE(_Skybox, reflDirWS);
staticReflColor = lerp(skyboxReflColor.rgb, staticReflColor.rgb, staticReflColor.a);

This code combines the static reflections with reflections from the skybox.

The following figure shows combining different types of reflections:

Figure 5-31 Combining different types of reflections


Was this page helpful? Yes No