Unreal Development Kit Game Design Cookbook
上QQ阅读APP看书,第一时间看更新

Generating volume from the BSP brush

The BSP brush can be used to generate volumes that cover functionality like defining a spatial zone for something to happen (or not happen) inside. In later chapters we'll be using all kinds of volumes. For now let's choose a simple one, a PostProcess Volume. This volume type effects the coloration and focus of the image seen by the camera. The use of a volume provides a boundary for the effect.

How to do it...

  1. Create a new scene and create a hollow cube, as above, with a pointlight inside it (hold L and click on an interior surface). The repetitive start for the last few recipes will help you get faster at this common process.
  2. Highlight and apply any likely wall Materials from the Content Browser using Apply Material as we did before. You can copy Materials from one surface to another using right-click and choosing Copy then Paste.
  3. Duplicate this room alongside itself by selecting it in the Top viewport and then hold down ALT and move it until the outer walls of the rooms just touch. You can even copy over the PointLight at the same time.
  4. Adjust one of the lights to red, and the other to blue, through its properties (F4). Place each in its own room which was created by the hollow cubes. Scale each PointLight so its decay area (the pale blue circle bounding the light) just covers the room it is inside, so we can see distinct colors bounded to each room.
  5. Subtract a doorway by shaping a new, non-hollow BSP brush in the touching walls then pressing CSG Subtract [ How to do it... ].
    How to do it...
  6. Now reset the BSP cube and move it and shape it to fill the red room's space.
  7. On the left-hand side of the editor, right-click on the Volumes icon [ How to do it... ] (below the CSG icons) and choose PostProcessVolume. This adds a volume where the Builder Brush is. It may not be easy to see, because of the Builder Brush, but it will be selected after its creation. Press F4 to see its properties.
  8. Change the following in Post Process Volume | Settings: first tick on Enable DOF so we can blur the scene, then tick off Max Near, and then tick on Min. Set Min to 20, and set Max to 100. Above, set the DOF_Falloff Exponent to 16. These values blur the volume in a simple way. Don't worry for now about what all the available properties are for. That is discussed in Chapter 8, Then There Was Light! For now, we just want to see a noticeable difference to the normal focus.
  9. Select the floor in the blue room and right click and choose Add Actor | Player Start here. Now you can build [ How to do it... ] and play this little scene (F8). The blue room should be in focus and the red room out of focus. At this stage, if you return to the blue room it will probably also be out of focus now. Once a PostProcessVolume is turned on, leaving the volume won't change the look of the scene back, unless you enter another volume.
  10. To fix that, in the top viewport select the PostProcessVolume you made earlier, and move it while pressing Alt to create a copy of it. Place the copied volume over the blue room. Press F4, then set these properties for it: Tick on Max Near and ensure it is 0. Change Max Far to 16 and DOF_Falloff Exponent to 4. So we have now a ‘no blur' volume to enter.
  11. Build All [ How to do it... ] and press F8. You should observe how both rooms now toggle in and out of focus as you go back and forth. This scene is provided in the book's downloadable content: Packt_01_Volumes_DEMO.UDK.

See also

  • For more on PostProcess features see Chapter 8, Then There Was Light!
  • For more on Materials, see Chapter 9, The Devil is in the Details!