WiseHDR: HDR - (High Dynamic Range)

From Valve Developer Community
Jump to: navigation, search

This tutorial was originally created by wisemx.

Ported from SDKnuts.net to VDC by: Pinsplash (talk) 07:20, 21 June 2018 (UTC)

(Porter's note: About half of the original tutorial by wisemx was left out of this port because it was basically an exact copy of the HDR Lighting Basics page.)

DOD:S Example

Let’s examine the Source SDK HDR example map from Day of Defeat: Source, step by step. Even if you don't have DOD:S this file is part of the updated Source SDK, you can open it in Hammer with the CS:S parameters. The map is common\sourcesdk_content\dod\mapsrc\sdk_example_hdr.vmf.

light_environment:

  • Pitch Yaw Roll: 0 165 0
  • Pitch: -40
  • Brightness: 250 241 192 600
  • Ambient: 209 227 237 200
  • BrightnessHDR: 250 241 192 500
  • AmbientHDR: 209 227 237 200

Skybox Texture Name: sdk_sky_example_hdr

env_tonemap_controller:

  • Name: tonemap
This entity is give a name so it can be called via inputs. There are 9 inputs in the example env_tonemap_controller. Three of the inputs set the initial HDR exposures when the map starts via a logic_auto. The remaining 6 Inputs are 2 groups of 3 Inputs from triggers.

logic_auto:

  My Output Target Entity Target Input Parameter Delay Only Once
Io11.png OnMapSpawn tonemap SetAutoExposureMax 2 0.00 No
Io11.png OnMapSpawn tonemap SetAutoExposureMin .8 0.00 No
Io11.png OnMapSpawn tonemap SetBloomScale 1.2 0.00 No

The trigger_multiple entites are not needed but are used to illustrate how you can control the HDR exposure during the game.

Walking into the sample building will trigger these:

  My Output Target Entity Target Input Parameter Delay Only Once
Io11.png OnMapSpawn tonemap SetAutoExposureMax 5 0.00 No
Io11.png OnMapSpawn tonemap SetAutoExposureMin 3 0.00 No
Io11.png OnMapSpawn tonemap SetBloomScale 2 0.00 No

Walking out of the sample building will trigger these:

  My Output Target Entity Target Input Parameter Delay Only Once
Io11.png OnMapSpawn tonemap SetAutoExposureMax 2 0.00 No
Io11.png OnMapSpawn tonemap SetAutoExposureMin .8 0.00 No
Io11.png OnMapSpawn tonemap SetBloomScale 1 0.00 No

Notice the height of the env_cubemap inside the sample building. This will often be important when you build cubemaps with the buildcubemaps console command in relation to the height of windows as an example.

Lastly notice the dev reflectivity materials are used. These are great tools for both testing and achieving lighting effects. You can for example use the material dev/reflectivity_30 on a func_illusionary for a light-at-the-end-of-the-tunnel effect, even without HDR enabled.

Final Notes

Open the DOD:S sample map sdk_dod_flash. (In the same folder as the HDR sample.) Notice the 15 info_lighting entities used in this map. These are used to change the lighting origin of a prop_static. To use these simply place an info_lighting in the spot where you want to change the lighting origin for a prop_static. Then in that prop_static set the name of the info_lighting in the Lighting Origin property. Also notice there are only 3 inputs in the env_tonemap_controller for this map. The Exposure Max, Min and Bloom Scale are all set once when the map spawns.