# 3. Worked Example - Grade Damage and a Cave
Part of [[Post-Processing]]. Previous: [[2. URP Effect Catalog]]. Next: [[4. Scripting Volume Overrides]].
> [!note] Verification status
> The Box Volume setup is the official 6000.5 local-volume example. The runtime script uses `Volume.profile` / `TryGet` / `VolumeParameter` patterns that are standard in URP. **Exact Vignette and ChromaticAberration field names** (`intensity`) should be confirmed in your URP version's override — if a field does not compile, open the override in the Inspector and match the Scripting API. **Code not compiled in Unity.**
## 3.1 Three profiles
Create three Volume Profile assets:
| Asset | Overrides | Where it lives |
|---|---|---|
| `Look.Base` | Tonemapping (Neutral), Color Adjustments (slight contrast), Bloom (low, high threshold) | A **Global** volume in the scene, Priority 0 |
| `Look.Cave` | White Balance cooler, slightly lower Color Adjustments "post exposure" / contrast as you prefer, a touch more Vignette | A **Box Volume** around the cave, trigger collider, Blend Distance 2–4 m, Priority 10 |
| `State.LowHealth` | Vignette, Chromatic Aberration; all other overrides left off | A **Global** volume, Priority 100, **Weight 0** until the player is hurt |
Save them under `Assets/Settings/Volumes/`. Do not edit the project-wide Default Volume for this lab; leave it alone so other scenes stay predictable.
Walk the cave in Play Mode and tweak Blend Distance until entering the cave feels like a fade, not a cut. This is the same "place has a mood" idea as lighting ([[Lighting and Baking]]) and audio reverb ([[Spatial Audio and Reverb Zones]]).
## 3.2 Drive low health from code
Put a Global Volume in the scene, assign `State.LowHealth`, start at weight 0. The script below lerps weight with the player's health fraction and also tightens the vignette. It uses a *runtime* profile clone so Play Mode does not dirty the asset (part 4).
```csharp
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
public sealed class LowHealthLook : MonoBehaviour
{
[SerializeField] Volume _volume;
[SerializeField] float _vignetteAtZeroHealth = 0.45f;
[SerializeField] float _chromaAtZeroHealth = 0.3f;
[SerializeField] float _blendSpeed = 3f;
Vignette _vignette;
ChromaticAberration _chroma;
float _target;
void Awake()
{
if (_volume == null) _volume = GetComponent<Volume>();
// .profile returns a runtime clone; .sharedProfile would edit the asset.
VolumeProfile profile = _volume.profile;
profile.TryGet(out _vignette);
profile.TryGet(out _chroma);
if (_vignette != null) _vignette.intensity.overrideState = true;
if (_chroma != null) _chroma.intensity.overrideState = true;
}
public void SetHealthFraction(float fraction)
{
_target = 1f - Mathf.Clamp01(fraction);
}
void Update()
{
if (_volume == null) return;
_volume.weight = Mathf.MoveTowards(_volume.weight, _target, _blendSpeed * Time.deltaTime);
float w = _volume.weight;
if (_vignette != null)
_vignette.intensity.value = w * _vignetteAtZeroHealth;
if (_chroma != null)
_chroma.intensity.value = w * _chromaAtZeroHealth;
}
}
```
Call `SetHealthFraction(current / (float)max)` from your health component ([[5. Worked Example - Inventory and Stats Tests]] has a simple `ActorHealth` you can hook, or use the real stats in [[Stat-Driven RPG Systems]]).
Camera *shake* on hit still belongs to Cinemachine Impulse ([[4. Impulse Noise and Extensions]]), not to a volume. Use both: a short Impulse plus a brief weight pulse.
## 3.3 What the student should notice
- Walking into the cave changes the grade without a unique material on the walls.
- Taking damage reads even if the HUD is hidden (Level 8, "clean screen").
- Overdoing chroma / vignette looks like a bug, not like feel. Cap the values.
## Official docs
- Set up a volume: https://docs.unity.com/en-us/engine/6000.5/manual/post-processing-and-full-screen-effects/urp/volumes-landing-page/set-up-a-volume