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

Adding Light: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
m (minoro)
m (Nesciuse moved page Adding Light/en to Adding Light without leaving a redirect: Move en subpage to basepage)
 
(24 intermediate revisions by 15 users not shown)
Line 1: Line 1:
{{first room menu}}
{{LanguageBar}}
{{Source topicon}}
{{First room menu}}


Now we’ll add some lighting to the room. If no lights are placed, the map will automatically be evenly lit when it is loaded in the game, but setting the lighting will look more realistic. Also, if no lights are placed then the <code>mat_fullbright</code> cvar will be set to 1.  In order to see lighting in a map which was previously loaded in the game without lights then you must either close the game and reopen it, or set <code>mat_fullbright</code> to "<code>0</code>".
Now we’ll '''add some lighting''' to the room. If no lights are placed your map will automatically be lit “fullbright” when it is loaded in the game, but as you’ll have noticed this is hardly ideal. Creating lights will make your map look far more realistic.
{{clr}}
[[Image:hammer_picklight.jpg|thumb|left|200px|Pick the [[light]] entity from the entity list.]]


Lights are entities too.
{{Note|In order to see lighting in a map which was previously loaded in the game ''without'' lights, you may need to open the [[developer console]] and set {{Command|mat_fullbright|0}}.}}


Pick the [[light]] entity from the entity drop-down list in the '''Object Toolbar'''.
# Activate the {{hammer entity}} (lights are entities too) and pick {{ent|light}} from [[:File:Hammer picklight.jpg|the drop-down list in the Object Toolbar]]. This is the most basic light of them all, and it shines all around from an invisible source. Place one in the center of the ceiling now by clicking in the 3D view:<p>[[File:Hammer placelight.png|400px|Place the {{ent|light}}.]]</p>
# We are now going to edit the color and brightness of this light. Switch back to the {{hammer select}}, then double-click on the <tt>light</tt> entity in the 3D View to open the Object Properties dialog. To bring up the settings for the light’s brightness, find and click on the <tt>Brightness</tt> field in the [[Keyvalue]]s list.
# While you could type a color into the new text box directly, it’s better to use Hammer’s built-in dialog by clicking the ''Pick color'' button, just beneath the text box:<p>[[File:Hammer pickbrightness.png|400px|Select the <tt>Brightness</tt> field, then click the ''Pick color'' button.]]</p>
# The ''Color'' dialog will now appear, letting us change the color of the light.
## Change the hue and saturation of the color by clicking in the square color spectrum area on the right.
## Because luminance is set to max, the color will still be white. Lower the luminance to change the color from bright white to something of the hue you picked. You can see how the color changes in the preview square at the bottom of the dialog to something more colorful, instead of white.
## Click the ''OK'' button to confirm your choice:<p>[[File:Hammer setcolor.png|400px|Change the hue/saturation and luminance of the light, then click ''OK''.]]</p>
# We have now set the color of the light, but this has not affected its intensity. The color is described by the first three numbers of the Brightness setting, leaving the brightness value itself as the fourth number. Mark this number (currently <tt>200</tt>) with the mouse, and enter <code>800</code> instead, to have the light shine four times as intensely: <p>[[File:Hammer setcolor800.png|400px|Raise the brightness of the light by increasing this number, then click ''Apply''.]]</p> {{Tip|If you want your light to shine in a different color under [[High Dynamic Range]] lighting, edit the <tt>BrightnessHDR</tt> or <tt>BrightnessScaleHDR</tt> settings. This is generally used to balance out the richer colors that HDR generates.}}
# Now that we’ve made changes to the light’s parameters, hit the ''Apply'' button to commit them. The color of the light’s icon will change to the color you have selected for it.


This is the most basic lighting entity.
== Results ==
When you compile your map, you will see a sphere of light projected onto the walls that is brightest near to your light entity and darkest further away. Remember to disable {{Command|mat_fullbright}} if necessary!


Place the ''light'' entity in the center area of the ceiling by clicking there in the 3D view.
Your light won’t have a visual source, however—it just appears from nowhere. You’ll be able to fix this in the next article.
 
{{clr}}
[[Image:hammer_placelight.jpg|thumb|right|400px|Place the [[light]].]]
 
[[Image:hammer_openprop_sm.jpg|thumb|right|400px|Double-click an object in the 3D View to open the ''Object Properties'' dialog.]]
 
We are now going to edit the characteristics of this light.
 
Switch back to the '''Selection Tool''', and then double-click on the ''light'' entity in the 3D View to open the '''Object Properties''' dialog containing its properties.
{{clr}}
 
[[Image:hammer_pickbrightness.gif|thumb|right|400px|Select the ''Brightness'' field, then click the ''Pick color'' button.]]
 
# To bring up the setting for the ''Brightness'' property of the light, click on the ''Brightness'' field in this dialog.
# To open up the dialog for picking a color, click the ''Pick color'' button just beneath the settings values.
{{clr}}
 
[[Image:hammer_setcolor.gif|thumb|right|400px|Change the hue and luminance of the light, then click ''OK''.]]
 
The ''Color'' dialog will now appear, letting us change the color of the light:
 
