Promotiraj s'rv'r
11 lines 5.5 KiB Markdown Source Rendered Raw Permalink History
---
title: "Lighting a CS 1.6 Map (light and light_environment)"
excerpt: "How GoldSrc lighting works: point lights, spotlights, the single light_environment sun tied to your sky, texture lights, and why hlrad bakes it all into lightmaps at compile time."
category: "mapping"
tags: "lighting, rad"
image: ""
read_time: "8 min read"
---
<p>Lighting in a GoldSrc map is not real-time &mdash; it is <strong>baked</strong>. The <code>hlrad</code> compile stage calculates how light bounces around your level and writes the result into lightmaps stored in the BSP. That means every lighting change requires a recompile, and it means a map with no light entities compiles <em>fullbright</em>: flat, shadowless, and obviously unfinished. This covers the entities you place and how they interact. It assumes you can already compile with <a href="/tutorials/zhlt-vhlt-compile-parameters">ZHLT/VHLT parameters</a>.</p><h2>1. The light entity (point light)</h2><p>The workhorse is <code>light</code> &mdash; a point that emits in all directions. Its key values:</p><pre>classname   light
_light      255 255 200 300   // R G B brightness
</pre><p>The first three numbers are the colour (0&ndash;255 each), the fourth is brightness. Warm interior light might be <code>255 200 150</code>; a cold fluorescent <code>200 220 255</code>. Place a <code>light</code> under each lamp, in each room that needs fill, and anywhere a dark corner needs lifting. Brightness falls off with distance, so a big room needs several.</p><h2>2. The light_spot (directional cone)</h2><p><code>light_spot</code> emits a cone in a direction &mdash; a spotlight, a downlight, a lamp with a shade. Beyond the colour/brightness of a <code>light</code>, it adds a direction (aim it with the angle or a target) and inner/outer cone angles that control the hard and soft edges of the pool. Use it for focused pools under fixtures where an omni <code>light</code> would spill everywhere.</p><h2>3. The light_environment (the sun)</h2><p><code>light_environment</code> is the outdoor sun and skylight, and there must be <strong>exactly one per map</strong>. It works together with your <code>sky</code>-textured brushes: <code>hlrad</code> casts sunlight <em>through</em> every sky-textured face into the level, so wherever the player can see the skybox, sunlight falls in. Its keys set the sun colour/brightness, the <em>pitch</em> (how high the sun sits) and the <em>angle</em> (compass direction the light comes from), plus a separate ambient skylight colour for the diffuse fill in shadow. One <code>light_environment</code> plus sky brushes gives you directional sun and soft ambient in a single entity.</p><h2>4. Texture lights (surfaces that glow)</h2><p>Any texture can be made to emit light via the <code>lights.rad</code> file that <code>hlrad</code> reads &mdash; you list a texture name and an RGB+brightness, and every face using that texture becomes a light source. This is how ceiling light panels, glowing screens, and neon signs illuminate a room realistically, because the light comes from the whole surface rather than a point. It is the cleanest way to light large flat fixtures.</p><h2>5. Let hlrad bounce the light</h2><p>The reason baked lighting looks good is radiosity: <code>hlrad</code> bounces light off surfaces so a bright floor lifts the walls above it. Higher-quality <code>hlrad</code> settings (more bounces, finer sampling) give softer, more realistic results at the cost of compile time. During iteration, run fast/low-quality RAD to preview placement; do a full-quality RAD only for the final compile. Every change to any light entity means re-running RAD &mdash; nothing about lighting updates without a recompile.</p><h2>6. Avoid fullbright and pure black</h2><p>Two failure states bracket good lighting. <strong>Fullbright</strong> (everything evenly lit, no shadows) means <code>hlrad</code> found no lights or was skipped &mdash; add at least one light entity and run RAD. <strong>Pitch black</strong> areas mean no light reaches there &mdash; add fill lights or raise the ambient on the <code>light_environment</code>. Aim for contrast with detail visible in the shadows, not crushed black.</p><h2>Common errors</h2><ul><li><strong>Map is fullbright</strong> &mdash; no light entities exist, or <code>hlrad</code> did not run. Add lights and run the RAD stage of the compile.</li><li><strong>Outdoors is dark despite a sun</strong> &mdash; the sky brushes are not textured with the <code>sky</code> texture, so sunlight has nowhere to enter, or you have no <code>light_environment</code>.</li><li><strong>Weird double shadows / no sun direction</strong> &mdash; more than one <code>light_environment</code>. Delete extras; there must be exactly one.</li><li><strong>Lighting looks flat and blotchy</strong> &mdash; you ran fast/low RAD. Do a full-quality RAD for release.</li><li><strong>Changed a light but nothing updated in-game</strong> &mdash; you did not recompile. Lightmaps are baked; re-run the compile.</li></ul><h2>Verification</h2><p>Compile with a full RAD pass and load the map. Confirm nothing is fullbright, that outdoor areas under sky brushes get directional sun with soft ambient in shadow, and that interior lights cast believable pools with visible detail in the darker corners. Walk the whole map for pure-black spots and add fill where needed. If the outdoors is dark, check that your skybox brushes use the <code>sky</code> texture and that you have one working <code>light_environment</code>. For sky and sun specifics, see <a href="/tutorials/light-environment-and-sky">light_environment and sky</a>.</p>