Sub topic 9
Combining an HDRI with Lamps
An HDRI world gives a scene believable ambient light and reflections. Lamps add direction, contrast and control. This chapter explains how to combine them so that shadows and highlights agree, and how to avoid the most common conflicts.
This chapter assumes you can set up an HDRI through the Environment Texture and Background nodes, rotate it and set its strength. It also assumes you know the four lamp types and how power and size affect brightness and softness. Those topics are covered in earlier chapters.
Why combine them at all
An HDRI alone often produces flat or soft results. An overcast sky map has no strong sun, so the subject has no clear shadow. A studio HDRI may have good reflections but put the brightest light in a place that does not flatter your subject.
Lamps fix this. You can add a strong light where you want it, and the HDRI still supplies fill light and reflections.
| Source | Strengths | Weaknesses |
|---|---|---|
| HDRI only | Realistic ambient light, reflections and color mood | Direction and contrast are fixed by the image |
| Lamps only | Full control of direction, size and power | Empty reflections, little ambient bounce |
| HDRI plus lamps | Realistic base plus controlled accents | Shadows can conflict if the two disagree |
The core rule: one dominant light direction
Your eye reads light direction from shadows and highlights. If the HDRI shows a sun at the upper left and your key lamp lights the subject from the right, the subject gets two shadows pointing in different directions. The result looks fake.
Pick one of two strategies.
- Lamp matches the HDRI. Find the brightest spot in the HDRI and place a lamp in that direction. The lamp strengthens a light that already exists.
- HDRI is moved to match the lamp. Keep your lamp where you want it and rotate the HDRI so its brightest region sits in the same direction.
Both strategies give one consistent light direction. The second is usually easier, because the HDRI rotation is a single value.
Finding the light direction in the HDRI
To locate the dominant light in an HDRI, use one of these methods.
- Switch the viewport to Rendered shading and look at the shadows on a simple test object, such as a sphere on a plane. The shadow points away from the main light.
- Look at the reflection on a chrome sphere. The brightest reflected spot marks the direction of the strongest light.
- Open the image in the Image Editor and look for the brightest region. Remember that the image is an equirectangular map, so left and right edges wrap around.
A sphere with a glossy material and another with a matte material are a good test pair. The matte sphere shows shadow direction and softness. The glossy one shows where the highlights land.
Balancing strength
Two numbers decide the balance: the Background node's Strength and the lamp's power.
- Start with the HDRI alone and set its strength so the scene is lit acceptably.
- Add the lamp and raise its power until the lamp's shadow clearly reads as the dominant one.
- If the lamp washes out the HDRI, reduce the lamp power or raise the HDRI strength.
A useful ratio is a key lamp that is clearly brighter than the HDRI fill on the lit side. Contrast between the lit and shadowed sides is what gives the subject form. If both are equally bright, the image looks flat.
You can reduce the HDRI's contribution without changing the image itself. Lower the Background Strength, or add a Math node set to Multiply between the image and the Background node. The Math node approach is useful when you want to drive the strength from a custom property or driver.
Matching color temperature
The HDRI carries a color mood. A morning sky is warm and a clear noon sky is blue-white. A lamp with the default white color next to a warm HDRI looks out of place.
Match them in one of two ways.
- Tint the lamp color toward the dominant HDRI color. For a sunset HDRI, use a warm orange-white.
- Use contrast on purpose. A warm key against a cool HDRI fill is a classic look, because the shadows stay cool while the lit side is warm.
The second approach works only when the contrast is intentional and moderate. Strong opposing colors on every surface look unnatural.
Sun lamps and sky HDRIs
For outdoor HDRIs with a visible sun, a Sun lamp is the natural partner. A Sun lamp is parallel light with a size given as an angle, so it casts shadows with consistent direction.
The real sun in a photographed HDRI is clipped. The camera could not capture its true brightness, so the HDRI itself usually lights the scene with weak, soft-edged shadows. A Sun lamp placed at the same direction restores the sharp, strong shadow the real sun would produce.
Match the Sun lamp's angle to the real sun's apparent size, which is about 0.5 degrees. A larger angle gives softer shadows. If you want shadows that match a hazy sky, increase the angle a little.
Avoiding double lighting
When the lamp and the HDRI both light the same area from the same direction, the sum can overexpose that area. This is a common cause of blown-out highlights.
- If you add a Sun lamp at the HDRI's sun, lower the HDRI strength a little or lower the Sun strength, so the combined light stays reasonable.
- Check the result in the Render view, not only in the viewport. Tone mapping can hide or exaggerate overexposure.
- Compare against a neutral gray test object. The gray surface should not clip to white in the lit area.
Keeping the HDRI out of the picture
Often you want the HDRI light but not the HDRI background. Enable Film Transparent to hide the HDRI in the final image while it still lights and reflects in the scene. Then the background is transparent, and you can composite it over another image. Be aware that reflections of the HDRI remain visible on glossy surfaces, so a mismatched replacement background can still look wrong.
A second option works in Cycles: a Light Path node using the Is Camera Ray output as a Mix factor lets you show a plain color to the camera while the HDRI lights the scene. This also works without transparency.
Scripting the combination
The following script builds on the earlier examples. It rotates the HDRI, then points a Sun lamp in a matching direction. It assumes a World with an HDRI mapping node already exists, as built in the World setup chapter.
import bpy
import math
scene = bpy.context.scene
world = scene.world
# Rotate the HDRI so its bright region faces the chosen direction
mapping = next(n for n in world.node_tree.nodes if n.type == 'MAPPING')
mapping.inputs['Rotation'].default_value[2] = math.radians(135.0)
# Lower the HDRI strength so the lamp can dominate
bg = world.node_tree.nodes["Background"]
bg.inputs['Strength'].default_value = 0.6
# Add a Sun lamp as the dominant key
sun_data = bpy.data.lights.new(name="SunKey", type='SUN')
sun_data.energy = 3.0 # strength in W/m^2
sun_data.angle = math.radians(0.53) # apparent size of the real sun
sun_data.color = (1.0, 0.95, 0.88)
sun = bpy.data.objects.new("SunKey", sun_data)
scene.collection.objects.link(sun)
# Lights shine along local -Z. Rotate the lamp so it points down and along +X/-Y.
sun.rotation_euler = (math.radians(50.0), 0.0, math.radians(135.0))The rotation values here are a starting point. After running the script, check the shadow direction in a render and adjust the Z rotation of either the HDRI mapping or the lamp until they agree.
Common mistakes
- Two clear shadows. The HDRI sun and the key lamp point in different directions. Rotate one to match.
- Flat result. The HDRI strength is too high compared with the lamp. Lower it and let the lamp create contrast.
- Blown highlights. The lamp and HDRI sun add together. Reduce either one.
- Lamp visible in reflections as a wrong shape. An Area lamp reflected in a glossy surface appears as a rectangle. That is correct physically, but check that its shape and position make sense with the HDRI reflection.
- Color clash. The lamp's color is unrelated to the HDRI mood. Tint the lamp or make the contrast deliberate.
Exercise
A scene is lit by an outdoor HDRI whose sun is at the upper left. You add a Sun lamp on the right side. The render shows two shadows on the ground. Give two ways to fix this, and say which is usually simpler.
Show answer
Either move the Sun lamp to the same direction as the HDRI sun, or rotate the HDRI around the Z axis (the Mapping node's Z rotation) until its sun sits in the direction of the lamp. Rotating the HDRI is usually simpler, because it is a single value and does not disturb the lamp placement you chose for composition.
Exercise
After adding a Sun lamp at the same direction as the HDRI sun, the lit side of the subject is clipped to white. List two changes that reduce the clipping.
Show answer
Lower the Sun lamp's strength, or lower the Background node's Strength so the HDRI contributes less light. You can also reduce global exposure, but that darkens the whole image rather than fixing the double lighting.