A cookie is a mask that you place on a Light to create a shadow with a specific shape or color, which changes the appearance and intensity of the Light. Cookies are an efficient way of simulating complex lighting effects with minimal or no runtime performance impact. Effects you can simulate with cookies include caustics, soft shadows, and light shapes.
To apply a cookie to a Light in Unity, assign a texture to the Cookie field of a a Light component.
For more information on the different render pipelines available in Unity, see Render pipelines.
Render pipeline: | Details: |
---|---|
Built-in Render Pipeline | The Built-in Render Pipeline supports cookies for Realtime LightsLight components whose Mode property is set to Realtime. Unity calculates and updates the lighting of Realtime Lights every frame at runtime. No Realtime Lights are precomputed. More info See in Glossary, and for Baked LightsLight components whose Mode property is set to Baked. Unity pre-calculates the illumination from Baked Lights before runtime, and does not include them in any runtime lighting calculations. More info See in Glossary and Mixed LightsLight components whose Mode property is set to Mixed. Some calculations for Mixed Lights are performed in advance, and some calculations for Mixed Lights are performed at runtime. The behavior of all Mixed Lights in a Scene is determined by the Scene’s Lighting Mode. More info See in Glossary when you use the Progressive Lightmapper. In the Built-in Render Pipeline, cookies only use data from the alpha channel. This means that you can define a shape for a cookie, but not a color. For more information on cookies in the Built-in Render Pipeline, see Creating cookies for the Built-in Render Pipeline and Texture Type: Cookie. |
Universal Render Pipeline (URP) | URP does not support cookies at this time, but this feature is in research. This means that Unity is researching adding support for this feature in a future release, but cannot confirm that it is on the roadmap. For more information on features in URP, see the URP feature comparison table. |
High Definition Render Pipeline (HDRP) | HDRP supports cookies for Realtime Lights, and for Baked Lights and Mixed Lights when you use the Progressive Lightmapper. In HDRP, cookies use the data from the RGB channels. This means that you can define a shape and a color for a cookie. For more information on cookies in HDRP, see Lights in the High Definition Render Pipeline and the HDRP Asset. |
For Projects created in Unity 2020.1 or above, baked cookies are enabled for Baked Lights and Mixed Lights in the Progressive LightmapperA tool in Unity that bakes lightmaps according to the arrangement of lights and geometry in your scene. More info
See in Glossary by default. For Projects created in versions of Unity prior to 2020.1, baked cookies are disabled for Baked Lights and Mixed Lights in the Progressive Lightmapper by default. This is to provide backwards compatibility.
You can toggle whether cookies are enabled for Baked Lights and Mixed Lights in the Progressive Lightmapper in the Editor settings window.