# Change the hue color by clicking on the desired color in the large color spectrum area to the right.
# Because the luminance is set to max, the color will still be white, so we'll need to lower the luminance to change the color from bright white to the hue value you picked. You can see how the color changes in the preview square at the bottom of the dialog to something more colorful, instead of white.
# Then Click the ''OK'' button to confirm your color choice.
{{clr}}
 
[[Image:hammer_setcolor800.jpg|thumb|right|400px|Raise the brightness of the light by increasing this number, then click ''Apply''.]]
 
We have now set the color of the light, described by the first three numbers in the ''Brightness'' setting, so what's left is to increase its intensity—how bright it will shine. This is altered manually, through changing the fourth value in the setting.
 
# Mark this number (saying <code>200</code>) with the mouse, and enter <code>800</code> instead, to have the light shine four times as intense.
# Also if you wish to add an [[HDR]] value toward the light copy the Brightness field and paste it at the HDR Brightness field.
# Now that we’ve made changes to the parameters, we need to apply them to the light entity. Hit the ''Apply'' button to commit the changes.
 
The color of the bulb will change to the color you have selected for it.
{{clr}}
 
We are done with these properties now, so close the property dialog by clicking the closing button in the upper right corner.


== See also ==
== See also ==
Line 55: Line 26:
* [[Advanced Lighting]]
* [[Advanced Lighting]]


=== Entity types ===
=== Light Entities ===
* [[light]] - a basic light source.
* {{ent|light}} — A basic, omnidirectional light source.
* [[light_dynamic]] - a light source that can be changed and moved.
* {{ent|light_spot}} — A directed light that shines in a cone.
* [[light_spot]] - a directed light.
* {{ent|light_environment}} — The controller for global light cast from a [[skybox]].
* [[light_environment]] - the controller for light cast from a skybox.
* {{ent|light_dynamic}} — A dynamic light source that can be changed and moved in-game.
 
* {{ent|env_projectedtexture}} — A dynamic light source like a <tt>light_dynamic</tt>, but it can also cast proper dynamic shadows.
{{NavBar|Adding Entities|Your First Map|Adding Prop Models}}


[[Category:Level Design Tutorials]]
{{Navbar|Creating Brush Entities|Your First Map|Adding Prop Models}}
[[Category:Level Design]]
[[Category:Lighting]]
[[Category:Tutorials]]

Latest revision as of 03:58, 12 July 2024

English (en)Français (fr)日本語 (ja)Português do Brasil (pt-br)Русский (ru)中文 (zh)Translate (Translate)

Now we’ll add some lighting to the room. If no lights are placed your map will automatically be lit “fullbright” when it is loaded in the game, but as you’ll have noticed this is hardly ideal. Creating lights will make your map look far more realistic.

Note.pngNote:In order to see lighting in a map which was previously loaded in the game without lights, you may need to open the developer console and set mat_fullbright 0.
  1. Activate the Entity tool Mt-entities.png (lights are entities too) and pick light from the drop-down list in the Object Toolbar. This is the most basic light of them all, and it shines all around from an invisible source. Place one in the center of the ceiling now by clicking in the 3D view:

    Place the light.

  2. We are now going to edit the color and brightness of this light. Switch back to the Selection tool Hammer select.png, then double-click on the light entity in the 3D View to open the Object Properties dialog. To bring up the settings for the light’s brightness, find and click on the Brightness field in the Keyvalues list.
  3. While you could type a color into the new text box directly, it’s better to use Hammer’s built-in dialog by clicking the Pick color button, just beneath the text box:

    Select the Brightness field, then click the Pick color button.

  4. The Color dialog will now appear, letting us change the color of the light.
    1. Change the hue and saturation of the color by clicking in the square color spectrum area on the right.
    2. Because luminance is set to max, the color will still be white. Lower the luminance to change the color from bright white to something of the hue you picked. You can see how the color changes in the preview square at the bottom of the dialog to something more colorful, instead of white.
    3. Click the OK button to confirm your choice:

      Change the hue/saturation and luminance of the light, then click OK.

  5. We have now set the color of the light, but this has not affected its intensity. The color is described by the first three numbers of the Brightness setting, leaving the brightness value itself as the fourth number. Mark this number (currently 200) with the mouse, and enter 800 instead, to have the light shine four times as intensely:

    Raise the brightness of the light by increasing this number, then click Apply.

    Tip.pngTip:If you want your light to shine in a different color under High Dynamic Range lighting, edit the BrightnessHDR or BrightnessScaleHDR settings. This is generally used to balance out the richer colors that HDR generates.
  6. Now that we’ve made changes to the light’s parameters, hit the Apply button to commit them. The color of the light’s icon will change to the color you have selected for it.

Results

When you compile your map, you will see a sphere of light projected onto the walls that is brightest near to your light entity and darkest further away. Remember to disable mat_fullbright if necessary!

Your light won’t have a visual source, however—it just appears from nowhere. You’ll be able to fix this in the next article.

See also

Light Entities

  • light — A basic, omnidirectional light source.
  • light_spot — A directed light that shines in a cone.
  • light_environment — The controller for global light cast from a skybox.
  • light_dynamic — A dynamic light source that can be changed and moved in-game.
  • env_projectedtexture — A dynamic light source like a light_dynamic, but it can also cast proper dynamic shadows.