threejs-lighting-and-gi
Skill1.1k starsChanged 5 days agoMITView on GitHub
Author physically coherent Three.js lighting, HDRI fill, global illumination, and real-time reflections. Use for single-sun direction alignment, clear-sky sun-to-sky irradiance ratios, removing the HDRI second-sun, practical and emissive fixtures lighting surroundings, character lighting, GPU-baked irradiance probe grids (LightProbeGrid), planar and cube-probe reflections, and diagnosing flat or overcast scenes.
In this repository29 other files it gives its agents.
- .codex/AGENTS.mdAGENTS.md
- .claude/CLAUDE.mdCLAUDE.md
- threejs-atmosphere-aerial-perspectiveSkill
- threejs-bloomSkill
- threejs-camera-directionSkill
- threejs-exposure-color-gradingSkill
- threejs-image-pipelineSkill
- threejs-parallax-occlusion-mappingSkill
- threejs-precipitation-surfacesSkill
- threejs-procedural-animationSkill
- threejs-procedural-architectureSkill
- threejs-procedural-fieldsSkill
- threejs-procedural-geometrySkill
- threejs-procedural-materialsSkill
- threejs-procedural-planetsSkill
- threejs-procedural-vegetationSkill
- threejs-procedural-vfxSkill
- threejs-raymarched-space-effectsSkill
- threejs-reference-readingSkill
- threejs-screen-space-ambient-occlusionSkill
- threejs-shadow-systemsSkill
- threejs-skill-routerSkill
- threejs-spectral-oceanSkill
- threejs-temporal-stabilitySkill
- threejs-temporal-surfacesSkill
- threejs-terrain-and-landscapesSkill
- threejs-visual-validationSkill
- threejs-volumetric-cloudsSkill
- threejs-water-opticsSkill
The file
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 2 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 16
Add occluded indirect light — GPU-baked irradiance probes (LightProbeGrid or custom SH atlas) over reachable spaces — so recesses darken …
- Distinctive: line 17
Add practical fixtures and emissive-to-world lighting with inverse-square falloff and real-extent reflections.
- Very specific: line 20
Read references/sun-sky-and-hdri-lighting.md for clear-sky irradiance anchors, Three.js unit mapping, HDRI second-sun removal, …
- Very specific: line 22
Read references/irradiance-probes-and-reflections.md for GPU-baked LightProbeGrid setup, probe cell sizing and leak prevention, SSGI …
- Distinctive: line 24
Read references/practical-emissive-and-subject-lighting.md for practical fixtures, static light baking, sub-pixel bulb energy conservation, …
- Very specific: line 26
Run node scripts/sun-sky.mjs <elevationDeg> [sunIntensity] (or --self-test) to derive clear-sky direct/diffuse ratios and Three.js sky-fill …
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Lighting, Global Illumination, and Reflections
Establish coherent direct light, sky fill, occluded indirect bounce, and real reflections before tuning tone mapping or color grading. Contrast, warmth, and depth belong in the light transport first.
Build order
- Define one authoritative sun/key direction in one place so visible disc, directional light, shadows, light patches, and sky glow agree from every angle.
- Compute physical sun-to-sky irradiance ratios with scripts/sun-sky.mjs (
diffuse/direct ≈ 0.10–0.20for clear sky) and calibrateDirectionalLight.intensityagainstscene.environment/HemisphereLight. - Prepare the HDRI as image-based fill only: remove its sun energy before prefiltering, align
scene.environmentRotationto sun azimuth, and fix mismatched lower-hemisphere ground. - Validate direct + sky lighting in a neutral clay render (plus grey card
0.18and white/mirror spheres) before adding surface textures or grade. - Add occluded indirect light — GPU-baked irradiance probes (
LightProbeGridor custom SH atlas) over reachable spaces — so recesses darken and colored bounce reaches soffits and alcoves. - Add practical fixtures and emissive-to-world lighting with inverse-square falloff and real-extent reflections.
- Configure real reflections per surface class (planar mirror, cube/box-projected probes, or fallback-safe SSR) and verify them at full resolution and in motion.
Read references/sun-sky-and-hdri-lighting.md for clear-sky irradiance anchors, Three.js unit mapping, HDRI second-sun removal, flat/overcast lighting diagnosis, and orbit-safe stylized light deviations.
Read references/irradiance-probes-and-reflections.md for GPU-baked LightProbeGrid setup, probe cell sizing and leak prevention, SSGI trade-offs, planar/probe/SSR reflection ownership, and full-resolution diagnostics.
Read references/practical-emissive-and-subject-lighting.md for practical fixtures, static light baking, sub-pixel bulb energy conservation, emissive-to-world illumination, and subject/character key-fill-rim lighting.
Run node scripts/sun-sky.mjs <elevationDeg> [sunIntensity] (or --self-test) to derive clear-sky direct/diffuse ratios and Three.js sky-fill targets.
Non-negotiable rules
- One sun: derive the directional light, sky model, aureole, and shadow direction from one shared vector. Verify with a mirror sphere and vertical stick shadow.
- Physical sun-to-sky ratio first: an overly bright HDRI or hemisphere fill is the primary cause of flat, overcast renders. Measure an up-facing shaded white swatch rather than trusting raw HDRI intensity.
- HDRI is fill and reflection, never a visible backdrop or second sun: strip the HDRI sun disc before PMREM prefiltering so it never casts a shadowless competing glow, and keep the visible sky on a sky model (
$threejs-atmosphere-aerial-perspective). - Occlude indirect light: uniform environment/hemisphere light makes alcoves and undersides glow like open roofs. Pair probe grids with contact AO (
$threejs-screen-space-ambient-occlusion). - Emitters light their surroundings: lanterns, windows, glowing water, fire, and screens must illuminate nearby surfaces and reflect with their real extent rather than sitting in an unlit world.
- Update moving reflections continuously: render all
6cube faces every frame when reflected content moves; never step cube faces across frames or hide geometry bugs behind reflection blur. - Verify installed Three.js APIs:
LightProbeGridand TSLreflectorare version-sensitive; inspect the target project's installed Three.js build before writing imports.
Failure conditions
- visible sun disc, shadows, specular highlights, and sky glow disagree on direction;
- HDRI sun energy floods shadow regions with unshadowed light, or the HDRI is used directly as the visible sky;
- raising fill to see poorly lit forms instead of fixing a misplaced key light;
- interiors, loggias, and under-hangs read as bright as open sunlit walls due to unoccluded fill;
- glowing fixtures or emissive surfaces cast zero light on adjacent geometry;
- characters or hero subjects use self-lit fills that ignore cast shadows, or accidental horror under-lighting;
- planar reflections leak below-plane geometry or normal-offset past wall bases into bright dashed seams;
- color grading or exposure is abused to manufacture missing key-to-fill contrast.
Routing boundary
This skill owns direct lighting, sky/HDRI fill calibration, practical/emissive lighting, irradiance-probe GI, and reflections. Use $threejs-shadow-systems for shadow map coverage, cascades, clipmaps, bias, and caster update policies; $threejs-screen-space-ambient-occlusion for small-scale contact AO; $threejs-atmosphere-aerial-perspective for visible sky scattering and aerial haze; $threejs-exposure-color-grading for exposure, tone mapping, and LUT/grade; $threejs-bloom for HDR glare; and $threejs-reference-reading to decode lighting evidence from a visual reference.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

