Static Cubemap creation and real-time reflection

To create a reflection of the live scene requires feeding a camera view from six different angles to a Material on an object, such as a screen or water surface. The first way to do this is by creating a Cubemap (which is static) and the other is by creating a RenderToTextureCube (which works in real time). A RenderToTextureCube is an extension from the single surface 2D RenderToTexture asset, which is good for security camera footage and portals.

Getting ready

Open the scene Packt_09_ReflectProces_Start.UDK, which shows an energy chamber.

How to do it...

  1. Open the Content Browser and switch to the Actor Classes tab. Look in the list for Uncategorized | SceneCaptureCubeMapActor (or else uncheck the Show Categories checkbox and look in the list under SceneCaptureActor | SceneCaptureCubeMapActor).
  2. Highlight this and right-click in the middle of the scene and choose Add SceneCaptureCubeMapActor Here. A big black ball will appear and you'll need to place it in the room so it doesn't overlap the floor, ceiling or walls. Expand the properties of this actor to show: SceneCaptureActor | SceneCapture | Capture | TextureTarget which requires a Texture entry. Lock [ How to do it... ] the properties, then in the Content Browser right-click and choose NewTextureRenderTargetCube. Call it Yourfolder.Texture.RoomCube.
  3. Set 512 as the Size X amount. Turn off Needs Two Copies (which saves memory, as in this case you don't need two). ForcePVRTC4 can be left unchecked for this example (it doubles the size of the texture). Highlight this new asset in the browser, then back in the properties of the scene actor that was pinned, assign the highlighted asset to the Texture Target channel. The ball should update.
  4. You don't really have to adjust the default properties to get a result, but you may want to mouse-over each to get a description of its purpose and experiment with changing them, in particular the Max View Distance Override, which sets how far from the actor the reflections will be shown. If you change the View Mode to SceneCapView_Lit then it will get more of a contribution from scene lighting. Similarly, if you tick Enable Post Process and then tick Use Main Scene Post Process Settings, the reflections will take into account bloom and focal blur if there's any in the environment.
    How to do it...
  5. Right-click on the generated asset in the Content Browser and choose Create New Static Texture. This will render out six views based on the scene actor position and compile them into a static TextureCube (it won't update). Name it Yourfolder.Texture.RoomCube_Result.
    How to do it...
  6. Besides generating the Cubemap, you can use real-time capture in a Material too. Create a new Material, Yourfolder.Material.ReflectCubeTest and within it, right click and choose Texture | New TextureSampleParameterCube. Set its Parameter Name property to Cube, just to shorten it. In the Texture channel, assign the TextureRenderTargetCube asset you created. Be sure not to confuse this with the static TextureCube.
  7. Right-click and choose Vector | New ReflectionVector and hook this into Cube's UVs input.
  8. Right-click and choose Utility | New LightmassReplace, then hook Cube to it. This can connect to the Diffuse and/or Emissive channels.
    How to do it...
  9. Compile the Material, save your package, and assign the Material to a new StaticMesh placed in the scene in the middle of the floor.
  10. In the scene there is a Matinee driving a platform which drops down. You should see the reflection of this movement in the StaticMess actors Material when you PIE. An example is provided: Packt_09_ReflectProcess_DEMO.UDK. This uses a slightly more complex iteration of the Material, which blends in a base texture and creates more of a glossy coating effect: Packt.Material.ReflectProcessSpecular. It is a little bit like the pumping up of specular suggested in the documentation for simulated HDR: http://udn.epicgames.com/Three/MaterialExamples.html.

There's more...

Image based reflections and Material usage

The Cubemap that we generated can be used in many ways. It is also possible to directly use real-time capture from a 2D scene actor (for creating a mirror for example) where the reflection must be updated live. The Material Editor sequence for this using a 2D capture is provided by Epic Games (in their Gems): http://udn.epicgames.com/Three/rsrc/Three/DevelopmentKitGemsCreatingDistortedReflection/07_MirrorMaterialLayout.jpg.

As it happens, there is now a new process for this sort of situation, called an Image Based Reflection , which uses its own actor type, an ImageReflectionActor , described at http://udn.epicgames.com/Three/ImageBasedReflections.html. Our next recipe discusses this process.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.31.206