diff --git a/skills/light-scene/SECURITY.md b/skills/light-scene/SECURITY.md new file mode 100644 index 0000000..c3b78a9 --- /dev/null +++ b/skills/light-scene/SECURITY.md @@ -0,0 +1,18 @@ +# Security notes: light-scene + +This skill has the agent run C# inside the user's open Unity Editor through `unity command script eval`. Automated skill scanners flag that as a powerful capability. It is intentional, and it is limited by the safeguards below. + +## Accepted risks + +| Risk | Capability | Why it is accepted | +|---|---|---| +| `SEC_POWER_CAP` | Runs C# in the user's open Editor through `unity command script eval` | It only reaches the Editor the user already has open, on their own machine, as that user, so it grants nothing they couldn't do themselves. `script eval` sits behind the Pipeline package's capability gate. No code fetched from a remote source is run. The C# changes the scene's lighting and the assets the user asked about, and each change is recorded with Undo. | + +## Mitigations + +- **Only the user's own Editor.** `unity command script eval` talks to the Editor open on this machine. It can't reach another machine or another user's Editor. +- **Capability gate.** `script eval` is only available when the project's Pipeline package provides it. +- **No remote code.** The agent runs C# it writes from this skill's own instructions. Documentation pages it fetches are read as reference and never executed. +- **Undo and a restore point.** The skill makes a restore point before changing the project and records each change with Undo, so the user can roll it back. +- **Shared assets named first.** Before it edits an asset other scenes use, such as a pipeline asset, a Volume profile or a skybox material, the skill names the asset and what else uses it. +- **Scope limits.** The skill does only what the user asked, and obeys any limit the user sets on the work. diff --git a/skills/light-scene/SKILL.md b/skills/light-scene/SKILL.md new file mode 100644 index 0000000..f2e9294 --- /dev/null +++ b/skills/light-scene/SKILL.md @@ -0,0 +1,153 @@ +--- +name: light-scene +description: "Sets up, repairs and restyles the lighting of a Unity scene, from the first lights and bake to a new mood or lighting that changes over time. Make sure to use this skill when a scene needs lighting, or its lighting looks wrong or costs too much." +allowed-tools: WebFetch, WebSearch +required_editor_version: ">=6000.0.0" +metadata: + version: 1.0.0 + documentation: "https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting-configuration-workflow.md" + support: "https://unity.com/support-services" +--- + +# Light a scene + +Set up, fix, restyle, optimize or animate the lighting of a Unity scene: choose the workflow for the request below, read its file in full, and follow it. + +## Important + +- Use the unity cli (`unity command --format json`) and the `unity-cli` and `unity-pipeline` skills for each step. Run C# through the connected Editor with the `script eval` command (`unity command script eval --code ''`). +- Don't use `using` directives or unqualified types in the `snippet` for `script eval`: write `UnityEditor.AssetDatabase` and `UnityEngine.Rendering.Volume`, not `AssetDatabase` and `Volume`. Check that each API you call still exists in this Unity version, because several long-standing members became errors in Unity 6. The [error messages](#error-messages) table gives the fix for each compile error. +- Create a restore point you can roll back to if your changes fail. +- Do only what's asked. Don't change unrelated assets or files, because pipeline, quality and Volume assets are shared by every scene in the project. +- Obey any limit the user puts on the work, over anything this skill says. If they say change nothing, change nothing; if they cap your answer's length, stay under it; if they name one component, answer about that one and say what you skipped. Running ten tools on a question that needed one sentence is a failure even when the answer is right. The same holds the other way: if the user asks for a look these defaults would avoid - an overpowering light, a second sun, clipped highlights - do it, and state the cost in one line rather than pushing back. The defaults here are for when the user has not said. +- Never leave verification code in the user's script. Never build logging or detection they didn't ask for. See [Final step](#final-step). +- Verify any C# you author compiles BEFORE reporting it done, and say how. A non-compiling script blocks everything else in the project from compiling, so an unchecked script leaves the user worse off than nothing. If you cannot compile it, say so and keep it small enough to review by eye. +- Before concluding that the Editor, the render pipeline or a tool is broken, change ONE variable in a minimal probe and look at the render. Such claims - renderers "dropped" by a tool, post-processing "not running", HDR "clipped on the way in" - usually turn out to be a mistake in the agent's own setup: an object on a culled layer, a Volume parameter with `overrideState` off, a project with no Tonemapping override. +- A state read is not evidence that a change landed. An object can exist, be enabled and report correct bounds and still never draw, because the camera's `cullingMask` excludes its layer; a Volume parameter can display the right value and be ignored, because its `overrideState` is false. Only the render settles it. +- Read the workflow file for the request before you change anything, because the steps, checks and rules for that work live there and acting on this page alone skips them. +- Avoid long explanations. + +## Step 0 + +Before you go forward with a workflow or diagnosis: + +1. Work on the scene open in the Editor, because that is the one the user means by "my scene" or "this scene". If several scenes are loaded, ask which one. If the open scene has never been saved, work on it anyway and say that it still needs saving. +2. Read the active render pipeline, as [Render pipeline](#render-pipeline) describes, because it decides which pages and steps apply. +3. Open and read the [doc page(s)](#full-topic-map) that cover the specific thing you intend to do or fix, before you change anything, and check if you've missed anything. If your web-fetch tool has to be loaded before first use, load it. +4. List the documentation pages you read, by URL, in your final report. + +This is because your training knowledge about Unity might be out of date, incorrect, or for the wrong Unity version. + +Relative paths in this skill, such as `references/topic-map.md`, resolve to this skill's own folder; do not search the project for them. + +If the project's exact Unity version has no published manual, use the nearest published Unity 6 version and say which. If a page is missing for the project's version, read the same page in a later Unity 6 manual, such as `6000.3`, and say which version you read. If a page is unreachable - you fetched it and the fetch failed - say so and fall back to this skill's own guidance plus the installed packages. You MUST NOT proceed on memory alone without saying so, because an unstated guess about a version-specific value is the failure this step exists to prevent. + +### Render pipeline + +Read the active render pipeline from `UnityEngine.Rendering.GraphicsSettings.currentRenderPipeline`, which is the asset actually in use and honours the quality level's override; `null` means the Built-in Render Pipeline. The workflows are written for URP, the preferred path. On URP every scene also has two default Volumes beneath its own: the project's Default Volume Profile and the active quality level's, per [Understand volumes in URP](https://docs.unity.com/en-us/engine//manual/post-processing-and-full-screen-effects/urp/volumes-landing-page/volumes.md). Whenever you read Volumes, read those too, through `UnityEngine.Rendering.VolumeManager.instance.globalDefaultProfile` and `qualityDefaultProfile`, because exposure or a grade set there changes the scene even when it contains no Volume. On Built-in or HDRP, read [references/pipeline-notes.md](references/pipeline-notes.md) first - it says which steps change and which do not - then follow the workflow with those substitutions, and name the pipeline in your report. Do NOT refuse a project because of its pipeline. + +### Project conventions + +Unity's manual describes how lighting works. It cannot tell you what THIS project has already decided. Each workflow file says what to read in the project before you change a value - its own documentation, a sibling scene, its lighting and bake policies. Do that before your first change. Where a project convention and a workflow disagree, the project wins; name the document you followed. Do this because a setup that is correct in general can still be wrong for a project that has already decided these things - the most common reason this work gets rejected. + +### When project sources disagree + +Project docs often contradict each other or what the scenes ship. Treat that as a finding: name both values and their sources, ask only if it changes what the user will see, otherwise follow the written direction and report the shipped value as drift. Full procedure: [references/project-conventions.md](references/project-conventions.md). + +### Full topic map + +Prefer fetching the page directly (for example `WebFetch`) over searching (for example `WebSearch`) — faster and lands on the exact reference. Only fetch what you need, and only search if you don't have the exact URL. Replace `` with the following before fetching: + +- **Engine on docs.unity.com**: The Unity version, eg `6000.3` +- **Package on docs.unity3d.com**: The package version, eg `@17.0`. Check the package version if unsure. + +Use only the first two numbers of the Unity version, because a full version such as `6000.3.2f1` gives a 404. docs.unity.com publishes the versions listed in `https://docs.unity.com/en-us/engine/llms.txt`. An unlisted version redirects to a general index page instead of the page you asked for, so treat it as having no published manual, as [Step 0](#step-0) describes. + +Manual pages live under `https://docs.unity.com/en-us/engine//manual/`. Keep the `.md` suffix, because it returns the page as plain Markdown. Links inside a page start with `/engine/`: add `https://docs.unity.com/en-us` before them. URP's local `Documentation~` holds no pages, so URP pages come from the online manual; some are landing pages - follow them down. HDRP pages live in the `com.unity.render-pipelines.high-definition` package manual on docs.unity3d.com, which has no `.md` version, so fetch those as linked; Built-in pages are in the main manual. The pages for each workflow, grouped by stage, are in [references/topic-map.md](references/topic-map.md): open only the pages for the step you are about to do, and name the ones you read. + +## Choose the workflow + +Choose the workflow from what the user wants changed. Open its file and read it in full before any change. A request that spans several workflows uses each file, in the order listed. + +| The user wants | Read | +|---|---| +| A scene with no lighting, or only a default light, lit from scratch - or one light added to a lit scene, such as a lamp, fire or torch | [references/set-up.md](references/set-up.md) | +| A lit scene that looks wrong: too dark, washed out, flat, blocky or missing shadows, an unwanted flicker, or broken since a change | [references/diagnose.md](references/diagnose.md) | +| A bake run, configured or fixed, or lighting that differs between the Editor and a build | [references/bake.md](references/bake.md) | +| A different mood or time of day on an existing setup | [references/style.md](references/style.md) | +| The sky, environment reflections or fog set up or repaired | [references/environment.md](references/environment.md) | +| Materials that render magenta, or a custom shader that receives no light or shadow | [references/materials.md](references/materials.md) | +| Lighting that costs too much on a platform or quality tier | [references/optimize.md](references/optimize.md) | +| Lighting that changes over time: a day-night cycle, a moving sun, a flicker the user asks for, a blend between lighting states | [references/animate.md](references/animate.md) | +| A themed or dramatic look built from new lights, such as a ring of fires in a dark room | set-up, then style; add environment when the sky or ambient must go dark | +| New lights that also move or flicker | set-up, then animate | + +- If the user only asks how Unity lighting works and wants no change, answer from the documentation at the length they asked for, without running a workflow. +- Post-processing effects set up for their own sake - bloom, vignette, depth of field - belong to the `urp-postprocessing` skill. Converting a project from the Built-in Render Pipeline to URP belongs to the `migrate-birp-to-urp` skill. +- Otherwise, if no row fits but the request is about how a scene is lit, start with diagnose, because its first section sends each kind of request to the right workflow. + +## Rules for every workflow + +### Anti-hallucination constraints + +| Rule | Reason | +|---|---| +| NEVER state a menu path, UI label or API name from memory | These move between versions. The setting often called "ambient intensity" is Intensity Multiplier under Environment Lighting in Unity 6, per the [Lighting window reference](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting-reference/lighting-window.md) | +| Test a claimed mechanism against the render before stating it | "Tonemapping is None, so everything above 1.0 clips to white" is checkable: render and count the clipped pixels. An explanation the image contradicts is a wrong diagnosis in a confident voice | + +Each workflow file adds the rows that matter for its own work. + +### Error messages + +| Message | Cause | Fix | +|---|---|---| +| `CS0210` from a `script eval` snippet | `script eval` compiles a statement block, not a file, so a `using` directive reads as a resource-disposal statement | Delete the `using` lines and fully qualify every type | +| `CS0246` or `CS0103` from a `script eval` snippet | A bare type such as `AssetDatabase` or `Volume` does not resolve in a statement block | Write the full name, such as `UnityEditor.AssetDatabase` or `UnityEngine.Rendering.Volume` | +| `CS0104` naming `Object` | `Object` matches both `UnityEngine.Object` and `System.Object` | Write `UnityEngine.Object` | +| `CS0619`: a member is obsolete | Unity deprecated the member and made calling it a compile error | Look the member up in this version's Scripting API and call the replacement it names | +| "Light Probe Groups are unavailable as Probe Volumes have been enabled", in the Inspector | The pipeline asset enables Adaptive Probe Volumes, so a Light Probe Group does nothing | Light moving objects with the project's Probe Volume instead, per [Use Adaptive Probe Volumes](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting/probevolumes/use.md) and the bake workflow | + +### Keep the change reversible and contained + +You are making a scoped edit to lighting, and the user must be able to undo it and to see exactly what moved. Work to that standard: + +1. Make the whole change one Ctrl+Z for the user. `Undo.RecordObject` alone leaves no undo entry when a snippet runs through `script eval`, because its snapshot is deferred to the end of an Editor event, so in each snippet: + 1. Open a group: `UnityEditor.Undo.IncrementCurrentGroup()`, name it with `UnityEditor.Undo.SetCurrentGroupName("")`, and keep `UnityEditor.Undo.GetCurrentGroup()`. + 2. Before you modify an object, call `UnityEditor.Undo.RegisterCompleteObjectUndo` on it, which snapshots immediately. After you create an object, call `UnityEditor.Undo.RegisterCreatedObjectUndo` on it. + 3. End with `UnityEditor.Undo.FlushUndoRecordObjects()` and `UnityEditor.Undo.CollapseUndoOperations()`, then read `UnityEditor.Undo.GetCurrentGroupName()` back. If it is not your label, say the change cannot be undone with Ctrl+Z. +2. List every object and asset you touched in your report, including any you touched only to read. +3. After each change, check its effect. If it made the problem worse, revert it before trying anything else, and say that you reverted it. +4. If the user asks you to revert, revert everything from that request and confirm what the state is now. Do not part-revert and do not substitute a different fix. + +NEVER change a setting you were not asked about because it looked wrong. INSTEAD name it, say what you would change it to, and ask. + +NEVER delete and recreate a GameObject or hierarchy to fix it. INSTEAD change the specific property, because destroyed objects break references elsewhere in the scene. + +NEVER repeat an action that already failed with a larger value or a different setting. INSTEAD stop and report what you tried, because escalating a failing change is how a slow bake becomes a crash. + +NEVER edit an asset shared by other scenes without saying so first. INSTEAD name the asset, name what else uses it, and ask. + +## Final step + +1. Check the project has zero console errors. Use `console_status` for counts. Find its name in the connected Editor with `unity command --query console`, because the name differs between versions, for example `unity command console status`. +2. Capture the Game view once, in Edit mode, and look at it, even when the scene holds little, because lighting is judged by eye: a scene can report perfect values and still render wrong. Find the capture command with `unity command --query capture`, which searches the connected Editor's commands as the `unity-cli` skill describes; `unity command --help` does not list them. +3. Stop there unless the user asked you to prove it works or you suspect a specific fault, such as an animated lighting cycle that never advances, which an Edit-mode capture can't show. If either holds, do the checks in the workflow file's Verify section, and put back anything you change only to run a check - an object you move, a time-of-day value, the active quality level, a setting you toggle - as soon as you have the reading, whether the check passed or failed, because the user asked for the lighting change and nothing else. Name anything you could not put back in the Final report. +4. If you do enter Play mode, do it once only to chase a fault you already suspect. Read the world through `script eval` rather than adding logging. Take no screenshots in Play mode, as they take too much time. + +If a check fails, go back and reread the relevant documentation from the [Full topic map](#full-topic-map) for what you missed. + +You MUST NOT run the fix-and-recheck loop more than three times. If it still fails on the third attempt, stop and give the user what you found instead of continuing, because past that point you are guessing rather than diagnosing. + +## Final report + +Give the user a concise but not dense checklist of what you did and why, including any incidental side effects (for example, settings you toggled to test something, or temporary files you created). If the user needs to follow up with more steps or decisions, list them. Include the items in the workflow file's Report section, and every object and asset you touched. List the documentation pages you read, by URL, and the captures you looked at, with what each showed, because those are the evidence behind what you report. + +## References + +Files in this skill's folder, by relative path: + +- Workflows: [set-up](references/set-up.md), [diagnose](references/diagnose.md), [bake](references/bake.md), [style](references/style.md), [environment](references/environment.md), [materials](references/materials.md), [optimize](references/optimize.md), [animate](references/animate.md) +- [Documentation pages, by workflow and stage](references/topic-map.md) +- [Built-in and HDRP substitutions](references/pipeline-notes.md) +- [When project sources disagree](references/project-conventions.md) +- [Terms this skill uses in a specific sense](references/terms.md) diff --git a/skills/light-scene/references/animate.md b/skills/light-scene/references/animate.md new file mode 100644 index 0000000..f81deba --- /dev/null +++ b/skills/light-scene/references/animate.md @@ -0,0 +1,152 @@ +# Animate scene lighting + +Drive a URP scene's lighting over time, choosing between realtime and blended-baked approaches on what the scene actually contains. + +Relative paths in this file, such as `references/terms.md`, resolve to the skill's root folder, not to this file's folder or the project. Other workflows are named by workflow, such as "the bake workflow"; the skill's workflow table gives each one's file. + +## Contents + +- Success criteria +- Important for this workflow +- Project conventions +- Confirm this is the right workflow +- Establish the design before writing code +- Choose the approach from what the scene contains +- Build it in this order +- Constraints +- Anti-hallucination constraints +- Terms +- Worked example +- Verify +- Report + +## Success criteria + +- One normalised time value drives the sun, the ambient and the sky together; none of them has its own clock. +- Motion is proven from two readings taken a moment apart that differ, not from a single reading. +- Ambient and environment updates run on a timer or threshold, never every frame. +- A scene with static lightmaps and a moving sun is reported as a design conflict before any code is written. +- The user is told what the cycle changes and which value to adjust to change its pace. + +## Important for this workflow + +- Do only what's asked. You MUST NOT change unrelated assets or files, because this workflow writes runtime scripts as well as scene data. +- WAIT for the user to say how long a full cycle should take and whether it must survive a save or reload. Those two answers decide the whole design, and guessing means rewriting it. + +## Project conventions + +Unity's manual describes the mechanisms. It cannot tell you how THIS project already handles time, state and lighting ownership. Before writing anything: + +1. Search the project for its own documentation on lighting, scene composition and game state - for example a `Docs` folder or a technical design document - and read it. A project that documents which scene owns lighting will break if a cycle writes to the wrong one. +2. Check whether the project already has a time-of-day or game-state system. Adding a second clock is worse than driving the existing one. +3. Where a project convention and this workflow disagree, the project wins. Name the document you followed in your response. +4. Check where the new script belongs. Projects usually have a documented folder and namespace convention for runtime scripts. + +Do this because an animated-lighting system touches runtime code, scene ownership and update order, and a scene-level view cannot see any of those. + +## 1. Confirm this is the right workflow + +| Request | Handle here? | +|---|---| +| A day-night cycle, a moving sun, a flicker the user asks for, or other lighting that changes over time | Yes | +| Blending between two baked lighting states | Yes | +| A scene has no lighting yet | No - use the set-up workflow first; you cannot animate what does not exist | +| A single fixed mood or time of day | No - use the style workflow | +| A one-off bake | No - use the bake workflow | +| A light that flickers or disappears when it should not | No - use the diagnose workflow | +| The skybox does not change when the lighting state does | No - use the environment workflow | + +## 2. Establish the design before writing code + +Change nothing during this step. + +1. Read the existing lighting: lights, ambient source, skybox type, and whether the scene has lightmaps. +2. For a cycle, ask how long a full cycle should take, and whether the time of day must persist across a save or scene reload. WAIT for both answers. For a flicker, the only questions are its speed and strength: take them from the request, or use a firelight default and name it in your report, because neither changes the approach. +3. Ask whether the geometry is static. This decides the approach more than anything else. +4. Check whether a procedural or texture skybox is in use. A texture skybox will not follow a moving sun, so a day-night cycle needs either a procedural sky or a blend between two skies. + +## 3. Choose the approach from what the scene contains + +| The scene has | Use | Why | +|---|---|---| +| Realtime lighting only, no lightmaps | Drive the directional light and ambient directly from script | Simplest, and nothing baked can go stale | +| Static geometry, and the user wants baked quality that still changes | Adaptive Probe Volumes, blending [Lighting Scenarios](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting/probevolumes/probe-volumes-change-lighting-at-runtime/bakedifferentlightingsetups.md) or using [sky occlusion](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting/probevolumes/probe-volumes-change-lighting-at-runtime/skyocclusion.md) | Lightmaps cannot change at runtime, and these let baked indirect light follow a time of day | +| Existing lightmaps and a moving sun | Stop and explain the conflict | Static lightmaps encode one sun position; they cannot follow a moving one, and the scene will look wrong at every other time of day | + +If the third row applies, say so plainly before writing anything. It is a design conflict, not a bug, and the user has to choose between baked quality and a moving sun. + +## 4. Build it in this order + +1. **Drive the sun.** Rotate the directional light and set its colour and intensity from a single normalised time value. One value driving everything keeps the cycle coherent. +2. **Move ambient with it.** Update the ambient source or its colours in the same step, then call the dynamic GI environment update so the change takes effect. A sun that sets over a fixed daylight ambient looks broken. +3. **Move the sky with it.** Assign the sun to the render settings so a procedural sky tracks it, or blend between sky materials. +4. **Blend baked data, if used.** Set up lighting scenarios per [Use Adaptive Probe Volumes](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting/probevolumes/use.md) and blend between them, rather than rebaking at runtime. +5. **Make the update cheap.** Lighting does not need updating every frame. Update on a timer or on a threshold change in the time value, because ambient and environment updates are not free. +6. **Drive it from a clock that actually advances where it will be judged.** `Update()` and + coroutines run in Play mode. In Edit mode they run only on `[ExecuteAlways]` components and + only while the Editor loop is ticking, and under a headless or batch Editor they do not run at + all; `EditorApplication.update` has the same limit. A flicker driven from any of these renders + as a frozen frame in a still capture. If the environment offers an explicit time or tick + callback, drive the animation from that; otherwise enter Play mode to verify, and say which + you did. + +After each stage, re-read the affected values rather than assuming the write applied. + +## 5. Constraints + +| Rule | Reason | +|---|---| +| NEVER update ambient or environment lighting every frame | The environment update has real cost, and lighting changes are imperceptible at frame granularity | +| NEVER rebake at runtime | Baking is an editor operation; blend prebaked scenarios instead | +| ALWAYS drive everything from one time value | Separate clocks for sun, ambient and sky drift out of step | +| Write the cycle so a given time value always produces the same lighting | A cycle that accumulates state cannot be resumed after a save or scene reload | +| NEVER animate lighting in a scene the project says does not own its lighting | The change will be overridden, or it will override another scene's setup | +| NEVER verify motion from one reading | Two readings a moment apart that differ are the evidence something moved; one reading cannot tell a running cycle from a frozen one | + +## 6. Anti-hallucination constraints + +| Rule | Reason | +|---|---| +| Confirm whether the project uses Adaptive Probe Volumes or the older Light Probes before writing probe code | They are different systems with different APIs, and the pipeline asset says which is active | +| Do not assume a skybox tracks the sun | Only some skybox shaders do; a texture sky will not move | +| Before creating any visible object, read the rendering camera's `cullingMask` and put the object on the layer of the thing it belongs to | NEVER assume the Default layer renders. In a project that culls it the object exists, is enabled, has bounds, and never draws - and a state read looks perfect | +| NEVER claim lights animate from a single reading | Read the sun's rotation twice, a moment apart, in Play mode and compare. Identical values mean nothing moved, whatever the code says | + +## 7. Terms + +Terms this workflow uses in a specific sense - key light, ambient, Contribute GI, light mode and the rest - are defined in `references/terms.md`. + +## 8. Worked example + +Requested: "Add a day-night cycle to this level." + +1. Read state: one directional light, procedural skybox, ambient source Skybox, no lightmaps, geometry mostly static. +2. Ask for cycle length and whether time persists across a reload. The user says ten minutes, and yes it must persist. +3. No lightmaps exist, so realtime driving is viable and the baked-versus-moving-sun conflict does not arise. Say so. +4. Write one component holding a normalised time value, derived from persisted elapsed time so a reload resumes correctly rather than restarting at dawn. +5. From that value: rotate the sun, set its colour warm at the horizon and neutral at noon, scale intensity, and update ambient in the same step. +6. Assign the sun to render settings so the procedural sky's sun disc tracks it. +7. Update on a timer rather than every frame, and say why. +8. Verify by reading the sun angle and resolved ambient through `script eval` at several time values, and confirm the same value always gives the same lighting. + +## Verify + +A cycle that never advances is this workflow's most common fault, so always treat it as the suspected fault the Final step names, and do these after its console check and capture: + +1. Enter Play mode once and read the sun's rotation and the resolved ambient through `script eval` twice, a moment apart. Values that differ show the cycle advances; also check that the sun angle, ambient and sky stay in step, and that the same time value reproduces the same lighting. Take no screenshots in Play mode. +2. Confirm the update is not running every frame. +3. If the user asked to see the cycle, set the time value in Edit mode to dawn, noon and dusk, capture each and look at them, then set it back to its starting value, because the captures are only a test. + +Because the result is judged by eye over time, state which values you verified and ask the user to watch a full cycle. You MUST NOT claim the transition looks right from state reads alone. + +If a check fails, go back and reread the relevant documentation from `references/topic-map.md`. A cycle that looks wrong at dusk but right at noon is usually ambient failing to move with the sun. + +## Report + +Include these in your final report: + +- Which approach you chose and what in the scene decided it. +- Where the new script lives and what drives it. +- How the time value persists across a reload. +- The documentation pages you read, by URL. +- Any conflict between baked lighting and a moving sun that the user still has to resolve. diff --git a/skills/light-scene/references/bake.md b/skills/light-scene/references/bake.md new file mode 100644 index 0000000..118de35 --- /dev/null +++ b/skills/light-scene/references/bake.md @@ -0,0 +1,156 @@ +# Bake scene lighting + +Prepare a URP scene for baked lighting, run the bake, and prove from project state that it produced output. + +Relative paths in this file, such as `references/terms.md`, resolve to the skill's root folder, not to this file's folder or the project. Other workflows are named by workflow, such as "the bake workflow"; the skill's workflow table gives each one's file. + +## Contents + +- Success criteria +- Important for this workflow +- Project conventions +- Confirm this is the right workflow +- Check the scene can be baked at all +- Prepare in dependency order +- Run the bake +- Work the known causes before escalating +- Anti-hallucination constraints +- Terms +- Worked example +- Verify +- Report + +## Success criteria + +- Contribute GI flags, light modes and lightmap UVs are verified before the bake, and a bake that cannot produce output is not run. +- The bake actually runs: `Lightmapping.Bake()` returns `true`, and the lightmap count is read back from project state afterwards - never assumed from the absence of errors. +- Lightmaps exist for every Baked or Mixed light, or the user is told exactly which lights still contribute nothing and why. +- The user is told which files the bake wrote and that the scene must be saved and the lighting folder committed for the result to survive. +- No shared asset is written to disk without saying so first. + +## Important for this workflow + +- Do only what's asked. You MUST NOT change unrelated assets or files, because lightmap settings and pipeline assets are shared across scenes. +- `UnityEditor.Lightmapping.BakeAsync()` returns immediately and bakes in the background, so any code after it runs against an unbaked scene. If your script needs the bake finished before it reports, captures or verifies, call the synchronous `Bake()` instead, check that it returns `true`, and say which you used. +- WAIT for the user before starting a bake on a large scene. A bake can take minutes to hours and blocks the editor, so it is not a step to run speculatively. + +## Project conventions + +Unity's manual describes how baking works. It cannot tell you what THIS project has already decided. Before changing any value: + +1. Search the project for its own documentation on lighting and technical constraints - for example a `Docs` folder, a style guide, or a technical design document - and read what it says about baking. Some projects state that lighting is realtime by policy. +2. Open a sibling scene that is already baked and read its settings: lightmap resolution, lightmapper backend, light modes, and whether probes are used. +3. Where a project convention and this workflow disagree, the project wins. Name the document you followed in your response. +4. If the project has never baked anything, treat that as a decision until the user says otherwise, and confirm before introducing the first lightmaps. Baked output is large binary data that lands in version control. + +Do this because baking has project-wide consequences - import settings, repository size, iteration time - that a scene-level view cannot see. + +## 1. Confirm this is the right workflow + +| Request | Handle here? | +|---|---| +| Run a bake, configure lightmaps, add light probes | Yes | +| A bake produced nothing, or the scene looks unchanged after baking | Yes | +| A scene has no lighting at all and needs a setup | No - use the set-up workflow first | +| A lit scene looks wrong and no bake is involved | No - use the diagnose workflow | +| The user wants a different mood or time of day | No - use the style workflow | +| A material renders magenta, or a shader has no Meta pass | No - use the materials workflow | + +## 2. Check the scene can be baked at all + +Change nothing during this step. Report what you find, because steps 2 to 4 decide what section 3 must fix before a bake can produce anything. + +1. Read the Unity version and confirm the active pipeline is URP, including any per-quality-level override. +2. Count renderers whose static flags include Contribute GI. **If none are marked, nothing will bake.** A scene of entirely moving objects has nothing to bake, and the answer is probes rather than lightmaps. +3. Check each static mesh has lightmap UVs by reading the mesh itself, `mesh.HasVertexAttribute(UnityEngine.Rendering.VertexAttribute.TexCoord1)`, not the model's import settings, because a model can bring its own lightmap UVs with Generate Lightmap UVs off. Only a mesh without them needs that setting turned on, which re-imports the model. +4. Read the light modes of every light. Realtime lights contribute nothing to a bake. +5. Read the current lightmap count and whether a Lighting Data Asset exists. + +Hold the bake, not the workflow. If the user asked you to configure or repair baking, fix what steps 2 to 4 found in section 3, then bake. Stop the workflow only when nothing in the scene can contribute GI, because then lightmaps are not the answer, and say that probes are. Never run a bake before its prerequisites are in place, because it cannot produce output. + +## 3. Prepare in dependency order + +Each stage below depends on the one above it, so a stage done out of order usually has to be redone. + +1. Mark the static geometry to contribute GI. Only geometry that never moves. +2. Set light modes per [Choose a light mode](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting-light-sources/components/configuring/light-modes/choose.md), and never Baked for a light that anything changes at runtime, because a change to a Baked light has no visible effect. +3. Set lightmap resolution and parameters per [Lightmap Parameters](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting-reference/class-lightmap-parameters.md). Start low. A first bake exists to prove the setup, not to look final. +4. Probes for moving objects, because moving objects receive nothing from lightmaps. First read the probe system the resolved pipeline asset enables - on URP, `lightProbeSystem` on the `UnityEngine.Rendering.Universal.UniversalRenderPipelineAsset`, shown as Light Probe System - because it decides which probes work, whatever the scene contains. Then look for existing volumes with `UnityEngine.Object.FindAnyObjectByType()`. + - If the asset enables Adaptive Probe Volumes, use [Adaptive Probe Volumes](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting/probevolumes/use.md), and add a volume if the scene has none. + - If it enables Light Probe Groups, use a [Light Probe Group](https://docs.unity.com/en-us/engine//manual/lighting-overview/direct-and-indirect-lighting/light-probes/light-probes.md), or offer to switch the asset to Adaptive Probe Volumes. Ask before switching, because the pipeline asset is shared and the switch changes every scene's bake. + - On the Built-in Render Pipeline, use a Light Probe Group. + + NEVER add a `LightProbeGroup` while the asset enables Adaptive Probe Volumes, because it does nothing there and a script that adds one still appears to succeed. +5. Add a [Reflection Probe](https://docs.unity.com/en-us/engine//manual/lighting-overview/reflections/reflection-probes.md) only if a surface is metallic or smooth. Matte surfaces gain nothing from one. + +## 4. Run the bake + +1. Tell the user the bake is about to run and roughly how long you expect it to take. WAIT if the scene is large. +2. Choose a backend per [Choose a light baking backend](https://docs.unity.com/en-us/engine//manual/lighting-overview/direct-and-indirect-lighting/lightmapping/baking-before-runtime/configure/progressive-lightmapper.md). Use the backend that page recommends for the project's Unity version. +3. Run the bake explicitly, because the [Unity 6 upgrade guide](https://docs.unity.com/en-us/engine//manual/upgrade-guides/upgrade-guide-unity6.md) lists what no longer bakes on its own. +4. NEVER decline to bake because the scene cannot be saved, because the bake's lighting data and lightmaps are assets that are live the moment it finishes, and only the scene's reference to them needs the save. Bake, then say plainly that the scene must be saved and its lighting folder committed for the result to survive a reopen or reach a build. +5. NEVER report a bake as done until `UnityEditor.Lightmapping.Bake()` has returned `true` for this bake and you have read the lightmap count back from project state, because a failed bake leaves the previous result in place, so the count alone can come from an earlier bake. +6. Assigning `LightProbes.bakedProbes` writes to `LightingData.asset` on disk immediately, and it + is not undone by declining to save the scene. Say so before touching probe data by script, and + re-read the asset's size afterwards, because a "restored" probe array can come back different + from the original. + +## 5. Work the known causes before escalating + +| Symptom | Work these first | Escalate only when | +|---|---|---| +| Bake finishes but produces zero lightmaps | Contribute GI flags, light modes, lightmap UVs, then the steps in [No baked global illumination](https://docs.unity.com/en-us/engine//manual/lighting-overview/direct-and-indirect-lighting/lightmapping/baking-before-runtime/troubleshooting/ts-no-baked-global-illum.md) | All of those are correct and the bake is still empty | +| Mixed lights look baked, with no realtime shadows | Work the steps in [Mixed lights render as baked](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting-light-sources/components/configuring/lighting-mode/ts-mixed-lights-render-as-baked.md) | Every step on that page checks out and it still demotes | +| The editor crashes during Generate Lighting | Switch backend per [Choose a light baking backend](https://docs.unity.com/en-us/engine//manual/lighting-overview/direct-and-indirect-lighting/lightmapping/baking-before-runtime/configure/progressive-lightmapper.md), then lower lightmap resolution and atlas size, update GPU drivers, and clear the GI cache per [No baked global illumination](https://docs.unity.com/en-us/engine//manual/lighting-overview/direct-and-indirect-lighting/lightmapping/baking-before-runtime/troubleshooting/ts-no-baked-global-illum.md) | Every backend has been tried and it still reproduces | +| Surfaces turn magenta after the bake | The material's shader has no usable `Meta` pass, so the bake produced Unity's error shader for it. Hand the material to the materials workflow; do NOT adjust lights, ambient or lightmap settings, because none of them changes an error shader | Never - this is a material fault, not a bake fault | + +You MUST NOT skip the first column, because escalating a fixable case wastes the user's time. + +## 6. Anti-hallucination constraints + +| Rule | Reason | +|---|---| +| Treat "Baked Global Illumination is enabled" and "the scene is baked" as different facts | The first is a setting; only a completed bake produces lightmaps | +| NEVER assume a mesh has lightmap UVs, or that it lacks them | Read the mesh's second UV channel: the import setting only says whether Unity generates one, and without it a lightmap cannot be applied | +| After every bake, check that `Lightmapping.Bake()` returned `true`, then read the lightmap count | The return value says whether this bake succeeded and the count shows what it produced; neither is enough alone, because a failed bake leaves the previous lightmaps in place | +| Say which on-disk assets a change touches before making it | `LightProbes.bakedProbes` writes to `LightingData.asset` the moment it is assigned, and `SerializedObject.ApplyModifiedProperties` on a pipeline, quality or Volume asset marks it dirty so the Editor saves it on exit. Declining to save the scene undoes neither | +| Confirm whether the project uses Adaptive Probe Volumes or Light Probe Groups before any probe work | The resolved pipeline asset decides it - on URP, its `lightProbeSystem` - not the scene's contents, because a project can enable Adaptive Probe Volumes before any `ProbeVolume` exists | + +## 7. Terms + +Terms this workflow uses in a specific sense - key light, ambient, Contribute GI, light mode and the rest - are defined in `references/terms.md`. + +## 8. Worked example + +Requested: "Bake the lighting for this level." + +1. Context: Unity 6000.6, URP active, no quality-level override. +2. Pre-flight: 140 renderers, **none** marked Contribute GI. Lightmap count 0, no Lighting Data Asset. Both lights are Realtime. +3. Report that as it stands the bake would produce nothing, and say why. +4. Ask which geometry is genuinely static, rather than marking all 140 renderers. +5. Mark the confirmed static geometry, set the key light to Mixed, leave moving objects unmarked. +6. Check the static models have lightmap UVs. Two do not, so flag that fixing them re-imports the model. +7. Set a low lightmap resolution for the first bake and say it is a proving run, not a final one. +8. Ask before running, then run explicitly. +9. Read back: `Bake()` returned `true`, the lightmap count is now 3, and the Lighting Data Asset is present. Report those facts rather than saying "baked". + +## Verify + +If the user asked you to prove it works or you suspect a specific fault, do these after the Final step's console check and capture: + +1. Confirm that `Lightmapping.Bake()` returned `true` for this bake, then read the lightmap count and the presence of a Lighting Data Asset from project state. +2. Note a dynamic object's position, move it through the probed area in Edit mode and capture again, then put it back at the noted position whether or not the check passed, because the move is only a test. Probes apply in Edit mode too, so a moving object that stays unlit means the probe data did not bake. + +Because baked lighting is judged by eye, state which values you verified and ask the user to confirm the appearance. You MUST NOT claim a bake looks correct from state reads alone. + +If a check fails, go back and reread the relevant documentation from the topic map's bake section for what you missed. An empty bake is far more often a missing Contribute GI flag or a missing lightmap UV than a wrong lightmapper setting. + +## Report + +Include these in your final report: + +- What could and could not be baked, and why. +- What you marked static and what you deliberately left dynamic. +- The lightmap count and Lighting Data Asset state before and after. +- The documentation pages you read, by URL. +- Anything that needs a model re-import or a project-wide decision. diff --git a/skills/light-scene/references/diagnose.md b/skills/light-scene/references/diagnose.md new file mode 100644 index 0000000..071436e --- /dev/null +++ b/skills/light-scene/references/diagnose.md @@ -0,0 +1,192 @@ +# Diagnose scene lighting + +Diagnose a URP scene whose lighting looks wrong, repair the whole setup rather than the named symptom, and verify the repair by reading project state. + +Relative paths in this file, such as `references/terms.md`, resolve to the skill's root folder, not to this file's folder or the project. Other workflows are named by workflow, such as "the bake workflow"; the skill's workflow table gives each one's file. + +## Contents + +- Success criteria +- Important for this workflow +- Project conventions +- Confirm this is the right workflow +- Gather project context +- Narrow down where the problem lives +- Complete the setup, not the symptom +- Work the known causes before escalating +- Anti-hallucination constraints +- Terms +- Worked example +- Verify +- Report + +## Success criteria + +- The one cause is named, and the fix changes only what was broken: the moved value in a regression, or the earliest missing stage in an unfinished setup. +- No authored value that was not the symptom is changed; anything else that looks wrong is reported and left. +- Every claimed mechanism is tested against the render before it is stated - a "clips to white" is shown by counting clipped pixels, not asserted. +- Brightness, shadows or the reported symptom are visibly restored, and the render is inspected to confirm it. +- Any shared asset the fix touches is named as shared before it is edited. + +## Important for this workflow + +- Do only what's asked. You MUST NOT change unrelated assets or files, because lighting settings are shared across scenes and an unrelated edit is hard for the user to spot. +- A component cannot be destroyed while another on the same GameObject declares `[RequireComponent]` on it, and Unity refuses without throwing an exception, so a `script eval` snippet that tries it still appears to succeed. URP attaches `UniversalAdditionalLightData` to every Light, so removing a Light means removing that first. Re-read the count afterwards: a destroy that quietly did nothing looks identical to one that worked. +- WAIT for the user's decision whenever a repair needs a look or an intent they have not stated, because there is no correct value to guess. + +## Project conventions + +Unity's manual describes how lighting works. It cannot tell you what THIS project has already +decided. Before changing any value: + +1. Search the project for its own documentation on lighting, scene composition and art + direction - for example a `Docs` folder, a style guide, or a technical design document - and + read what it says about lighting. +2. Open a sibling scene that is already lit and read its rig: how many lights, their colour, + intensity and mode, the ambient source, whether fog is used, and whether a Volume is bound. + Read its shadow and bake policy too: how many lights cast shadows, and whether the scene is + lit by a bake. Those two decide each other - a baked scene pays no runtime cost for shadows, + so it can afford far more shadow-casting lights than a realtime rig, and copying a realtime + rig's shadow budget into a baked scene silently throws most of its shadows away. + Match the project's existing structure unless you have a stated reason not to. +3. Where a project convention and this workflow disagree, the project wins. Name the document you + followed in your response. +4. If the project documents a scene-lighting ownership rule, obey it. A scene with no lights is + sometimes deliberate, and "fixing" it can silently break the arrangement. + +Copying a sibling scene is not the same as agreeing with it. Read its values, then judge them +against the scene in front of you - an intensity tuned for textured geometry can clip flat +blockout albedos. + +Do this because a setup that is correct in general can still be wrong for a project that has +already decided these things - the most common reason this work gets rejected. + +## 1. Confirm this is the right workflow + +| Request | Handle here? | +|---|---| +| A scene looks wrong, or shadows are missing or blocky | Yes | +| A scene has no lighting yet and needs some | No - use the set-up workflow | +| Run or configure a bake, with no problem reported | No - use the bake workflow | +| The setup is correct and the user wants a different look | No - use the style workflow | +| Materials render magenta, or a custom shader receives no light | No - use the materials workflow | +| The skybox, environment reflections or fog are the problem | No - use the environment workflow | + +### Match the effort to what was asked + +Decide this before gathering anything, because it determines how much gathering is warranted. + +| What the user asked | What to deliver | +|---|---| +| A question, with no change requested - "why is X like this", "dont change anything" | Read only what is needed to name the cause, answer at the length they asked for, and change nothing. Do not render the scene to answer a question about a setting you can read | +| A symptom that appeared after a change they name - "since i changed the sun" | A regression. Find what moved, put it back, and stop. See section 4 | +| A symptom with no known trigger, or a scene that was never finished | A full diagnosis. Work sections 3 to 6 | + +## 2. Gather project context + +Change nothing during this step. + +1. Read the Unity version and the active render pipeline asset. +2. Check whether the current quality level overrides the pipeline asset, per [Set the render pipeline asset](https://docs.unity.com/en-us/engine//manual/render-pipelines/choose-a-render-pipeline/srp-setting-render-pipeline-asset.md). Do this because a project can render through a different pipeline asset per quality level, so the Graphics Settings default is not always what is active. +3. Name the active pipeline. The steps below are written for URP; on Built-in or HDRP apply the substitutions in `references/pipeline-notes.md` as you go - the shape of the work is the same, the places the settings live are not. +4. Find every light in the open scene using the query `t:Light`. +5. In a single call, read each light's type, intensity, colour, shadow mode, range and light mode, the scene's Environment Lighting Source and Intensity Multiplier, and each Volume in effect - the scene's own and, on URP, the two default Volumes every scene has, per [Understand volumes in URP](https://docs.unity.com/en-us/engine//manual/post-processing-and-full-screen-effects/urp/volumes-landing-page/volumes.md) - with its Color Adjustments Post Exposure and its Tonemapping mode, and their `overrideState`. Use one call because each round trip is slow, and read the Volumes here because exposure, not a light, is a common cause of a scene that is dark everywhere, and it can sit in a default Volume when the scene has none. +6. Report what exists before proposing any change, so the user can correct a wrong assumption early. + +## 3. Narrow down where the problem lives + +1. Find out whether the problem appears in the Scene view, the Game view or a build. If the user has not said, capture the Game view first and ask only if the capture does not settle it, because a capture answers the question faster than the user can. +2. If it appears only in the Scene view, check the Scene view's own View Options, because those toggles affect the Scene view alone and not the built game. +3. If it appears only in the Game view, inspect the active camera and any post-processing volume, because tonemapping and colour grading change the image without changing the lighting. Check whether a Tonemapping override exists at all: with mode None, anything above 1.0 clips hard to white, so a scene that reads blown out may be correctly lit and merely uncompressed. + Read each override's `overrideState` as well as its value: an override that is switched off + is not in effect however plausible its number looks, and one that is on with a large value can + be the whole fault. +4. If it appears in both views, do NOT conclude the cause is a light. Check the URP asset and any global Volume first, because shadow distance, cascade count, additional-light limits and a Volume with a default layer mask all affect both views and are neither a camera nor a scene light. +5. If it appears only in a build, go to section 5. + +## 4. Complete the setup, not the symptom + +A lighting problem usually spans shadows, baking and exposure together, so a repair that addresses only the named symptom tends to leave the scene wrong. + +### Unless it is a regression + +When the user names the change they made, the scene worked before it and the rest of this section +does not apply. Undo the damage; do not improve the scene. + +1. Identify the one thing that moved. Everything else is authored and deliberate. +2. Restore only that. If the original value is unrecoverable - the scene on disk no longer holds + it and the project has no version control - say so plainly, then take a replacement from the + project's own sibling scenes rather than from Unity's defaults. +3. Values you believe are wrong but that were NOT part of the reported change: report them and + leave them. Offer to fix them separately. + + The one exception: a value that is **zero** while the project's authored value and every + sibling scene are non-zero, and that sits alongside the reported symptom - an ambient + intensity of 0 next to a missing skybox, say - is part of the damage, not a tuning choice. + Restore it and say why. Left alone, it changes nothing visible until the next bake, which it then makes wrong. + +NEVER change a value that is neither the reported symptom nor demonstrably broken. A value that +differs from Unity's default is usually one somebody tuned deliberately. + +1. Work through [Lighting configuration workflow](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting-configuration-workflow.md) and identify every stage that is missing or unapplied. +2. Say which on-disk assets a fix will touch before making it. `LightProbes.bakedProbes` writes + to `LightingData.asset` the moment it is assigned, and `SerializedObject.ApplyModifiedProperties` + on a pipeline, quality or Volume asset marks it dirty so the Editor saves it on exit. Declining + to save the scene undoes neither. Prefer an in-memory change when the user asked only to see a + result. +3. Fix the earliest missing stage first, because later stages depend on it. A bake means nothing until light modes and ContributeGI flags are right. +4. After each change, re-read the affected value rather than assuming the write applied. +5. NEVER report a bake as done until `UnityEditor.Lightmapping.Bake()` has returned `true` and you have read the lightmap count from project state, because a failed bake leaves the previous result in place. + +## 5. Work the known causes before escalating + +| Symptom | Work these first | Escalate only when | +|---|---|---| +| Editor crashes during Generate Lighting | Switch baking backend per [Choose a light baking backend](https://docs.unity.com/en-us/engine//manual/lighting-overview/direct-and-indirect-lighting/lightmapping/baking-before-runtime/configure/progressive-lightmapper.md), then lower lightmap resolution and atlas size, update GPU drivers, and clear the GI cache per [No baked global illumination](https://docs.unity.com/en-us/engine//manual/lighting-overview/direct-and-indirect-lighting/lightmapping/baking-before-runtime/troubleshooting/ts-no-baked-global-illum.md) | Every backend has been tried and the crash reproduces. Report it as an engine issue and stop | +| Lighting correct in the editor, wrong in a build | Treat this as a setup problem, not a build problem. Check that the scene has a committed lighting data asset from an explicit bake, per the [Unity 6 upgrade guide](https://docs.unity.com/en-us/engine//manual/upgrade-guides/upgrade-guide-unity6.md), that it is in Build Settings, and quality-level differences | The setup is verified complete and the divergence still reproduces | +| Screen goes black at some viewing angles and renders at others | Read the camera's far clip plane, the fog end distance and whether occlusion culling data is baked for this scene, in that order, because a light cannot make a view direction black. Fix the one that is wrong and re-render from the failing angle | All three read sane and the blackout still reproduces from the same angle | + +You MUST NOT skip the first column, because escalating a fixable case wastes the user's time. + +## 6. Anti-hallucination constraints + +| Rule | Reason | +|---|---| +| Read every value before changing it | Lighting values are frequently non-default and cannot be inferred | +| Distinguish Baked Global Illumination being enabled from a bake having been run | The first is a setting; only the second produces lightmaps | +| Read the active pipeline asset and its quality-level override, rather than inferring the pipeline from folder names | Only the resolved asset determines behaviour | +| NEVER set a Volume override parameter's `.value` without setting `.overrideState = true` first | A parameter whose `overrideState` is false is ignored entirely: the profile displays the value and the render does not change. The result looks like a pipeline fault, which it is not | +| Say which on-disk assets a change touches before making it | `LightProbes.bakedProbes` writes to `LightingData.asset` the moment it is assigned, and `SerializedObject.ApplyModifiedProperties` on a pipeline, quality or Volume asset marks it dirty so the Editor saves it on exit. Declining to save the scene undoes neither | +| For Volume scripting beyond setting a value, follow the `urp-postprocessing` skill | Edit `volume.sharedProfile` (the asset, so it persists), not `volume.profile` (a runtime clone that is never saved), and an override added in editor code needs `AssetDatabase.AddObjectToAsset` to survive a reload - otherwise the grade shows in the Inspector and vanishes when the asset reloads | + +## 7. Terms + +Terms this workflow uses in a specific sense - key light, ambient, Contribute GI, light mode and the rest - are defined in `references/terms.md`. + +## 8. Worked example + +Reported: "My scene is completely black when I press play." + +1. Context: Unity 6000.6, `PC_RPAsset` active, no quality-level override. +2. `t:Light` returns zero lights. Environment Lighting Source is Color at an Intensity Multiplier of 0.02. +3. Report: the scene has no lights at all, and ambient is almost black. +4. Fix the earliest missing stage - a light source - by adding a directional light angled down, with shadows enabled and a sun-like intensity. +5. Re-read the light to confirm the write applied. +6. Do NOT raise the Intensity Multiplier as the fix, because that hides a scene with no working light rather than repairing it. +7. Verify: zero console errors, then capture the Game view and look at it. Adding a light is not runtime behaviour, so Play mode is not needed. + +## Verify + +Because the reported symptom is visual, state which values you verified and ask the user to confirm the appearance. You MUST NOT claim a visual result is correct from state reads alone. + +If a check fails, go back and reread the relevant documentation from `references/topic-map.md` for what you missed. The cause is more often a skipped stage of the configuration workflow than a wrong value. + +## Report + +Include these in your final report: + +- What the lighting state was before the change. +- Which stages of the configuration workflow were missing, and what completed them. +- The documentation pages you read, by URL. +- What you verified from state, and what still needs the user's eyes. +- Anything escalated as an engine issue. diff --git a/skills/light-scene/references/environment.md b/skills/light-scene/references/environment.md new file mode 100644 index 0000000..622f976 --- /dev/null +++ b/skills/light-scene/references/environment.md @@ -0,0 +1,184 @@ +# Configure environment lighting + +Set up or repair the sky, ambient, reflections and fog of a URP scene, resolving which of the several places that can supply a background is actually supplying it, and verify the result by reading project state. + +Relative paths in this file, such as `references/terms.md`, resolve to the skill's root folder, not to this file's folder or the project. Other workflows are named by workflow, such as "the bake workflow"; the skill's workflow table gives each one's file. + +## Contents + +- Success criteria +- Important for this workflow +- Rules for this workflow +- Project conventions +- Confirm this is the right workflow +- Gather project context +- Resolve which source is actually supplying the background +- Repair a sky that is missing or wrong +- Reflections +- Fog +- Anti-hallucination constraints +- Terms +- Worked example +- Verify +- Report + +## Success criteria + +- The source actually supplying the background - skybox material, camera clear colour, a Skybox component override, or a script - is identified before anything is changed. +- The skybox renders and also contributes ambient and reflection; the two paths are checked separately. +- Reflection probes have baked output or a working realtime state, verified from the render, not the Inspector. +- A value found at zero next to the reported fault is restored to the project's authored value, and the restoration is named. +- No Light component is changed; a sun that no longer suits the sky is reported, not adjusted. + +## Important for this workflow + +- Do only what's asked. You MUST NOT change unrelated assets or files, because environment settings are shared across scenes and an unrelated edit is hard for the user to spot. +- Leave every Light component as it is, because this workflow changes the environment only. If the sun's direction or colour no longer suits a new sky, say so and offer to change it. +- Environment settings live in several places that override each other - the scene's Lighting window, the camera, a Skybox component, and runtime script. Find which one is winning before you change any of them. +- WAIT for the user's decision whenever the choice is a look rather than a fault - which sky, how thick the fog - because there is no correct value to guess. + +## Rules for this workflow + +NEVER set the same background in two places to be sure it takes. INSTEAD fix the one that is winning, because a camera override and a scene value that disagree will diverge the next time either one is edited. + +NEVER repeat an action that already failed with a larger value. INSTEAD stop and report what you tried, because raising skybox exposure or fog density to force a result hides the actual cause. + +NEVER edit a skybox material, reflection probe or lighting settings asset shared by other scenes without saying so first. INSTEAD name the asset, name what else uses it, and ask. + +## Project conventions + +Unity's manual describes how environment lighting works. It cannot tell you what THIS project has +already decided. Before changing any value: + +1. Search the project for its own documentation on lighting, scene composition and art + direction - for example a `Docs` folder, a style guide, or a technical design document - and + read what it says about skies, reflections and fog. +2. Open a sibling scene that already renders correctly and read its environment: which skybox + material, the ambient source and intensity, the environment reflection source, whether fog is + on and at what density, and how the camera's background is set. Match the project's existing + structure unless you have a stated reason not to. +3. Where a project convention and this workflow disagree, the project wins. Name the document you + followed in your response. +4. If the project loads skyboxes at runtime - from a `Resources` folder, a scriptable object or + an addressable - the scene's authored skybox is not the one players see. Find the loading code + before editing the scene, or your change will be overwritten on the first frame. + +Copying a sibling scene is not the same as agreeing with it. Read its values, then judge them +against the scene in front of you - a fog density tuned for a corridor will erase an open +landscape. + +Do this because a setup that is correct in general can still be wrong for a project that has +already decided these things - the most common reason this work gets rejected. + +## 1. Confirm this is the right workflow + +| Request | Handle here? | +|---|---| +| The skybox is missing, blue, black, blurry, or will not change | Yes | +| A surface does not reflect the sky, or a reflection probe does nothing | Yes | +| Fog is missing, or will not turn off | Yes | +| Ambient is the wrong source or intensity | Yes | +| The scene is dark or washed out and the sky is not implicated | No - use the diagnose workflow | +| A scene has no lighting at all yet | No - use the set-up workflow | +| A material renders magenta, or a custom shader ignores light | No - use the materials workflow | +| The sky is correct and the user wants a different mood or time of day | No - use the style workflow | +| Volumetric light shafts and god rays | Partly - see section 6 | + +## 2. Gather project context + +Change nothing during this step. + +1. Read the Unity version and the active render pipeline asset. +2. Check whether the current quality level overrides the pipeline asset. Do this because a project can render through a different pipeline asset per quality level, so the Graphics Settings default is not always what is active, and realtime reflection probes are a per-quality-level toggle. +3. Name the active pipeline. The steps below are written for URP; on Built-in or HDRP apply the substitutions in `references/pipeline-notes.md` as you go - the shape of the work is the same, the places the settings live are not. +4. In a single call, read the scene's Skybox Material, Sun Source, Environment Lighting Source and Intensity Multiplier, Environment Reflections source and resolution, and the fog settings. Use one call because each round trip is slow. +5. Find every camera and every reflection probe in the scene. +6. Report what exists before proposing any change, so the user can correct a wrong assumption early. + +## 3. Resolve which source is actually supplying the background + +Several things can put pixels behind the geometry, and the one that wins is not always the one the user edited. Establish the winner before changing anything. + +1. Read the camera's Background Type per [URP camera component reference](https://docs.unity.com/en-us/engine//manual/cameras/urp/camera-components-reference/camera-component-reference.md). If it is Solid Color, the scene's skybox material is irrelevant to the Game view no matter what it is set to. A flat blue background is usually this, not a missing skybox. +2. Read the camera's Render Type. An Overlay camera does not clear, so the background comes from the Base camera in the stack. +3. Check for a `Skybox` component on the camera. Per [Use a skybox](https://docs.unity.com/en-us/engine//manual/creating-environments/sky/skyboxes-using.md) it overrides the scene's Lighting window skybox for that camera only, which is the usual reason an edit in the Lighting window does nothing. +4. Check whether anything assigns `RenderSettings.skybox` from script. Search the project for that property. Runtime assignment beats the authored scene value. +5. Only after all four, read the scene's Skybox Material in the Lighting window. + +State which of these is winning in your report. You MUST NOT change more than one of them to make the sky appear, because that leaves the scene with two sources of truth and the next person cannot tell which is intended. + +## 4. Repair a sky that is missing or wrong + +| Symptom | Work these first | +|---|---| +| Flat blue or flat colour background | Camera Background Type, then the Skybox component override, per section 3 | +| Skybox Material is assigned but nothing renders | Check the material's shader is a skybox shader per [Skybox shaders](https://docs.unity.com/en-us/engine//manual/creating-environments/sky/skybox-shaders.md), and that its texture or cubemap slots are filled per [Skybox material reference](https://docs.unity.com/en-us/engine//manual/creating-environments/sky/skybox-material-reference.md) | +| Sky renders black | Check the skybox shader's Exposure and Tint, and check exposure or tonemapping on a Volume before touching the sky | +| Sky changes but ambient and reflections do not | After assigning `RenderSettings.skybox` at runtime, call [`UnityEngine.DynamicGI.UpdateEnvironment()`](https://docs.unity.com/en-us/engine//script-reference/unityengine/dynamicgi/updateenvironment.md), because the assignment alone does not refresh them | +| Sky is visible in the editor and absent in a build | Confirm the skybox material is referenced by an asset that ships, or add its shader to Always Included Shaders per [Graphics settings](https://docs.unity.com/en-us/engine//manual/unity-editor/editor-settings-reference/comp-manager-group/class-graphics-settings.md), because a build strips a shader nothing in it references | +| Sky looks low resolution | Read the source texture's import settings - max size, compression and mip generation - before changing any skybox property | + +The `DynamicGI.UpdateEnvironment` row is the most common cause of a skybox that changes while ambient and reflections stay on the old sky. Check it before you conclude the assignment failed. + +## 5. Reflections + +1. Read the Environment Reflections source in the [Lighting window](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting-reference/lighting-window.md). +2. If the scene shows no environment reflection, check what this version still bakes by default, per the [Unity 6 upgrade guide](https://docs.unity.com/en-us/engine//manual/upgrade-guides/upgrade-guide-unity6.md), before you add a probe. +3. For each reflection probe, read its baked output, or for a realtime probe whether the active quality level enables Realtime Reflection Probes, per [Quality settings](https://docs.unity.com/en-us/engine//manual/unity-editor/editor-settings-reference/comp-manager-group/class-quality-settings.md). +4. Before concluding reflections are broken, read the material's Smoothness and Metallic. A rough dielectric surface reflects almost nothing, and that is correct behaviour rather than a fault. Report it as such rather than raising probe intensity to force a result. +5. Before you offer Screen Space Reflections, check the [render pipeline feature comparison](https://docs.unity.com/en-us/engine//manual/render-pipelines/choose-a-render-pipeline/feature-comparison.md) for the project's version, because it says whether URP supports them. Where it does not, reflections come only from the skybox and reflection probes. +6. For a reflection that is correct in the middle of a room and wrong at its edges, read box projection on the probe per [Reflection probe reference](https://docs.unity.com/en-us/engine//manual/lighting-overview/reflections/class-reflection-probe.md). + +Work [Reflection probe troubleshooting](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting/reflection-probes/troubleshooting.md) before escalating, because most no-reflection reports are one of its documented rows. + +## 6. Fog + +1. Read fog in the Lighting window of each scene involved, per the [Lighting window reference](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting-reference/lighting-window.md), because fog is set per scene: a project-wide belief that fog is off is usually one scene's value someone left on. +2. If fog appears in the Editor and not in a build, read the Fog row of [Settings and keywords reference for stripping keywords in URP](https://docs.unity.com/en-us/engine//manual/materials-and-shaders/built-in/shaders-in-universalrp/shader-stripping/features-and-keywords.md) and check the settings it names before changing fog values. +3. If the built-in materials fog and a custom material does not, hand that material to the materials workflow, because each shader applies fog itself. +4. If the user asks for volumetric fog or light shafts, read the Volumetrics rows of the [render pipeline feature comparison](https://docs.unity.com/en-us/engine//manual/render-pipelines/choose-a-render-pipeline/feature-comparison.md) for the project's version. Where URP has none, say plainly that this needs a custom renderer feature or a third-party asset, and offer the approximations that do exist rather than tuning fog density towards a result it cannot reach. You MUST NOT imply a built-in setting will produce volumetrics. + +## 7. Anti-hallucination constraints + +| Rule | Reason | +|---|---| +| Read every value before changing it | Environment values are frequently non-default and cannot be inferred | +| Distinguish the sky being rendered from the sky contributing ambient and reflection | These are separate paths, and one can be correct while the other is stale | +| NEVER claim a reflection probe works without reading its baked output or its realtime state | A probe with no baked output looks identical in the Inspector to one with output | +| NEVER set a Volume override parameter's `.value` without setting `.overrideState = true` first | A parameter whose `overrideState` is false is ignored entirely: the profile displays the value and the render does not change. The result looks like a pipeline fault, which it is not | +| After `DynamicGI.UpdateEnvironment()` in Edit mode, check the default reflection as well as the ambient | The skybox reflection can keep mirroring the old sky after the ambient has updated. If it does, set `defaultReflectionMode` to Custom with an explicit cubemap | +| Read a reflection probe's texture after `ReflectionProbe.RenderProbe()` in Edit mode | The call can leave the probe without a texture outside Play mode; `Camera.RenderToCubemap` from the probe's position is the fallback | +| For Volume scripting beyond setting a value, follow the `urp-postprocessing` skill | Edit `volume.sharedProfile` (the asset, so it persists), not `volume.profile` (a runtime clone that is never saved), and an override added in editor code needs `AssetDatabase.AddObjectToAsset` to survive a reload - otherwise the grade shows in the Inspector and vanishes when the asset reloads | + +## 8. Terms + +Terms this workflow uses in a specific sense - key light, ambient, Contribute GI, light mode and the rest - are defined in `references/terms.md`. + +## 9. Worked example + +Reported: "the screen is all blue, there is no skybox from Resources/Skyboxes". + +1. Context: Unity 6000.6, `PC_RPAsset` active, no quality-level override. +2. Resolve the source: the main camera's Background Type is Solid Color, set to blue. The scene's Skybox Material is assigned correctly. +3. A project search finds a start-up script assigning `RenderSettings.skybox` from `Resources/Skyboxes` with no follow-up call. +4. Report both findings before changing anything, because the user believes there is one fault and there are two. +5. Fix the camera's Background Type to Skybox - the one change that makes the sky visible. +6. Add `UnityEngine.DynamicGI.UpdateEnvironment()` after the runtime assignment, so ambient and reflections match the sky that was loaded. +7. Re-read both values to confirm the writes applied. +8. Verify: zero console errors, then read `RenderSettings.skybox` by name and the camera's background type, capture the Game view and look at it. Play mode is needed only if a script sets the skybox at runtime, as in section 3's case. + +## Verify + +Because the reported symptom is visual, state which values you verified and ask the user to confirm the appearance. You MUST NOT claim a visual result is correct from state reads alone. + +If a check fails, go back and reread the relevant documentation from `references/topic-map.md` for what you missed. The cause is more often a second source overriding the one you fixed than a wrong value. + +## Report + +Include these in your final report: + +- Which source was actually supplying the background, and how you established it. +- What you changed, and what you deliberately left alone. +- The documentation pages you read, by URL. +- What you verified from state, and what still needs the user's eyes. +- Anything the pipeline cannot do, such as volumetric fog, stated plainly rather than approximated. diff --git a/skills/light-scene/references/materials.md b/skills/light-scene/references/materials.md new file mode 100644 index 0000000..05027fb --- /dev/null +++ b/skills/light-scene/references/materials.md @@ -0,0 +1,192 @@ +# Fix material lighting response + +Repair URP materials and shaders that render magenta or fail to respond to light, by identifying whether the shader is absent, wrong for the pipeline, or missing the passes and keywords lighting needs, and verify the repair by reading project state. + +Relative paths in this file, such as `references/terms.md`, resolve to the skill's root folder, not to this file's folder or the project. Other workflows are named by workflow, such as "the bake workflow"; the skill's workflow table gives each one's file. + +## Contents + +- Success criteria +- Important for this workflow +- Rules for this workflow +- Project conventions +- Confirm this is the right workflow +- Gather project context +- Separate the three failure shapes +- Magenta or pink materials +- A custom shader receives no light or no shadows +- The shader is right but the material still looks wrong +- Anti-hallucination constraints +- Terms +- Worked example +- Verify +- Report + +## Success criteria + +- No magenta or pink surface remains, verified from the render. +- Materials on Built-in shaders are moved to their URP equivalents through Unity's own upgrader; custom shaders are repaired, not replaced. +- No mesh or material is deleted and recreated to hide the fault. +- A surface that stays dark for a lighting or environment reason is handed to the right skill with the reason stated, rather than "fixed" in the material. +- The user is told which shaders changed and which were left for them to decide. + +## Important for this workflow + +- Do only what's asked. You MUST NOT change unrelated assets or files, because materials and shaders are shared across scenes and an unrelated edit is hard for the user to spot. +- NEVER recreate a mesh, material or terrain to fix how it renders. The asset is almost always intact and only its shader reference is broken, and recreating it destroys the user's authored values. +- Read the console before forming any theory. A magenta surface usually has a shader compile error printed with the file and line, and guessing past it wastes the user's time. + +## Rules for this workflow + +NEVER recreate a mesh, material, terrain or prefab to fix how it renders. INSTEAD repair the shader reference, because the asset holds authored work that recreating it destroys. + +NEVER replace a custom shader with a built-in one to make the symptom go away. INSTEAD name what the custom shader is missing and ask, because someone wrote that shader for a reason. + +NEVER change lighting, ambient or exposure to compensate for a material that renders wrong. INSTEAD fix the material, because compensating in the scene breaks every other object in it. + +NEVER edit a material or shader shared by other scenes without saying so first. INSTEAD name the asset, name what else uses it, and ask. + +## Project conventions + +Unity's manual describes how shaders and materials work. It cannot tell you what THIS project has +already decided. Before changing any value: + +1. Search the project for its own documentation on rendering, shaders and art direction - for + example a `Docs` folder, a style guide, or a technical design document - and read what it says + about which shaders are approved and whether custom shaders are maintained in-house. +2. Open a sibling material that renders correctly and read which shader it uses, its surface type + and its keyword state. Match the project's existing structure unless you have a stated reason + not to. +3. Where a project convention and this workflow disagree, the project wins. Name the document you + followed in your response. +4. If the project ships its own shader library, a custom shader is someone's authored work, not a + mistake. Repair it rather than replacing it with a built-in shader, unless the user asks for + the replacement. + +Copying a sibling material is not the same as agreeing with it. Read its values, then judge them +against the asset in front of you - a surface type that suits opaque geometry will break a +material that needs alpha clipping. + +Do this because a setup that is correct in general can still be wrong for a project that has +already decided these things - the most common reason this work gets rejected. + +## 1. Confirm this is the right workflow + +| Request | Handle here? | +|---|---| +| Materials render magenta, pink or purple | Yes | +| A custom or third-party shader receives no light, or casts no shadow | Yes | +| One object stays flat or dark while the rest of the scene lights correctly | Yes | +| Metallic or smoothness has no visible effect on one material | Yes | +| The whole scene is dark, black or washed out | No - use the diagnose workflow | +| The skybox is missing, or nothing reflects the sky at all | No - use the environment workflow | +| A scene has no lighting at all yet | No - use the set-up workflow | +| The user wants to author a new shader for a look they describe | No - this workflow repairs lighting response, it does not design shaders | +| The whole project is moving from the Built-in Render Pipeline to URP | No - that is `migrate-birp-to-urp`; come back here for any material still wrong afterwards | + +If a single material is wrong, the fault is almost certainly in that material or its shader. If every material is wrong, check the pipeline and the scene first - see section 3. + +## 2. Gather project context + +Change nothing during this step. + +1. Read the Unity version, the active render pipeline asset, and whether the current quality level overrides it. +2. Read the console and collect every shader compile error and warning verbatim. Do not summarise them away - the file and line are the fastest route to the cause. +3. Identify the affected renderers and, for each, the material and the shader asset it points to. +4. For each shader, establish which pipeline it was written for: a built-in `Standard` or `Legacy` shader, an HDRP shader, a URP shader, or a Shader Graph asset with a target set. +5. Check the project's package list for a render pipeline package that was removed or changed, because a removed package leaves materials pointing at shaders that no longer exist. +6. Report what exists before proposing any change, so the user can correct a wrong assumption early. + +## 3. Separate the three failure shapes + +Magenta and unlit are different faults with different fixes. Name which one you have before acting. + +| Shape | What it looks like | Where the fix lives | +|---|---|---| +| Shader not found or not compiled | Solid magenta or pink, often with a console error | Section 4 | +| Shader found but not lighting-aware | Renders its texture, but flat - no shadows, no response to lights | Section 5 | +| Shader correct, material or renderer wrong | Lights partly, but one aspect is missing | Section 6 | + +A magenta surface is Unity's error shader. It is not a lighting result and no lighting setting will change it. You MUST NOT adjust lights, ambient or exposure while any material is magenta, because it hides the real fault and changes the scene for everything else. + +## 4. Magenta or pink materials + +1. If the console shows a compile error, fix that first. The error names the file and line. +2. If there is no error, read the shader the material points at. A missing reference means the shader asset is gone - usually with the package that provided it. +3. For materials written for the Built-in Render Pipeline, use the [Render Pipeline Converter](https://docs.unity.com/en-us/engine//manual/render-pipelines/universal-render-pipeline/introduction/installing-and-configuring-urp/upgrading-from-birp/rp-converter.md) rather than reassigning shaders by hand. Converting in bulk preserves property mappings that a manual swap loses. +4. For materials from a removed HDRP package, reassign each material as [Convert shaders from HDRP to URP](https://docs.unity.com/en-us/engine//manual/render-pipelines/universal-render-pipeline/introduction/installing-and-configuring-urp/migrating-from-hdrp/convert-hdrp-shaders-to-urp.md) describes, say plainly that this is done by hand, and tell the user which properties could not be carried across. +5. For a Shader Graph asset, read its active target. A graph targeting a different pipeline compiles to nothing usable and renders magenta. +6. If the material renders correctly in the editor and magenta in a build, the shader was stripped. Check whether it is referenced only by name or from a `Resources` load. + +NEVER recreate the mesh, terrain or prefab. The geometry is intact; only the shader reference is broken. + +## 5. A custom shader receives no light or no shadows + +Work these in order, because a missing pass makes the keywords below it irrelevant. + +1. **Pass tags.** Read the renderer's rendering path first, then check the shader has a lighting pass for that path, using the tags [URP ShaderLab pass tags](https://docs.unity.com/en-us/engine//manual/materials-and-shaders/shaders/writing-custom-shaders-urp/use-built-in-shader-methods/urp-shaderlab-pass-tags.md) lists for it. Never call a pass missing before you have checked that page's tags for the path, because more than one tag is valid. +2. **Shadow casting.** If the object casts no shadow, check for the shadow caster pass that page lists before you touch the renderer's Cast Shadows setting, because that setting has no effect without the pass. +3. **Shadow receiving.** Check the shader declares the shadow keywords [Use shadows in a custom URP shader](https://docs.unity.com/en-us/engine//manual/materials-and-shaders/shaders/writing-custom-shaders-urp/use-built-in-shader-methods/shadows.md) lists, because a missing one raises no error: the shader compiles and drops shadows. +4. **Additional lights.** If only the directional light affects the surface, check the additional-light keywords [Render additional lights in a shader in URP](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting/custom-lighting/use-built-in-shader-methods-additional-lights-fplus.md) lists. +5. **Depth passes.** If the surface disappears when a depth prepass or SSAO is on, check for the depth passes the URP ShaderLab pass tags page lists. +6. **Meta pass.** If the surface adds nothing to a bake, check for a `Meta` pass, per [Meta pass](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting-birp/meta-pass.md). Unity reports a missing one as a named warning about a fallback material being used, so search the console for the material name before theorising. + +For a third-party shader you did not write, read its source before editing it, and tell the user you are modifying a vendor asset that an update will overwrite. + +## 6. The shader is right but the material still looks wrong + +| Symptom | Work these first | +|---|---| +| Point lights have no effect, directional works | The per-object additional-light limit per [Light limits in URP](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting/light-limits-in-urp.md), and whether the renderer is Forward or Forward+ | +| Lights work at a distance and drop out up close, or flicker | [Lights flicker or disappear](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting/ts-lights-flicker-disappear.md) | +| Metallic or smoothness has no visible effect | There is no environment reflection to be metallic against. Hand this to the environment workflow rather than raising the values | +| Diffuse lighting works, specular does not | [Missing specular response](https://docs.unity.com/en-us/engine//manual/lighting-overview/direct-and-indirect-lighting/lightmapping/baking-before-runtime/ts-missing-spec-response.md) | +| Transparent surface receives no shadow | Surface Type and Receive Shadows, per the [Lit shader reference](https://docs.unity.com/en-us/engine//manual/materials-and-shaders/built-in/shaders-in-universalrp/reference/lit-shader.md) | +| Emissive material lights nothing around it | [Emissive materials not rendering](https://docs.unity.com/en-us/engine//manual/lighting-overview/ts-emissive-mats-not-rendering.md) | +| Alpha clipping is enabled but the surface stays opaque | Read the material's Surface Type and its alpha clip threshold, and confirm the shader declares the alpha-clip keyword | + +## 7. Anti-hallucination constraints + +| Rule | Reason | +|---|---| +| Read the shader source or graph before describing what it does | A shader's name says nothing about which passes it declares | +| NEVER state a shader property, keyword or pass tag name from memory | These change between URP versions, and a wrong keyword fails silently rather than erroring | +| Distinguish a shader that fails to compile from one that compiles and is not lighting-aware | The first is magenta and the second is flat, and the fixes share nothing | +| NEVER report a material as fixed without reading back its shader assignment | A failed assignment leaves the old shader in place with no error | + +## 8. Terms + +Terms this workflow uses in a specific sense - key light, ambient, Contribute GI, light mode and the rest - are defined in `references/terms.md`. + +## 9. Worked example + +Reported: "the buildings render pink after we removed the HDRP package. Diagnose first, then repair only the confirmed broken materials." + +1. Context: Unity 6000.6, `PC_RPAsset` active, no quality-level override. +2. Console shows no compile errors, so this is a missing shader rather than a broken one. +3. The affected materials point at shader references that no longer resolve. The package list confirms the HDRP package is gone. +4. Report that the meshes and material values are intact and only the shader references are broken, because the user's instruction not to recreate anything depends on that being true. +5. Say plainly that each material is reassigned by hand, per the conversion page, and that some properties will not carry across. +6. Ask once which URP shader family the buildings should use, listing the options and what each costs, because that is a look decision and not a fault. +7. Assign the chosen shader, then read each material back to confirm the assignment applied. +8. Verify: zero console errors, then read each material's shader name, capture the Game view and look at it. Play mode is not needed for a shader assignment. + +## Verify + +If the user asked you to prove it works or you suspect a specific fault, do these after the Final step's console check and capture: + +1. Confirm no shader compile errors remain in the console. + +Because the reported symptom is visual, state which values you verified and ask the user to confirm the appearance. You MUST NOT claim a visual result is correct from state reads alone. + +If a check fails, go back and reread the relevant documentation from `references/topic-map.md` for what you missed. The cause is more often a missing pass or keyword than a wrong property value. + +## Report + +Include these in your final report: + +- Which of the three failure shapes this was, and the evidence for it. +- Every material and shader you changed, and what you deliberately left alone. +- The documentation pages you read, by URL. +- Any property that could not be carried across a pipeline change, named individually. +- What you verified from state, and what still needs the user's eyes. diff --git a/skills/light-scene/references/optimize.md b/skills/light-scene/references/optimize.md new file mode 100644 index 0000000..4474d45 --- /dev/null +++ b/skills/light-scene/references/optimize.md @@ -0,0 +1,143 @@ +# Optimize lighting for a platform + +Cut the runtime cost of lighting for a stated target platform, changing the cheapest settings first and saying what each one costs in appearance. + +Relative paths in this file, such as `references/terms.md`, resolve to the skill's root folder, not to this file's folder or the project. Other workflows are named by workflow, such as "the bake workflow"; the skill's workflow table gives each one's file. + +## Contents + +- Success criteria +- Important for this workflow +- Project conventions +- Confirm this is the right workflow +- Find out what is actually running +- Change in cost-effectiveness order +- Constraints +- Anti-hallucination constraints +- Terms +- Worked example +- Verify +- Report + +## Success criteria + +- The pipeline asset the target platform actually resolves to is the one read and edited, not the one the Editor happens to be using. +- Changes are made in cost-effectiveness order, one at a time, each re-read after writing. +- The visual cost of each change is stated so the art team can evaluate it. +- Lights are not deleted; realtime shadow casters and limits are reduced instead, and baked lights are recognised as already free. +- No frame-time gain is claimed that was not measured. + +## Important for this workflow + +- Do only what's asked. Pipeline assets and Quality Settings are shared by every scene in the project, so a change here is never scene-local. You MUST say which scenes are affected before editing one. +- WAIT for the user to name the target platform and an acceptable quality loss. Every change here trades appearance for cost, and without a target there is no way to judge the trade. + +## Project conventions + +Unity's manual describes what each setting does. It cannot tell you which quality tier THIS project ships to which platform. Before changing any value: + +1. Search the project for its own documentation on target platforms, performance budgets and quality tiers - for example a `Docs` folder or a technical specification - and read it. +2. Read every quality level and which pipeline asset each one resolves to. A project often has a tuned mobile asset that nothing actually references, which means the mobile build is silently using desktop settings. +3. Where a project convention and this workflow disagree, the project wins. Name the document you followed in your response. +4. Check what else references a pipeline asset before editing it. Editing the wrong one changes every scene and every platform. + +Do this because the most valuable finding here is usually a wiring mistake, not a value that needs lowering. + +## 1. Confirm this is the right workflow + +| Request | Handle here? | +|---|---| +| Lighting is too expensive, or the frame rate drops on a platform | Yes | +| Tune lighting for mobile, or for a specific quality tier | Yes | +| A scene has no lighting yet | No - use the set-up workflow | +| A scene looks wrong or shadows are missing | No - use the diagnose workflow | +| The user wants a different mood or time of day | No - use the style workflow | +| Bake lighting to reduce realtime cost | Partly - decide the strategy here, then hand the bake to the bake workflow | + +## 2. Find out what is actually running + +Change nothing during this step. Report what you find before proposing any change. + +1. If the request does not name the target platform and the quality loss the user accepts, ask for both and WAIT for the answer, because the rest of this section reads that platform's settings. +2. List every quality level and the pipeline asset each resolves to, per [Set the render pipeline asset](https://docs.unity.com/en-us/engine//manual/render-pipelines/choose-a-render-pipeline/srp-setting-render-pipeline-asset.md). +3. Check for a pipeline asset that exists but is referenced by nothing. That is a common and expensive mistake: a tuned mobile asset that no quality level points at means the mobile build ships desktop settings. +4. For the asset the target platform actually resolves to, read shadow distance, cascade count, shadow resolution, soft shadow setting, additional-light limit, render scale and rendering path. +5. Read the scene's realtime light count and how many cast shadows. + +## 3. Change in cost-effectiveness order + +Work down this list in order, because the early entries usually give up the least visible quality for what they cost; stopping early is a valid outcome. The order is guidance, not a measurement, so never describe a change in your report as saving frame time, or as the biggest saving. + +| Order | Change | What it costs you | +|---|---|---| +| 1 | Point the target platform's quality level at the correct pipeline asset | Nothing, if one was mis-wired. This is a fix, not a trade | +| 2 | Reduce shadow distance | Distant shadows disappear | +| 3 | Reduce cascade count | Shadow quality at distance. Pairs naturally with a shorter shadow distance | +| 4 | Soft Shadows to Hard | Shadow edges harden. Significant on tile-based mobile, per [Optimize shadow rendering in URP](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting/shadows-in-urp/shadows-optimization.md) | +| 5 | Reduce shadow resolution | Shadow crispness everywhere | +| 6 | Lower the additional-light limit, or stop secondary lights casting realtime shadows: switch a light that never moves or changes from Mixed to Baked with its shadows on and re-bake, or turn off additional-light shadows on the target tier's pipeline asset | Moving objects lose those lights' realtime shadows and highlights, and lights past the limit are downgraded | +| 7 | Move static lighting to baked | Iteration time, and a bake becomes required. Run it as the bake workflow describes | +| 8 | Reduce render scale | Overall image sharpness. Affects everything, not just lighting | + +When the user has named the target platform and the loss they accept, make the first change in this table that stays inside this scene in the same pass, and list the changes to shared assets for approval, each with its visual cost from the table. If the limit the user asked for is already met on their target, say so and still make that change, because they asked for the cost to come down. + +After each change, re-read the value rather than assuming the write applied, and state what it cost visually. + +## 4. Constraints + +| Rule | Reason | +|---|---| +| NEVER edit a pipeline asset without first saying which quality levels and scenes use it | These assets are project-wide, and the change will reach every scene | +| NEVER tune the asset the editor happens to be using | The editor may resolve to a different quality level than the target platform | +| ALWAYS state the appearance cost of each change | An optimisation the art team cannot evaluate will be reverted | +| Change one setting at a time and re-read it | Several changes at once make it impossible to attribute the saving | +| NEVER set a Mixed light's Shadow Type to None to save shadow cost | On a quality level that renders additional-light shadows, the light also loses the shadows the bake stored for it, so its light spills into areas that were shadowed. The next bake gives it no shadowmask channel, so every tier loses them. Switch a light that never moves or changes to Baked with its shadows on instead, or reduce shadows on the target tier's pipeline asset | +| NEVER switch a light to Baked while anything changes it at runtime | A Baked light gives no realtime direct light, so a script or animation that changes its intensity, colour or enabled state stops having any visible effect. Search the project's scripts and animation clips for anything that drives the light first, and keep a changing light Mixed or Realtime | +| Do not claim a performance gain you have not measured | You can state what a setting costs in principle; you cannot state the frame time without profiling | +| Say when a change is written to disk | `SerializedObject.ApplyModifiedProperties` on a pipeline or quality asset marks it dirty, and the Editor saves it on exit even if the scene is never saved. That is the right API for an approved change and the wrong one for an experiment | + +## 5. Anti-hallucination constraints + +| Rule | Reason | +|---|---| +| Read the resolved pipeline asset, not the Graphics Settings default | A quality level can override it, so the default is often not what runs | +| Do not quote frame-time numbers for a setting | Cost depends on scene, resolution and hardware, and an invented figure is worse than none | +| Say which on-disk assets a change touches before making it | `LightProbes.bakedProbes` writes to `LightingData.asset` the moment it is assigned, and `SerializedObject.ApplyModifiedProperties` on a pipeline, quality or Volume asset marks it dirty so the Editor saves it on exit. Declining to save the scene undoes neither | + +## 6. Terms + +Terms this workflow uses in a specific sense - key light, ambient, Contribute GI, light mode and the rest - are defined in `references/terms.md`. + +## 7. Worked example + +Requested: "Lighting is killing our frame rate on Android." + +1. Read the quality levels. There is one level, "High", with no custom pipeline asset, so it inherits the desktop asset from Graphics Settings. +2. There is a mobile pipeline asset in the project that **nothing references**. Report this first: the Android build is running desktop lighting settings, and no amount of value tuning fixes that. +3. Ask whether the mobile asset is the intended target and what quality loss is acceptable. WAIT. +4. Wire the mobile quality level to the mobile asset. Re-read to confirm which asset now resolves. +5. Compare the two assets and report the differences that now apply - shadow distance 200 to 50, resolution 2048 to 1024, Soft to Hard shadows, render scale 1.0 to 0.8 - as appearance changes the art team should review. +6. Stop there and let them look, rather than tuning further in the same pass. + +## Verify + +If the user asked you to prove it works or you suspect a specific fault, do these after the Final step's console check and capture: + +1. Read back which pipeline asset each quality level resolves to, and confirm the target platform's level points where you intended. +2. Capture with the target platform's quality level active, because the Editor's current level may resolve to a different pipeline asset than the one you edited. +3. If you changed a light rather than a pipeline asset, also capture with each other quality level that renders this scene active, because a light change that is invisible on the target tier can show on another. +4. Make the quality level that was active before these captures active again, because the Editor stores its active level in the project's quality settings, which the user did not ask you to change. + +You MUST NOT claim a frame-rate improvement you have not measured. State what you changed and what it costs in appearance, and ask for a profiled comparison on the target device. + +If a check fails, go back and reread the relevant documentation from `references/topic-map.md`. The most common mistake is tuning an asset the target platform does not resolve to. + +## Report + +Include these in your final report: + +- Which pipeline asset each quality level resolved to before and after. +- Any asset that was mis-wired or unreferenced. +- Each setting you changed or propose to change, and what it costs visually. +- The documentation pages you read, by URL. +- That the saving needs profiling on the target device to be confirmed. diff --git a/skills/light-scene/references/pipeline-notes.md b/skills/light-scene/references/pipeline-notes.md new file mode 100644 index 0000000..9f8b812 --- /dev/null +++ b/skills/light-scene/references/pipeline-notes.md @@ -0,0 +1,46 @@ +# Pipeline notes + +The workflows are written for URP. On the Built-in Render Pipeline or HDRP the order of work is the same, but many settings live somewhere else and some values mean something else. This file sends each step to the page that documents it for that pipeline, and adds only the decisions those pages leave to you. Read the page for the step you are on before you change anything, because the facts belong to the pipeline and its version, not to this skill. + +## Contents + +- Built-in Render Pipeline +- High Definition Render Pipeline + +## Built-in Render Pipeline + +| When a workflow step works on | Read instead | +|---|---| +| A pipeline asset's shadow, light-limit or render-scale settings | [Quality settings](https://docs.unity.com/en-us/engine//manual/unity-editor/editor-settings-reference/comp-manager-group/class-quality-settings.md) for each quality level, because Built-in has no pipeline asset, and [Rendering paths in the Built-in Render Pipeline](https://docs.unity.com/en-us/engine//manual/render-pipelines/built-in-render-pipeline/built-in-rendering-paths.md) for the per-object light limit | +| Shadow distance or cascades | [Shadow distance](https://docs.unity.com/en-us/engine//manual/lighting-overview/shadows/shadow-realtime/shadow-distance.md) and [Shadow cascades](https://docs.unity.com/en-us/engine//manual/lighting-overview/shadows/shadow-realtime/shadow-cascades/shadow-cascades.md) | +| A Volume, exposure, tonemapping or a grade | [Post Processing Stack v2](https://docs.unity3d.com/Packages/com.unity.postprocessing@/manual/index.html) and its [Color Grading](https://docs.unity3d.com/Packages/com.unity.postprocessing@/manual/Color-Grading.html), if the project has that package | +| Probes for moving objects | [Light Probe Group](https://docs.unity.com/en-us/engine//manual/lighting-overview/direct-and-indirect-lighting/light-probes/class-light-probe-group.md) | +| The lighting mode of a bake | [Lighting Mode](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting-light-sources/components/configuring/lighting-mode/lighting-mode.md) and the [render pipeline feature comparison](https://docs.unity.com/en-us/engine//manual/render-pipelines/choose-a-render-pipeline/feature-comparison.md) | +| A custom shader's passes | [Pass tags](https://docs.unity.com/en-us/engine//manual/materials-and-shaders/shaders/reference/sl-reference/sl-sub-shader-pass/sl-pass-tags.md), [Surface shaders](https://docs.unity.com/en-us/engine//manual/materials-and-shaders/shaders/writing-shaders-birp/writing-surface/sl-surface.md) and [Meta pass](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting-birp/meta-pass.md) | +| Sky, ambient, reflections or fog | [Lighting window reference](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting-reference/lighting-window.md), [Using skyboxes](https://docs.unity.com/en-us/engine//manual/creating-environments/sky/skyboxes-using.md) and [Reflection Probe component](https://docs.unity.com/en-us/engine//manual/lighting-overview/reflections/class-reflection-probe.md) | + +Decisions on Built-in: + +- If the project has no post-processing package, say so and build the look from lights and ambient, because there is no Volume to grade with. +- Map a URP or HDRP material to a Built-in shader by hand, and list what did not carry over, because no converter works in that direction. + +## High Definition Render Pipeline + +| When a workflow step works on | Read instead | +|---|---| +| Light intensity | [Physical light units](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@/manual/Physical-Light-Units.html) and [Light component](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@/manual/Light-Component.html) | +| Exposure | [Exposure](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@/manual/Override-Exposure.html) | +| The sky, ambient or environment | [Visual Environment](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@/manual/Override-Visual-Environment.html), [Create an HDRI sky](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@/manual/create-an-hdri-sky.html), [Create a physically based sky](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@/manual/create-a-physically-based-sky.html), [Create a gradient sky](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@/manual/create-a-gradient-sky.html) and [Environment lighting](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@/manual/Environment-Lighting.html) | +| Shadow distance, cascades or resolution | [Shadows](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@/manual/Override-Shadows.html) and [HDRP Asset](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@/manual/HDRP-Asset.html) | +| A feature that does nothing | [Frame Settings](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@/manual/Frame-Settings.html) | +| Shadowmask, probes or reflections | [Shadowmask](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@/manual/Lighting-Mode-Shadowmask.html), [Use Adaptive Probe Volumes](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@/manual/probevolumes-use.html), [Reflection Probe](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@/manual/Reflection-Probe.html), [Planar Reflection Probe](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@/manual/Planar-Reflection-Probe.html) and [Screen Space Reflection](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@/manual/Override-Screen-Space-Reflection.html) | +| Fog, tonemapping or Volumes | [Fog](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@/manual/fog.html), [Volumetric lighting](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@/manual/Volumetric-Lighting.html), [Tonemapping](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@/manual/Post-Processing-Tonemapping.html) and [Understand volumes](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@/manual/understand-volumes.html) | +| Render scale | [Dynamic resolution](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@/manual/Dynamic-Resolution.html) | +| Magenta materials or a custom shader | [Convert a project from the Built-in Render Pipeline](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@/manual/convert-project-from-built-in-render-pipeline.html) and [Lit material](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@/manual/lit-material.html) | + +Decisions on HDRP: + +- Set exposure before you judge any light, because under the wrong exposure correct lights read black or blown. +- Never copy an intensity from a URP scene, because HDRP measures light in physical units. Set each light from its role, using the units page. +- When a feature does nothing, check Frame Settings before you change the feature, because a camera can switch it off. +- Before a bake, check that the sky reaches the bake as the Environment lighting page describes, because otherwise the bake has no sky light. diff --git a/skills/light-scene/references/project-conventions.md b/skills/light-scene/references/project-conventions.md new file mode 100644 index 0000000..f20ffd3 --- /dev/null +++ b/skills/light-scene/references/project-conventions.md @@ -0,0 +1,23 @@ +# When project sources disagree + +A project's own documentation often contradicts itself, or contradicts what its scenes and assets +actually ship. The user usually does not know. Treat a disagreement as a finding, not as noise to +resolve silently. + +1. **Name it.** State both values and where each came from - which document, which scene or + asset. A conflict the user cannot see is a conflict they cannot fix. +2. **Ask only if it changes what they will see.** Colour, brightness, whether shadows exist, time + of day, which sky, or whether a surface is opaque are worth one question. Ask it as a single + question with the actual options and what each one costs, never open-ended. Do NOT ask about a + difference with no visible effect; pick one and move on, because a skill that stops on every + ambiguity is worse than one that guesses on trivia. +3. **If you cannot ask, or it is not material, apply this precedence and say you did:** the + written direction states intent and wins; a value shipped in a scene or asset tells you what the + project actually renders. Where they differ, follow the written direction and report the + shipped value as either drift to fix or an undocumented decision. +4. **Offer to record the answer.** Once a conflict is resolved, offer to write the resolution + into the project's own documentation so the next person does not rediscover it. You MUST NOT + edit the user's documentation without them agreeing to it first. + +Do this because an unrecorded conflict is rediscovered on every task, and a silent choice is +unreviewable - nobody can tell a considered decision from a coin toss. diff --git a/skills/light-scene/references/set-up.md b/skills/light-scene/references/set-up.md new file mode 100644 index 0000000..edf1a9e --- /dev/null +++ b/skills/light-scene/references/set-up.md @@ -0,0 +1,198 @@ +# Set up scene lighting + +Build a lighting setup for a URP scene from nothing, in the order Unity expects, asking for the intended look rather than guessing it. + +Relative paths in this file, such as `references/terms.md`, resolve to the skill's root folder, not to this file's folder or the project. Other workflows are named by workflow, such as "the bake workflow"; the skill's workflow table gives each one's file. + +## Contents + +- Success criteria +- Important for this workflow +- Project conventions +- Confirm this is the right workflow +- Gather project context +- Ask for the three things you cannot infer +- Adding a single light to a scene that is already lit +- Build the setup in order +- Anti-hallucination constraints +- Terms +- Worked example +- Verify +- Report + +## Success criteria + +- The environment is set before the first light, and exactly one directional light acts as key. +- The key casts shadows; a reflection probe exists if anything in view is metallic or smooth. +- If any light is Baked or Mixed the bake has run and lightmaps exist; otherwise the setup is stated to be fully realtime. +- Intensity was calibrated by rendering and looking at every area the user will see, interiors included, not copied from a sibling scene. +- The three questions the setup depends on were either answered in the prompt or asked once, together, before any value was chosen. + +## Important for this workflow + +- Do only what's asked. You MUST NOT change unrelated assets or files, because pipeline and quality settings are shared across every scene in the project. +- A component cannot be destroyed while another on the same GameObject declares `[RequireComponent]` on it, and Unity refuses without throwing an exception, so a `script eval` snippet that tries it still appears to succeed. URP attaches `UniversalAdditionalLightData` to every Light, so removing a Light means removing that first. Re-read the count afterwards: a destroy that quietly did nothing looks identical to one that worked. +- WAIT for the user to state the intended look before choosing values. Time of day, mood and colour temperature are art decisions with no correct default, and guessing wastes the work. + +## Project conventions + +Unity's manual describes how lighting works. It cannot tell you what THIS project has already +decided. Before changing any value: + +1. Search the project for its own documentation on lighting and art direction - a `Docs` + folder, a style guide, a technical design document - and read it. +2. Open a sibling scene that is already lit and read its rig: light count, colour, intensity and + mode, ambient source, fog, and any bound Volume. Read its shadow and bake policy too - they + decide each other, because a baked scene pays no runtime cost for shadows and can afford far + more shadow casters than a realtime rig. Match the project's structure unless you have a + stated reason not to. +3. Where a project convention and this workflow disagree, the project wins. Name the document you + followed in your response. +4. If the project documents a scene-lighting ownership rule, obey it. A scene with no lights is + sometimes deliberate, and "fixing" it can silently break the arrangement. + +**Light mode, shadow policy and bake policy are conventions** - copy them. **Intensity, colour +and range are not**: they follow this scene's own materials, sky and mood, so take a light's +colour from what emits it HERE - a fixture's emissive material, the sky, a screen - not from a +sibling lit for another time of day. + +Do this because a setup that is correct in general can still be wrong for a project that has +already decided these things - the most common reason this work gets rejected. + +## 1. Confirm this is the right workflow + +| Request | Handle here? | +|---|---| +| A scene has no lighting, or only a default light, and needs a setup | Yes | +| Add or adjust one light in an already-lit scene - a lamp, fire, torch or other practical | Yes | +| A scene is already lit and looks wrong | No - use the diagnose workflow | +| The setup exists and the user wants a different mood or time of day | No - use the style workflow | +| Run or configure a bake on an existing setup | No - use the bake workflow | +| Tune lighting cost for a specific platform | No - use the optimize workflow | +| The sky, environment reflections or fog need setting up or repairing | No - use the environment workflow | +| A material renders magenta, or a custom shader receives no light | No - use the materials workflow | + +## 2. Gather project context + +Change nothing during this step. + +1. Read the Unity version and the active render pipeline asset. +2. Check whether the current quality level overrides the pipeline asset, per [Set the render pipeline asset](https://docs.unity.com/en-us/engine//manual/render-pipelines/choose-a-render-pipeline/srp-setting-render-pipeline-asset.md), because a project can render through a different pipeline asset per quality level. +3. Name the active pipeline. The steps below are written for URP; on Built-in or HDRP apply the substitutions in `references/pipeline-notes.md` as you go - the shape of the work is the same, the places the settings live are not. +4. Find existing lights with the query `t:Light`, and read the scene's Environment Lighting Source and Intensity Multiplier. +5. If the scene already has a considered setup and the request is not to add one light, hand off to the diagnose workflow: a second setup on top of an existing one produces conflicting shadows. A request to add one light continues at section 4. + +## 3. Ask for the three things you cannot infer + +Ask these together, in one message, and WAIT for the answer. Each one changes the values you would choose, so guessing means redoing the work. + +| Question | Why it changes the setup | +|---|---| +| What is the intended look - time of day, indoor or outdoor, mood? | Determines key light direction, colour temperature and intensity. There is no default. | +| Is the level geometry static, or does it move? | Static geometry can be baked; moving geometry cannot, and needs probes instead. | +| What is the target platform? | Mobile and tile-based platforms pay a real cost for Soft Shadows and extra realtime lights, per [Optimize shadow rendering in URP](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting/shadows-in-urp/shadows-optimization.md). | + +If the user says to just pick something, choose a neutral daylight exterior, say so explicitly, and tell them which values to change to move it. + +## 4. Adding a single light to a scene that is already lit + +A request for one light is not a request to relight the scene. Change nothing else. + +1. Read the existing rig first. A new light has to sit inside the established key, fill and ambient, not compete with it. +2. Choose the type from what the light represents, per [Light component types](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting-light-sources/components/lighting.md), and, outside HDRP, use an area light only in a baked scene, because that page says area lights can only be baked. +3. Set range before intensity. Range decides what the light touches; intensity only how strongly. Compensating for a wrong range with intensity gives a light too bright at the source and still dark at the edge. +4. Match the project's palette rather than inventing a colour; a practical is usually warmer than the key. Set warmth as a colour temperature in kelvin and put any visible fixture geometry on a layer the camera renders, both per the constraints in section 6. +5. Check the additional-light budget first, per [Lights flicker or disappear](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting/ts-lights-flicker-disappear.md): a light past the limit is silently downgraded or dropped, and gets reported as a bug. Shadows follow the light mode: a **Baked or Mixed** practical keeps its shadows on, because the bake stores its shadows on static geometry in the lightmaps or the shadowmask, and turning them off loses those too; only a **Realtime** practical goes without shadows by default, turned on only to describe form. Read the scene's policy before throttling: a realtime shadow budget imposed on a baked scene silently deletes most of its shadows. +6. If the scene is baked, match the surrounding rig's mode and bake afterwards - do not leave it half-applied. + +## 5. Build the setup in order + +Work through [Lighting configuration workflow](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting-configuration-workflow.md) and follow its order. Later stages depend on earlier ones, so a stage done out of order usually has to be redone. + +1. **Environment first.** Set the Environment Lighting Source and Intensity Multiplier, or confirm that the current values suit the look, before you add or change any light - including a default light the scene already has. Ambient sets the floor that every light adds on top of, and judging a light against a black ambient gives the wrong intensity. +2. **One key light.** Add a single directional light as the sun or main source. Use exactly one, because a second directional light casts a second set of shadows and reads as a rendering error rather than a lighting choice. +3. **Shadows on the key light.** Enable shadows and check the result against [Shadow configuration](https://docs.unity.com/en-us/engine//manual/lighting-overview/shadows/shadow-configuration.md). On a mobile target prefer Hard Shadows unless the user asked for soft ones. +4. **Secondary lights only where they do work.** Add point or spot lights only for features the key light cannot reach; the additional-light budget in section 4 applies. +5. **Reflection probe if anything is glossy.** Metallic and smooth surfaces render black or wrong without one, per [Reflection Probes](https://docs.unity.com/en-us/engine//manual/lighting-overview/reflections/reflection-probes.md). +6. **Decide light modes, then probes.** Use the matrix in [Choose a light mode](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting-light-sources/components/configuring/light-modes/choose.md). If geometry is static and baked quality is wanted, set it to contribute GI, choose Baked or Mixed, then give moving objects probes so they still receive that light, following the bake workflow section 3, which reads the pipeline asset's probe system before it chooses between [Adaptive Probe Volumes](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting/probevolumes/use.md) and a [Light Probe Group](https://docs.unity.com/en-us/engine//manual/lighting-overview/direct-and-indirect-lighting/light-probes/light-probes.md), because a Light Probe Group does nothing while that asset enables Adaptive Probe Volumes. +7. **Finish the bake if the setup depends on one.** Until a bake runs, the scene renders only the realtime half of the setup. Read what this Unity version bakes without being asked in the [Unity 6 upgrade guide](https://docs.unity.com/en-us/engine//manual/upgrade-guides/upgrade-guide-unity6.md) and the [Lighting window reference](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting-reference/lighting-window.md). + + Decide which of these you are in, and say which: + + - **Restoring a baked scene, or lighting static geometry you set to Baked or Mixed.** Run the bake; it is part of the work. Call the synchronous `Lightmapping.Bake()`, because `BakeAsync()` returns before anything is baked, and check that it returns `true`, because a failed bake leaves any earlier lightmaps in place. + + NEVER skip the bake because you cannot save the scene: the bake writes its lightmaps and `LightingData.asset` as **assets**, live the moment it finishes, and only the scene's own reference to that asset needs the save. Bake, then say what still needs saving. + - **If the project's authored settings are too slow, bake at draft quality rather than skipping it** - a few texels per unit and one bounce resolves in seconds and still gives real shadows, GI and probe reflections. If the scene already has lightmaps, ask before you bake the draft, because it replaces them. Put the draft values in a separate lighting settings asset, so the project's own settings stay as they were for the final bake. Say it is a draft and name the production settings. + - **Nothing in the scene can contribute GI yet**, such as a level with no static geometry so far. Do not bake, because there is nothing for the bake to work on; say that the setup needs a bake once static geometry is in. + - **Entirely realtime.** Nothing to bake; say so. + +After each stage, re-read the values you wrote rather than assuming the write applied. + +### Calibrate intensity against the render + +Intensity is the value you are most likely to get wrong and the one a state read cannot check - +every number looks plausible in the Inspector. Treat your first intensity as a guess and correct +it from the image. + +1. Render once the setup is in place, and judge the mid-tones rather than the highlights. A scene + is too dark when surfaces that should read white read grey and shadows carry no detail. +2. Raise the key light and the environment together, then render again. Indirect bounce scales + with the key, so a weak key leaves the scene flat however many practicals you add. +3. Say which intensities you measured and which you guessed, and name the first one to tune. + +### When a grade tuned for another time of day hides the result + +A scene's Volumes can carry exposure and white balance tuned for the look it had before, such as a night grade. Under a new daytime setup that grade can leave whole areas wrong however the lights are set - typically interiors that stay black. Check every area the user will look at, not only the main view. If one still reads wrong after calibration because of a grade: + +1. Read the exposure and white balance of each Volume profile that applies there. +2. Copy that profile to a new asset for this scene, assign the copy to the scene's Volume, and set exposure and white balance in the copy for the new look. Leave the original untouched, because other scenes may share it. +3. Render the area again and calibrate against it. +4. Report the copy, the values you changed and why, and that the original is unchanged, so the user can keep either. + +Do not raise light intensities to fight a grade, because the lights then read wrong as soon as the grade is fixed. + +## 6. Anti-hallucination constraints + +| Rule | Reason | +|---|---| +| NEVER rely on Auto Generate to produce baked lighting | It was removed in Unity 6, per the [Unity 6 upgrade guide](https://docs.unity.com/en-us/engine//manual/upgrade-guides/upgrade-guide-unity6.md); run the bake explicitly and save the lighting data asset it writes | +| Do not add a second directional light to raise brightness | Raise the existing light's intensity or the environment contribution instead; a second sun produces conflicting shadows | +| Do not treat "Baked Global Illumination is enabled" as "the scene is baked" | The first is a setting; only a completed bake produces lightmaps | +| NEVER set a Volume override parameter's `.value` without setting `.overrideState = true` first | A parameter whose `overrideState` is false is ignored entirely: the profile displays the value and the render does not change. The result looks like a pipeline fault, which it is not | +| Before creating any visible object, read the rendering camera's `cullingMask` and put the object on the layer of the thing it belongs to | NEVER assume the Default layer renders. In a project that culls it the object exists, is enabled, has bounds, and never draws - and a state read looks perfect | +| For warm or cool light prefer `useColorTemperature = true` and `colorTemperature` in kelvin over a hand-picked RGB | A temperature names the source the user described, and with a temperature in use the light's `color` is a filter that tints it, per the [URP Light component reference](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting/light-component.md), so read both when checking warmth | +| For Volume scripting beyond setting a value, follow the `urp-postprocessing` skill | Edit `volume.sharedProfile` (the asset, so it persists), not `volume.profile` (a runtime clone that is never saved), and an override added in editor code needs `AssetDatabase.AddObjectToAsset` to survive a reload - otherwise the grade shows in the Inspector and vanishes when the asset reloads | + +## 7. Terms + +Terms this workflow uses in a specific sense - key light, ambient, Contribute GI, light mode and the rest - are defined in `references/terms.md`. + +## 8. Worked example + +Requested: "This level has no lighting at all, can you set it up? It's an outdoor daytime scene, the terrain is static, PC only." + +1. Context: `PC_RPAsset` active, no override; `t:Light` returns zero lights; ambient is Color at 0.02. +2. The three questions are answered in the request; do not ask again. +3. Environment first: source to Skybox, Intensity Multiplier to 1. +4. Key light: one directional, warm white, pitched down ~50 degrees, intensity near the URP default. +5. Shadows: enable Soft Shadows, since the target is PC rather than mobile. +6. Glossy surfaces present: add a reflection probe over the play area. +7. Terrain is static and quality is wanted: contribute GI, key light Mixed, add light probes for movers. +8. Run the bake, at draft quality if the authored settings are slow, and say which you ran. +9. Verify: re-read every value, confirm zero console errors, then render and look at the result. + +## Verify + +Because lighting is judged by eye, state which values you set and ask the user to confirm the look. You MUST NOT claim the result matches their intent from state reads alone. + +If a check fails, go back and reread the relevant documentation from `references/topic-map.md` for what you missed. A stage completed out of order is a more common cause than a wrong value. + +## Report + +Include these in your final report: + +- What the scene had before. +- Each stage you completed, in order, and the values you set. +- The documentation pages you read, by URL. +- Whether a bake is still required, and that it is a separate step. +- Which values the user is most likely to want to adjust to move the look. diff --git a/skills/light-scene/references/style.md b/skills/light-scene/references/style.md new file mode 100644 index 0000000..b4ed624 --- /dev/null +++ b/skills/light-scene/references/style.md @@ -0,0 +1,161 @@ +# Style scene lighting + +Move a working lighting setup to a different mood or time of day, changing look rather than repairing fault. + +Relative paths in this file, such as `references/terms.md`, resolve to the skill's root folder, not to this file's folder or the project. Other workflows are named by workflow, such as "the bake workflow"; the skill's workflow table gives each one's file. + +## Contents + +- Success criteria +- Important for this workflow +- Project conventions +- Confirm this is the right workflow +- Establish the target before touching anything +- Change in this order +- Constraints that keep a mood pass reviewable +- Anti-hallucination constraints +- Terms +- Worked example +- Verify +- Report + +## Success criteria + +- The mood came from key colour and angle, then ambient, then shadows, then tonemapping, then grading - in that order. +- No light was added or removed, and no intensity was raised more than 20% without saying so. +- Every Volume parameter that was meant to take effect has `overrideState` on, and the render was checked to confirm the grade landed. +- A documented palette's values are kept where one exists. +- If the scene's lights are Baked or Mixed, the bake was re-run so the new mood is not sitting under stale daylight lightmaps. + +## Important for this workflow + +- Do only what's asked. You MUST NOT change unrelated assets or files. Volume profiles and pipeline assets are frequently shared between scenes, so check what else references one before editing it. +- WAIT for a reference before choosing values. Mood is an art decision with no correct default. An image, a named time of day, or a documented palette is the difference between one pass and five. + +## Project conventions + +Unity's manual describes how the controls work. It cannot tell you what look THIS project is aiming at, and that is the whole subject of this workflow. Before changing any value: + +1. Search the project for its own art direction - a style guide, visual rules, a colour palette, reference images. Read it. A documented palette outranks your judgement of what looks good. +2. Open a sibling scene that already has the intended look and read its values: key colour and angle, ambient, fog, and the Volume profile it uses. + Copy its **mode, shadow and bake policy and Volume structure**. Do NOT copy its intensity or colour: + those follow this scene's own materials, sky and mood, and a sibling lit for another time of day + will look careful while being wrong. Judge them against this scene's render instead. +3. Where a project convention and this workflow disagree, the project wins. Name the document you followed in your response. +4. If the project's documentation contradicts itself or marks something unresolved, do NOT silently pick a side. Say which choice you made and flag the open question. + +Do this because a mood change judged only by taste is unreviewable, while one traceable to the project's own palette can be argued with. + +## 1. Confirm this is the right workflow + +| Request | Handle here? | +|---|---| +| Make the scene feel like sunset, night, overcast, golden hour | Yes | +| Warm up, cool down, or match a reference or art style | Yes | +| The scene has no lighting at all | No - use the set-up workflow | +| The scene looks broken, blown out, or shadows are missing | No - use the diagnose workflow | +| Configure or troubleshoot a bake with no mood change | No - use the bake workflow | +| The skybox is missing, will not change, or nothing reflects the sky | No - use the environment workflow | + +A useful test: if the current look is a *fault*, it is not this workflow. This workflow assumes the setup works and the intent has changed. + +## 2. Establish the target before touching anything + +Change nothing during this step. + +1. Read the current key light colour, intensity and angle; the ambient source and colour; fog; and every Volume override in effect. +2. Establish the target. Ask for a reference image, a named time of day, or point at the project's documented palette. WAIT for the answer. +3. Check tonemapping first. If tonemapping is None with HDR on, values above 1 clip to white and no amount of colour work will read correctly. Say so before proceeding, because it changes what every later value does. +4. Report the current values and the target you are working to, so the user can correct the brief before you spend a pass on it. +5. If the user asks to restore an earlier mood and no reference, sibling scene or documented palette records it, say the original is unrecoverable, then offer an approximation from their description - and never present that approximation as a restore. + +## 3. Change in this order + +Mood comes mostly from the first two steps. Working bottom-up from post-processing produces a scene that looks graded rather than lit. + +1. **Key light colour and angle.** Time of day is mostly sun elevation. A low sun gives long shadows and warm light; a high sun gives short shadows and neutral light. Change the angle before reaching for a colour filter. + Set warmth with `useColorTemperature = true` and `colorTemperature` in kelvin rather than an + RGB guess, so the light reads as the source the mood describes. +2. **Ambient.** Set the shadow colour and the overall cool or warm balance. Warm key against cool ambient reads as daylight; both warm reads as interior or sunset. +3. **Shadow softness and strength.** Overcast is soft and low-contrast; midday is hard and high-contrast. Shadow strength below 1 lifts blacks without touching the light. +4. **Tonemapping.** Set it before grading, because it determines how highlights roll off. +5. **Colour grading.** Last, and sparingly. It corrects the image; it does not light the scene. + Every Volume parameter you mean to take effect needs `overrideState = true` as well as a + value; a parameter with it off is ignored and the profile still displays your number. Set the + state, then re-render and confirm the grade landed before moving on. +6. **Fog, bloom, vignette.** Atmosphere, last of all, and only if the project uses them. +7. **Re-bake if the scene is baked.** If the scene carries lightmaps and you moved or recoloured a Baked or Mixed sun, re-bake as part of this pass with the scene's own lighting settings, because under the old lightmaps the bounce light still describes the previous time of day and the mood reads as a tint over daylight. Say which files the bake writes - `LightingData.asset`, the lightmaps and the reflection probes in the scene folder - before running it. If those settings would make the bake too slow for this pass, ask before baking at draft quality instead, because a draft replaces the production lightmaps. If the user agrees, call the result a preview and leave the scene's own settings in place for the final bake. Hand off to the bake workflow only when the user asks about bake configuration itself. + +After each change, re-read the affected value rather than assuming the write applied. + +### Calibrate the sun angle against the render + +A low sun is the whole point of an evening look, and it is the change most likely to be silently +undone by the building: geometry that was irrelevant at noon blocks a sun at 15 degrees, and the +main surfaces fall into flat shade. That is not visible in any state read - the rotation you set +is the rotation you get, and the scene still looks wrong. + +Treat your first sun elevation as a guess and correct it from the image. + +1. Render, then check whether direct light actually reaches the surfaces the shot is about - + the floor, the wall the camera faces. Look for a cast shadow pattern; if nothing casts, no + direct light is arriving. +2. If the main surfaces are in flat shade, raise the elevation in steps and re-render until + light lands, then stop at the lowest angle that still lights them. +3. NEVER compensate for a blocked sun by raising intensity, warming the ambient or pushing the + grade. Those brighten the shade without restoring the direction, and the result reads as + overcast tinted orange rather than as evening. +4. Say which elevation you tried, which you settled on, and why. + +## 4. Constraints that keep a mood pass reviewable + +| Rule | Reason | +|---|---| +| NEVER raise key intensity to make a scene feel brighter in mood terms | Intensity past the tonemapping range clips detail to white; use exposure or ambient instead. If the Volume has no Tonemapping override (mode None) there is no range at all - anything above 1.0 clips - so read that first | +| NEVER edit a shared Volume profile or pipeline asset without saying so | One profile often serves several scenes, and the change will appear in all of them | +| ALWAYS keep a documented palette's values when one exists | A mood pass that ignores the palette will be reverted | +| NEVER use pure black or pure white if the project's rules forbid them | Many stylised projects cap both ends deliberately | +| Change one layer at a time and re-read it | Mood work compounds, and a wrong value found late costs the whole pass | + +## 5. Anti-hallucination constraints + +| Rule | Reason | +|---|---| +| Read every value before changing it | Mood values are almost never at their defaults | +| Do not claim a colour reads warm or cool without reading the resolved ambient | Ambient mode changes how a colour is applied, so the swatch alone does not tell you the result | +| NEVER set a Volume override parameter's `.value` without setting `.overrideState = true` first | A parameter whose `overrideState` is false is ignored entirely: the profile displays the value and the render does not change. The result looks like a pipeline fault, which it is not | +| For warm or cool light prefer `useColorTemperature = true` and `colorTemperature` in kelvin over a hand-picked RGB | A temperature names the source the user described, and with a temperature in use the light's `color` is a filter that tints it, per the [URP Light component reference](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting/light-component.md), so read both when checking warmth | +| For Volume scripting beyond setting a value, follow the `urp-postprocessing` skill | Edit `volume.sharedProfile` (the asset, so it persists), not `volume.profile` (a runtime clone that is never saved), and an override added in editor code needs `AssetDatabase.AddObjectToAsset` to survive a reload - otherwise the grade shows in the Inspector and vanishes when the asset reloads | + +## 6. Terms + +Terms this workflow uses in a specific sense - key light, ambient, Contribute GI, light mode and the rest - are defined in `references/terms.md`. + +## 7. Worked example + +Requested: "Make this level feel like late afternoon instead of midday." + +1. Read current state: key light white at intensity 1.4, pitch 60 degrees, ambient a neutral grey, tonemapping Neutral, no colour filter. +2. The project's style guide documents a warm golden-hour key of `#FFF5CC`. Use it rather than inventing a colour, and say so. +3. Drop the sun pitch from 60 to about 15 degrees. That alone lengthens shadows roughly fourfold and is most of the effect. +4. Warm the key to the documented colour; leave intensity alone, because the mood change is angle and hue, not brightness. +5. Cool the ambient slightly so the warm key reads as warm by contrast. +6. Soften shadows a little and set shadow strength below 1 so blacks are not crushed. +7. Leave grading untouched; it was already correct. +8. Re-read every value, then ask the user to confirm the look against their reference. + +## Verify + +Mood is judged only by eye. State which values you set and against which reference, and ask the user to confirm. You MUST NOT claim the look matches their intent from state reads alone. + +If the look is wrong, go back and reread the relevant documentation from `references/topic-map.md`. A mood that will not resolve is more often tonemapping or ambient than the key light everyone reaches for first. + +## Report + +Include these in your final report: + +- The target you worked to, and where it came from. +- Each layer you changed, in order, with the before and after values. +- The documentation pages you read, by URL. +- Any shared asset you touched, and what else references it. +- The one or two values the user is most likely to want to nudge. diff --git a/skills/light-scene/references/terms.md b/skills/light-scene/references/terms.md new file mode 100644 index 0000000..9eac807 --- /dev/null +++ b/skills/light-scene/references/terms.md @@ -0,0 +1,20 @@ +# Terms as this skill uses them + +Users, the Editor and the scripting API name some lighting settings differently. Use this mapping when you read or write a setting, and read the linked page for what the setting does, because the page matches the project's Unity version. + +| Users and the workflows say | Editor label | API | +|---|---|---| +| [Ambient](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting-reference/lighting-window.md) | Environment Lighting Source and Intensity Multiplier | `RenderSettings.ambientMode`, `RenderSettings.ambientIntensity` | +| [Environment reflections](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting-reference/lighting-window.md) | Environment Reflections Source and Intensity Multiplier | `RenderSettings.defaultReflectionMode`, `RenderSettings.reflectionIntensity` | +| [Light mode](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting-light-sources/components/configuring/light-modes/choose.md) | Light Mode | `Light.lightmapBakeType`, which exists only in the Editor | +| [Contribute GI](https://docs.unity.com/en-us/engine//manual/working-with-gameobjects/gameobject-fundamentals/static-objects.md) | Static: Contribute GI | `UnityEditor.StaticEditorFlags.ContributeGI` | +| [Shadow type](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting/light-component.md) | Shadow Type | `Light.shadows` | +| [Lighting Data Asset](https://docs.unity.com/en-us/engine//manual/lighting-overview/direct-and-indirect-lighting/lightmap-data/lightmap-snapshot.md) | Lighting Data Asset | `UnityEditor.Lightmapping.lightingDataAsset` | +| [Resolved pipeline asset](https://docs.unity.com/en-us/engine//manual/render-pipelines/choose-a-render-pipeline/srp-setting-render-pipeline-asset.md) | Render Pipeline Asset, per quality level | `UnityEngine.Rendering.GraphicsSettings.currentRenderPipeline` | + +Terms in this skill's own sense: + +- **Key light**: the light the viewer reads as the main source, usually the one directional light. Its colour and angle carry most of the mood. +- **Resolved pipeline asset**: the pipeline asset that actually renders after the active quality level's override, which is often not the Graphics Settings default. +- **Baked GI enabled**: a setting, not evidence of a bake. Only lightmaps and a Lighting Data Asset show that a bake ran. +- **Normalised time**: one value from 0 to 1 for the position in a lighting cycle, from which every other value in the cycle is derived. diff --git a/skills/light-scene/references/topic-map.md b/skills/light-scene/references/topic-map.md new file mode 100644 index 0000000..ce0d8d9 --- /dev/null +++ b/skills/light-scene/references/topic-map.md @@ -0,0 +1,222 @@ +# Documentation topic map + +The pages each workflow relies on, grouped by workflow and then by stage. Every link carries ``: replace it with the project's Unity version, for example `6000.3`, before fetching. Open only the pages for the step you are about to do, and name the ones you read. URP pages are in the main manual; some are landing pages, so follow them down. HDRP pages are in the `com.unity.render-pipelines.high-definition` package manual; Built-in pages are in the main manual. Both are indexed in the last section. + +## Contents + +- Set up scene lighting +- Diagnose scene lighting +- Bake scene lighting +- Style scene lighting +- Configure environment lighting +- Fix material lighting response +- Optimize lighting for a platform +- Animate scene lighting +- Built-in and HDRP pages + +## Set up scene lighting + +- **Order and pipeline** + - [Lighting configuration workflow](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting-configuration-workflow.md) - the ordered stages. Read this first; it is the backbone of this workflow. + - [Set the render pipeline asset](https://docs.unity.com/en-us/engine//manual/render-pipelines/choose-a-render-pipeline/srp-setting-render-pipeline-asset.md) - how the active pipeline asset is chosen, including the per-quality-level override. + - [Render pipeline feature comparison](https://docs.unity.com/en-us/engine//manual/render-pipelines/choose-a-render-pipeline/feature-comparison.md) - what differs across pipelines. + - [Lighting in URP](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting.md) - URP lighting behaviour and settings. + - [Unity 6 upgrade guide](https://docs.unity.com/en-us/engine//manual/upgrade-guides/upgrade-guide-unity6.md) - what Unity 6 changed about baking and environment lighting, which decides how a new setup is finished. +- **Environment and light sources** + - [Lighting window reference](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting-reference/lighting-window.md) - Environment Lighting Source and Intensity Multiplier. + - [Ambient light](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting-light-sources/lighting-ambient-light.md) - what ambient contributes. + - [Light component types](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting-light-sources/components/lighting.md) - Point, Spot, Directional and Area lights and what each is for. + - [Light sources](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting-light-sources.md) - light components, ambient light and cookies. + - [URP Light component](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting/light-component.md) - the URP-specific light properties. + - [Direct and indirect lighting](https://docs.unity.com/en-us/engine//manual/lighting-overview/direct-and-indirect-lighting.md) - which contributions are direct and which require a bake. +- **Shadows** + - [Shadow configuration](https://docs.unity.com/en-us/engine//manual/lighting-overview/shadows/shadow-configuration.md) - shadow settings and how to configure them. + - [Optimize shadow rendering in URP](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting/shadows-in-urp/shadows-optimization.md) - shadow cost, including Soft Shadows on tile-based mobile platforms. + - [Lights flicker or disappear](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting/ts-lights-flicker-disappear.md) - lights downgraded from per-pixel to per-vertex in Forward, and the additional-light limit. +- **Probes and baking** + - [Choose a light mode](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting-light-sources/components/configuring/light-modes/choose.md) - the Baked, Mixed and Realtime comparison matrix. + - [Lightmapping](https://docs.unity.com/en-us/engine//manual/lighting-overview/direct-and-indirect-lighting/lightmapping/baking-before-runtime/lightmapping.md) - what baking produces. + - [Light Probes](https://docs.unity.com/en-us/engine//manual/lighting-overview/direct-and-indirect-lighting/light-probes/light-probes.md) - lighting dynamic objects from baked light. + - [Use Adaptive Probe Volumes](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting/probevolumes/use.md) - the Unity 6 probe system; check for it before adding a Light Probe Group. + - [Reflection Probes](https://docs.unity.com/en-us/engine//manual/lighting-overview/reflections/reflection-probes.md) - reflections, and why glossy surfaces need one. + +## Diagnose scene lighting + +- **Setup and pipeline** + - [Lighting configuration workflow](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting-configuration-workflow.md) - the ordered stages Unity expects lighting to be configured in. + - [Render pipeline feature comparison](https://docs.unity.com/en-us/engine//manual/render-pipelines/choose-a-render-pipeline/feature-comparison.md) - the documented matrix of lighting, shadow, ambient and probe differences across pipelines. + - [Set the render pipeline asset](https://docs.unity.com/en-us/engine//manual/render-pipelines/choose-a-render-pipeline/srp-setting-render-pipeline-asset.md) - how the active pipeline asset is chosen, including the per-quality-level override. + - [Lighting window reference](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting-reference/lighting-window.md) - Environment Lighting Source and Intensity Multiplier. + - [Ambient light](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting-light-sources/lighting-ambient-light.md) - what ambient light contributes. + - [Lighting in URP](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting.md) - URP lighting behaviour and settings. +- **Shadows** + - [Shadow performance and failures](https://docs.unity.com/en-us/engine//manual/lighting-overview/shadows/shadow-performance.md) - documented reasons realtime shadows fail to appear. + - [Shadow cascades](https://docs.unity.com/en-us/engine//manual/lighting-overview/shadows/shadow-realtime/shadow-cascades/shadow-cascades.md) - cascades and perspective aliasing, the usual cause of blocky directional shadows. + - [URP shadow resolution](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting/shadows-in-urp/shadow-resolution-urp.md) - URP shadow resolution settings. + - [URP shadow troubleshooting](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting/shadows-in-urp/shadows-troubleshooting-urp.md) - bias, shadow acne, peter-panning, light leaking. + - [Optimize shadow rendering in URP](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting/shadows-in-urp/shadows-optimization.md) - shadow cost, including Soft Shadows on tile-based mobile platforms. + - [Lights flicker or disappear](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting/ts-lights-flicker-disappear.md) - lights downgraded from per-pixel to per-vertex in Forward. +- **Baking and global illumination** + - [Bake lighting](https://docs.unity.com/en-us/engine//manual/lighting-overview/direct-and-indirect-lighting/lightmapping/baking-before-runtime/bake.md) - running a bake. + - [Choose a light mode](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting-light-sources/components/configuring/light-modes/choose.md) - the Baked, Mixed and Realtime comparison matrix. + - [Choose a light baking backend](https://docs.unity.com/en-us/engine//manual/lighting-overview/direct-and-indirect-lighting/lightmapping/baking-before-runtime/configure/progressive-lightmapper.md) - the available baking backends and which one to use. + - [No baked global illumination](https://docs.unity.com/en-us/engine//manual/lighting-overview/direct-and-indirect-lighting/lightmapping/baking-before-runtime/troubleshooting/ts-no-baked-global-illum.md) - causes of missing baked GI, including backend, driver and GI cache steps. + - [Mixed lights render as baked](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting-light-sources/components/configuring/lighting-mode/ts-mixed-lights-render-as-baked.md) - Mixed lights silently demoted to Baked. + - [Emissive materials not rendering](https://docs.unity.com/en-us/engine//manual/lighting-overview/ts-emissive-mats-not-rendering.md) - emissive materials not contributing light. + - [Troubleshooting objects appearing unlit by Light Probes](https://docs.unity.com/en-us/engine//manual/lighting-overview/direct-and-indirect-lighting/light-probes/ts-objects-missing-lighting.md) - objects that render black with no probes to sample, including glossy surfaces with no reflection probe. + - [Unity 6 upgrade guide](https://docs.unity.com/en-us/engine//manual/upgrade-guides/upgrade-guide-unity6.md) - what Unity 6 changed about baking and environment lighting. + +## Bake scene lighting + +- **Before the bake** + - [Lightmapping](https://docs.unity.com/en-us/engine//manual/lighting-overview/direct-and-indirect-lighting/lightmapping/baking-before-runtime/lightmapping.md) - what baking produces and what it needs. + - [Choose a light mode](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting-light-sources/components/configuring/light-modes/choose.md) - the Baked, Mixed and Realtime comparison matrix. + - [Light modes](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting-light-sources/components/configuring/light-modes/light-modes.md) - what each mode contributes. + - [Unity 6 upgrade guide](https://docs.unity.com/en-us/engine//manual/upgrade-guides/upgrade-guide-unity6.md) - what Unity 6 changed about baking and environment lighting. +- **Running the bake** + - [Bake lighting](https://docs.unity.com/en-us/engine//manual/lighting-overview/direct-and-indirect-lighting/lightmapping/baking-before-runtime/bake.md) - running a bake. + - [Choose a light baking backend](https://docs.unity.com/en-us/engine//manual/lighting-overview/direct-and-indirect-lighting/lightmapping/baking-before-runtime/configure/progressive-lightmapper.md) - the available backends and which one to use. + - [GPU lightmapper](https://docs.unity.com/en-us/engine//manual/lighting-overview/direct-and-indirect-lighting/lightmapping/baking-before-runtime/gpuprogressive-lightmapper.md) - GPU-specific requirements and limits. + - [Lightmap Parameters](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting-reference/class-lightmap-parameters.md) - resolution and quality settings per object. +- **Probes** + - [Light Probes](https://docs.unity.com/en-us/engine//manual/lighting-overview/direct-and-indirect-lighting/light-probes/light-probes.md) - lighting dynamic objects from baked light. + - [Use Adaptive Probe Volumes](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting/probevolumes/use.md) - the Unity 6 probe system; check for it before adding a Light Probe Group. + - [Reflection Probes](https://docs.unity.com/en-us/engine//manual/lighting-overview/reflections/reflection-probes.md) - reflections for glossy surfaces. + - [Reflection probes in URP](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting/reflection-probes.md) - URP-specific behaviour. +- **When it goes wrong** + - [Lightmapping troubleshooting](https://docs.unity.com/en-us/engine//manual/lighting-overview/direct-and-indirect-lighting/lightmapping/baking-before-runtime/troubleshooting.md) - the index of bake failures. + - [No baked global illumination](https://docs.unity.com/en-us/engine//manual/lighting-overview/direct-and-indirect-lighting/lightmapping/baking-before-runtime/troubleshooting/ts-no-baked-global-illum.md) - causes of an empty bake, including backend, driver and GI cache steps. + - [Mixed lights render as baked](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting-light-sources/components/configuring/lighting-mode/ts-mixed-lights-render-as-baked.md) - Mixed lights silently demoted. + - [Lighting Data Asset](https://docs.unity.com/en-us/engine//manual/lighting-overview/direct-and-indirect-lighting/lightmap-data/lightmap-snapshot.md) - what the bake writes and where. + +## Style scene lighting + +- **Light and environment** + - [Light component types](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting-light-sources/components/lighting.md) - the light types and what each is for. + - [URP Light component](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting/light-component.md) - colour, temperature and intensity as URP exposes them. + - [Lighting window reference](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting-reference/lighting-window.md) - Environment Lighting Source and Intensity Multiplier. + - [Ambient light](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting-light-sources/lighting-ambient-light.md) - what ambient contributes to mood. + - [Using skyboxes](https://docs.unity.com/en-us/engine//manual/creating-environments/sky/skyboxes-using.md) - the sky as a light and colour source. + - [Shadow configuration](https://docs.unity.com/en-us/engine//manual/lighting-overview/shadows/shadow-configuration.md) - shadow softness and strength, which carry a lot of mood. +- **Grading and post-processing** + - [Post-processing in URP](https://docs.unity.com/en-us/engine//manual/post-processing-and-full-screen-effects/urp/integration-with-post-processing.md) - how URP applies post-processing. + - [Volumes](https://docs.unity.com/en-us/engine//manual/post-processing-and-full-screen-effects/urp/volumes-landing-page/volumes.md) - global and local volumes, and how overrides blend. + - [Tonemapping](https://docs.unity.com/en-us/engine//manual/post-processing-and-full-screen-effects/urp/effect-list/tonemapping.md) - highlight rolloff. Check this before touching anything else. + - [Color Adjustments](https://docs.unity.com/en-us/engine//manual/post-processing-and-full-screen-effects/urp/effect-list/color-adjustments.md) - exposure, contrast, saturation, colour filter. + - [Bloom](https://docs.unity.com/en-us/engine//manual/post-processing-and-full-screen-effects/urp/effect-list/bloom.md) - glow around bright areas. + - [Vignette](https://docs.unity.com/en-us/engine//manual/post-processing-and-full-screen-effects/urp/effect-list/vignette.md) - edge darkening. + +## Configure environment lighting + +- **Sky and background** + - [Lighting window reference](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting-reference/lighting-window.md) - the Environment tab: Skybox Material, Sun Source, Environment Lighting Source and Intensity Multiplier, Environment Reflections, and Fog under Other Settings. + - [Use a skybox](https://docs.unity.com/en-us/engine//manual/creating-environments/sky/skyboxes-using.md) - assigning a skybox per scene and per camera, and the Skybox component that overrides the scene. + - [Skybox shaders](https://docs.unity.com/en-us/engine//manual/creating-environments/sky/skybox-shaders.md) - which shader a skybox material must use. + - [Skybox material reference](https://docs.unity.com/en-us/engine//manual/creating-environments/sky/skybox-material-reference.md) - the properties of each skybox shader. + - [Procedural skybox](https://docs.unity.com/en-us/engine//manual/creating-environments/sky/skybox-material-reference/shader-skybox-procedural.md), [Panoramic skybox](https://docs.unity.com/en-us/engine//manual/creating-environments/sky/skybox-material-reference/shader-skybox-panoramic.md), [Cubemap skybox](https://docs.unity.com/en-us/engine//manual/creating-environments/sky/skybox-material-reference/shader-skybox-cubemap.md), [6-sided skybox](https://docs.unity.com/en-us/engine//manual/creating-environments/sky/skybox-material-reference/shader-skybox-6sided.md) - the four skybox shader families and what each one needs. + - [Panoramic video on a skybox](https://docs.unity.com/en-us/engine//manual/video/player/panoramic/skybox.md) - driving a skybox from a video player. + - [URP camera component reference](https://docs.unity.com/en-us/engine//manual/cameras/urp/camera-components-reference/camera-component-reference.md) - Background Type, and Render Type for camera stacking. +- **Ambient and reflections** + - [Ambient light](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting-light-sources/lighting-ambient-light.md) - what ambient contributes and where its source is chosen. + - [Reflections](https://docs.unity.com/en-us/engine//manual/lighting-overview/reflections.md) - how reflection sources combine. + - [Reflection probes in URP](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting/reflection-probes.md) and [their introduction](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting/reflection-probes/introduction.md) - probe types, baking, and realtime probes. + - [Reflection probe troubleshooting](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting/reflection-probes/troubleshooting.md) - documented reasons a probe produces no visible reflection. + - [Reflection probe reference](https://docs.unity.com/en-us/engine//manual/lighting-overview/reflections/class-reflection-probe.md) - probe properties including box projection. + - [Troubleshooting objects appearing unlit by Light Probes](https://docs.unity.com/en-us/engine//manual/lighting-overview/direct-and-indirect-lighting/light-probes/ts-objects-missing-lighting.md) - objects that render black with no probes to sample, including glossy surfaces with no reflection probe. + - [Unity 6 upgrade guide](https://docs.unity.com/en-us/engine//manual/upgrade-guides/upgrade-guide-unity6.md) - what Unity 6 changed about environment lighting, which decides what a scene shows before a bake. +- **Fog and volumes** + - [Settings and keywords reference for stripping keywords in URP](https://docs.unity.com/en-us/engine//manual/materials-and-shaders/built-in/shaders-in-universalrp/shader-stripping/features-and-keywords.md) - the Fog row: the settings that strip fog from a build. + - [Volumes in URP](https://docs.unity.com/en-us/engine//manual/post-processing-and-full-screen-effects/urp/volumes-landing-page/volumes.md) and [Volume troubleshooting](https://docs.unity.com/en-us/engine//manual/post-processing-and-full-screen-effects/urp/volumes-landing-page/volumes-troubleshooting.md) - Volume priority, layer masks and blend distance. + - [Emissive materials](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting-birp/lighting-emissive-materials.md) - emissive surfaces as an environment contribution. + +## Fix material lighting response + +- **Pipeline migration and magenta materials** + - [Render Pipeline Converter](https://docs.unity.com/en-us/engine//manual/render-pipelines/universal-render-pipeline/introduction/installing-and-configuring-urp/upgrading-from-birp/rp-converter.md) - the supported way to convert built-in materials to URP in bulk. + - [Upgrade a material](https://docs.unity.com/en-us/engine//manual/materials-and-shaders/materials/upgrade-material.md) - what an upgrade does to a material and its properties. + - [Upgrading from the Built-In Render Pipeline](https://docs.unity.com/en-us/engine//manual/render-pipelines/universal-render-pipeline/introduction/installing-and-configuring-urp/upgrading-from-birp.md) - the whole migration path. + - [Render pipeline feature comparison](https://docs.unity.com/en-us/engine//manual/render-pipelines/choose-a-render-pipeline/feature-comparison.md) - the documented matrix of lighting, shadow, ambient and probe differences across pipelines. + - [Shaders in URP](https://docs.unity.com/en-us/engine//manual/materials-and-shaders/built-in/shaders-in-universalrp.md) and [choosing one](https://docs.unity.com/en-us/engine//manual/materials-and-shaders/built-in/shaders-in-universalrp/choose.md) - which URP shader replaces which built-in shader. +- **Custom shaders and lighting** + - [URP ShaderLab pass tags](https://docs.unity.com/en-us/engine//manual/materials-and-shaders/shaders/writing-custom-shaders-urp/use-built-in-shader-methods/urp-shaderlab-pass-tags.md) - the `LightMode` tags URP renders, per rendering path. + - [Upgrade custom shaders from built-in to URP](https://docs.unity.com/en-us/engine//manual/render-pipelines/universal-render-pipeline/introduction/installing-and-configuring-urp/upgrading-from-birp/birp-urp-custom-shader-upgrade-guide.md) - the per-feature mapping for hand-written shaders. + - [Upgrading your shaders](https://docs.unity.com/en-us/engine//manual/render-pipelines/universal-render-pipeline/introduction/installing-and-configuring-urp/upgrading-from-birp/upgrading-your-shaders.md) - version-to-version shader changes. + - [Use shadows in a custom URP shader](https://docs.unity.com/en-us/engine//manual/materials-and-shaders/shaders/writing-custom-shaders-urp/use-built-in-shader-methods/shadows.md) and [Render additional lights in a shader in URP](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting/custom-lighting/use-built-in-shader-methods-additional-lights-fplus.md) - the keywords a shader must declare to receive shadows and additional lights. + - [Shader keywords](https://docs.unity.com/en-us/engine//manual/materials-and-shaders/shaders/writing-custom/shader-writing/sl-multiple-program-variants/shader-keywords.md) - how keywords are enabled, and why an undeclared one silently does nothing. + - [Built-in lighting methods in URP](https://docs.unity.com/en-us/engine//manual/materials-and-shaders/shaders/writing-custom-shaders-urp/use-built-in-shader-methods/lighting.md) and [additional lights in Forward+](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting/custom-lighting/use-built-in-shader-methods-additional-lights-fplus.md) - the functions a custom shader calls to be lit. + - [Meta pass](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting-birp/meta-pass.md) - the pass a shader needs to contribute to baked global illumination. +- **Per-material behaviour** + - [Lit shader](https://docs.unity.com/en-us/engine//manual/materials-and-shaders/built-in/shaders-in-universalrp/reference/lit-shader.md), [Complex Lit shader](https://docs.unity.com/en-us/engine//manual/materials-and-shaders/built-in/shaders-in-universalrp/reference/shader-complex-lit.md), [Unlit shader](https://docs.unity.com/en-us/engine//manual/materials-and-shaders/built-in/shaders-in-universalrp/reference/unlit-shader.md) - what each responds to. + - [Light limits in URP](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting/light-limits-in-urp.md) - the per-object additional-light limit, and how Forward+ changes it. + - [Lights flicker or disappear](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting/ts-lights-flicker-disappear.md) - lights downgraded from per-pixel to per-vertex in Forward. + - [Missing specular response](https://docs.unity.com/en-us/engine//manual/lighting-overview/direct-and-indirect-lighting/lightmapping/baking-before-runtime/ts-missing-spec-response.md) - surfaces that receive diffuse light but no specular. + - [Troubleshooting objects appearing unlit by Light Probes](https://docs.unity.com/en-us/engine//manual/lighting-overview/direct-and-indirect-lighting/light-probes/ts-objects-missing-lighting.md) - objects that render black with no probes to sample, including glossy surfaces with no reflection probe. + - [Emissive materials not rendering](https://docs.unity.com/en-us/engine//manual/lighting-overview/ts-emissive-mats-not-rendering.md) - emissive materials not contributing light. + +## Optimize lighting for a platform + +- **Where the settings live** + - [Set the render pipeline asset](https://docs.unity.com/en-us/engine//manual/render-pipelines/choose-a-render-pipeline/srp-setting-render-pipeline-asset.md) - how the active asset is chosen, including the per-quality-level override. Read this first. + - [Quality Settings](https://docs.unity.com/en-us/engine//manual/unity-editor/editor-settings-reference/comp-manager-group/class-quality-settings.md) - the quality levels and what each controls. + - [URP quality settings](https://docs.unity.com/en-us/engine//manual/render-pipelines/universal-render-pipeline/urp-quality-settings.md) - the URP asset's own quality options. + - [Universal Renderer](https://docs.unity.com/en-us/engine//manual/render-pipelines/universal-render-pipeline/urp-reference/urp-universal-renderer.md) - rendering path, and what Forward, Forward+ and Deferred cost. +- **Shadow cost** + - [Optimize shadow rendering in URP](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting/shadows-in-urp/shadows-optimization.md) - the main reference, including the cost of Soft Shadows on tile-based mobile platforms. + - [Shadow cascades](https://docs.unity.com/en-us/engine//manual/lighting-overview/shadows/shadow-realtime/shadow-cascades/shadow-cascades.md) - cascade count against shadow quality at distance. + - [URP shadow resolution](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting/shadows-in-urp/shadow-resolution-urp.md) - shadow map size. + - [Shadow performance](https://docs.unity.com/en-us/engine//manual/lighting-overview/shadows/shadow-performance.md) - general shadow cost and why shadows disappear. +- **Light cost** + - [Lights flicker or disappear](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting/ts-lights-flicker-disappear.md) - the additional-light limit, and lights downgraded to per-vertex. + - [Choose a light mode](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting-light-sources/components/configuring/light-modes/choose.md) - baked light is cheaper at runtime than realtime light. + - [Optimize for better performance](https://docs.unity.com/en-us/engine//manual/analysis/graphics-performance-profiling/in-urp/optimize-for-better-performance.md) - broader URP performance guidance. + - [Rendering Debugger](https://docs.unity.com/en-us/engine//manual/analysis/graphics-performance-profiling/in-urp/understand-performance/rendering-debugger.md) - inspecting what is actually being rendered. + +## Animate scene lighting + +- **What changes over time** + - [Light component types](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting-light-sources/components/lighting.md) - the sun is a directional light; its angle is the clock. + - [URP Light component](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting/light-component.md) - the light properties you can drive. + - [Ambient light](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting-light-sources/lighting-ambient-light.md) - ambient must move with the sun or dusk looks wrong. + - [Lighting window reference](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting-reference/lighting-window.md) - Environment Lighting Source and Intensity Multiplier. + - [Using skyboxes](https://docs.unity.com/en-us/engine//manual/creating-environments/sky/skyboxes-using.md) - procedural skyboxes track a sun; texture skyboxes do not. +- **Baked lighting that changes** + - [Adaptive Probe Volumes](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting/probevolumes.md) - the landing page for APV. + - [Understand Adaptive Probe Volumes](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting/probevolumes/concept.md) - what APV stores and how it differs from Light Probes. + - [Use Adaptive Probe Volumes](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting/probevolumes/use.md) - setting them up, including lighting scenarios. + - [Display and adjust Adaptive Probe Volumes](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting/probevolumes/showandadjust.md) - inspecting the result. + - [Fix issues with Adaptive Probe Volumes](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting/probevolumes/fixissues.md) - when blending looks wrong. + - [Light Probes](https://docs.unity.com/en-us/engine//manual/lighting-overview/direct-and-indirect-lighting/light-probes/light-probes.md) - the older system, for comparison. + - [Lightmapping](https://docs.unity.com/en-us/engine//manual/lighting-overview/direct-and-indirect-lighting/lightmapping/baking-before-runtime/lightmapping.md) - why static lightmaps cannot follow a moving sun. + +## Built-in and HDRP pages + +The pages behind the pipeline notes. Manual links take the Unity version, as above. Package links take the installed package's version instead, such as `17.6` for HDRP; check the package version if unsure. + +- **Built-in Render Pipeline** + - [Quality settings](https://docs.unity.com/en-us/engine//manual/unity-editor/editor-settings-reference/comp-manager-group/class-quality-settings.md) - Pixel Light Count, shadow distance, cascades and resolution, per quality level; Built-in has no pipeline asset. + - [Rendering paths in the Built-in Render Pipeline](https://docs.unity.com/en-us/engine//manual/render-pipelines/built-in-render-pipeline/built-in-rendering-paths.md) - the Forward path's per-object light limit, against Deferred. + - [Shadow distance](https://docs.unity.com/en-us/engine//manual/lighting-overview/shadows/shadow-realtime/shadow-distance.md) and [Shadow cascades](https://docs.unity.com/en-us/engine//manual/lighting-overview/shadows/shadow-realtime/shadow-cascades/shadow-cascades.md) - the main shadow-cost settings. + - [Light Probe Group](https://docs.unity.com/en-us/engine//manual/lighting-overview/direct-and-indirect-lighting/light-probes/class-light-probe-group.md) - probes for moving objects, since Built-in has no Adaptive Probe Volumes. + - [Lighting Mode](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting-light-sources/components/configuring/lighting-mode/lighting-mode.md) and [Render pipeline feature comparison](https://docs.unity.com/en-us/engine//manual/render-pipelines/choose-a-render-pipeline/feature-comparison.md) - which Mixed lighting modes each pipeline supports. + - [Meta pass](https://docs.unity.com/en-us/engine//manual/lighting-overview/lighting-birp/meta-pass.md) - how a shader contributes to baked global illumination. + - [Pass tags](https://docs.unity.com/en-us/engine//manual/materials-and-shaders/shaders/reference/sl-reference/sl-sub-shader-pass/sl-pass-tags.md) and [Surface shaders](https://docs.unity.com/en-us/engine//manual/materials-and-shaders/shaders/writing-shaders-birp/writing-surface/sl-surface.md) - what a Built-in lit shader needs. + - [Reflection Probe component](https://docs.unity.com/en-us/engine//manual/lighting-overview/reflections/class-reflection-probe.md) - reflection probes, which work as they do on URP. + - [Post Processing Stack v2](https://docs.unity3d.com/Packages/com.unity.postprocessing@/manual/index.html) and its [Color Grading](https://docs.unity3d.com/Packages/com.unity.postprocessing@/manual/Color-Grading.html) - tonemapping and grading on Built-in, when the package is installed. +- **High Definition Render Pipeline** + - [Physical light units](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@/manual/Physical-Light-Units.html) - lux, lumen, candela and EV100; URP intensities do not transfer. + - [Light component](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@/manual/Light-Component.html) - HDRP's light properties. + - [Exposure](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@/manual/Override-Exposure.html) - the Volume override to set before judging any intensity. + - [Visual Environment](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@/manual/Override-Visual-Environment.html) - chooses the sky type and the ambient mode. + - [Create an HDRI sky](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@/manual/create-an-hdri-sky.html), [Create a physically based sky](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@/manual/create-a-physically-based-sky.html) and [Create a gradient sky](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@/manual/create-a-gradient-sky.html) - the sky overrides. + - [Environment lighting](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@/manual/Environment-Lighting.html) - ambient light from the sky, and the Static Lighting Sky a bake needs. + - [Shadows](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@/manual/Override-Shadows.html) - the Volume override for cascade count and maximum distance. + - [Frame Settings](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@/manual/Frame-Settings.html) - per-camera switches that can turn lighting, shadows, fog or post-processing off. + - [HDRP Asset](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@/manual/HDRP-Asset.html) - shadow atlases, quality tiers and what is compiled in. + - [Shadowmask](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@/manual/Lighting-Mode-Shadowmask.html) - the Shadowmask lighting mode in HDRP. + - [Use Adaptive Probe Volumes](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@/manual/probevolumes-use.html) - probes and lighting scenarios in HDRP. + - [Reflection Probe](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@/manual/Reflection-Probe.html), [Planar Reflection Probe](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@/manual/Planar-Reflection-Probe.html) and [Screen Space Reflection](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@/manual/Override-Screen-Space-Reflection.html) - reflections in HDRP. + - [Fog](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@/manual/fog.html) and [Volumetric lighting](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@/manual/Volumetric-Lighting.html) - fog as a Volume override, volumetric fog included. + - [Tonemapping](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@/manual/Post-Processing-Tonemapping.html) - HDRP's tonemapping modes. + - [Understand volumes](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@/manual/understand-volumes.html) - the Volume framework HDRP shares with URP. + - [Dynamic resolution](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@/manual/Dynamic-Resolution.html) - HDRP's equivalent of render scale. + - [Convert a project from the Built-in Render Pipeline](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@/manual/convert-project-from-built-in-render-pipeline.html) and [Lit material](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@/manual/lit-material.html) - upgrading materials to HDRP.