This article's documentation is for anything that uses the Source engine. Click here for more information.

HDR Lighting Settings

From Valve Developer Community
Jump to navigation Jump to search
English (en)中文 (zh)Translate (Translate)

Overview

This article explains some of the more advanced techniques that can be used with HDR lighting. See HDR Lighting Basics for a description of the standard HDR methods.

Add a Custom env_tonemap_controller

Use a logic_auto to set env_tonemap_controller values. Click to enlarge.

Our example map also contains the entities to demonstrate the HDR effects. The first entity that needs to be placed is an env_tonemap_controller. This entity can control the HDR settings in the map and allows us to override the default HDR values. Go ahead and name it tonemap.

Now we can trigger this entity a couple of ways, here we show a logic_auto entity that was used to set the settings on level spawn. The Inputs on env_tonemap_controller that are of interest are:

SetAutoExposureMax
Sets the brightest level the exposure will go.
SetAutoExposureMin
Sets the darkest level the exposure will go.
SetBloomScale
Sets the bloom scale in the level.

Important Note

If the level is using an env_tonemap_controller, console commands used to change HDR values cannot be used directly. Instead, the env_tonemap_controller entity inputs must be fired to change the settings. This can be done via standard entity I/O or using the ent_fire command with the following format:

ent_fire <env_tonemap_controller name> <input name> <new value>

For example, if your env_tonemap_controller is named tonemap_global, you would use the following commands:

ent_fire tonemap_global SetBloomScale 3
ent_fire tonemap_global SetAutoExposureMax 6
ent_fire tonemap_global SetAutoExposureMin .8

Adding a Triggerable env_tonemap_controller

You can also use triggers to set env_tonemap_controller values. Click to enlarge.

The env_tonemap_controller can also be triggered with a trigger_multiple. Here we see a trigger that changes the HDR values when the player enters the house. We state that this is single-player only because if these values change they would change globally affecting all players.

Note.pngNote:Because the env_tonemap_controller affects all clients, triggering them in this way is generally only suitable for single-player games.

Adding Different Lighting Values for LDR and HDR Modes

Separate HDR values can be set for light_environment entities. Click to enlarge.

All entity lights and texture lights using lights.rad have the ability to contain two sets of lighting for LDR + HDR. In general, HDR lighting needs to be slightly less intense than the LDR values for a couple of reasons. Firstly, HDR has auto exposure to compensate for the darker areas and brighten the spaces. Secondly, bloom effects have the tendency to over-brighten certain surfaces, so toning down the light values also helps in this regard.

Environment Lights

Here is a screenshot of the light_environment entity with the HDR settings. The default values for BrightnessHDR and AmbientHDR are (-1, -1, -1, 1), which means to use the same settings as LDR. To change the HDR values, just enter your new values into these fields.

HDR Texture Lights

Separate HDR values can be set for texture light using lights.rad. Click to enlarge.

The lights.rad file, which controls "texture" light values, also allows for an independent HDR setting. The highlighted numbers above shows how the 2nd set of 4 numbers apply to the HDR values (R, G, B, intensity), if a 2nd set of numbers isn't entered vrad will use the LDR settings by default.

Other Lights

Other types of Source lights, including light and light_spot, also have HDR values. You can set the HDR values for these lights in the same way you set the light for light_environment entities.

More HDR Console Commands

Here is a list of commands that can be used at the console to dynamically edit your HDR settings in the engine.

Cvar/CommandParameters or default valueDescriptorEffect
mat_dynamic_tonemapping10 disables, 1 enablesEnables or disables dynamic (automatic) HDR tonemapping.
mat_autoexposure_max2Float 0–20Sets the brightest (maximum) exposure that will be reached. Values over 20 should not be used in most cases.
mat_autoexposure_min0.5Float 0–20Where 0 is darkest (minimum) exposure level that will be reached. Values over 20 should not be used in most cases. Typical values are less than 1.
mat_hdr_tonemapscaleFloat 0–20For use when mat_dynamic_tonemapping is set to 0 (off). Sets a single explicit exposure setting. Values over 20 should not be used in most cases.
mat_disable_bloom10 disables, 1 enablesDisables blooming.
mat_bloomscale1Float 0–16Sets the amount (scale) of HDR blooming. Higher values equal more blooming. Values beyond 16 should not be used in most cases.

See also