An example of baked fake caustics achieved using baked light cookies. Imagery courtesy of David Llewelyn.
Overview
This feature was developed by Uygar Kalem ( @uy3d ).
Using modelled geometry is one of the methods to change the way the light looks. Getting accurate and clean results using such method would need a lot of samples. This is where light cookies come into play. They allow users to change light’s appearance and intensity. With their help, users can simulate many different lighting effects. Such effects include caustics, soft shadows, light shapes, and others. This practice is very common in games and architectural visualizations. Before this feature was only available for realtime and mixed lights. We now support baked lights as well.
Baked light cookies have no runtime cost and are very efficient to render. As an added benefit, they also affect indirect global illumination. This is a key factor when striving to achieve realism in baked lighting scenes.
We support both grayscale and RGB textures. RGB textures allow for colored cookie effects. Grayscale textures act as a simple mask. Keep in mind that point lights need a cubemap texture in order for cookies to work. All other lights need 2D cookie textures.
Setup instructions
Baked cookies support is disabled for upgraded Unity projects to maintain legacy behavior. In order to enable it, navigate to Edit > Project Settings > Editor and make sure that Enable baked cookies support flag is checked. Newly created projects will have this flag checked by default.
Select a light in the scene. In the Inspector, unfold the Emission header. Cookie texture field is located there.
Here are couple of things to keep in mind when importing cookie textures in different render pipelines:
- In HDRP, set Texture Type field to Default. Set Texture Shape to 2D if the texture is a 2D map. For cubemaps, set Texture Shape to Cube.
- In Built-in RP, set Texture Type field to Cookie. Set Light Type property to Spot if the texture is a 2D map. For cubemaps, set Light Type property to Point.
Unity’s texture importer will extract the cookie mask from the alpha channel. For colored cookies make sure the texture contains no alpha channel.
Additional information
For more information on light cookies, please refer to the following pages:
- Create high-quality light fixtures in Unity - Unity Blog
- Unity Manual - Unity - Manual: Cookies
- HDRP Manual - Lights in the High Definition Render Pipeline | High Definition RP | 8.0.1
Please keep in mind that is feature is currently available in Built-in and High Definition Render Pipelines. Support for Universal Render Pipeline will follow at a later stage.
Feature access & feedback
You can get access to the feature by downloading the latest 2020.1 alpha build via the Unity Hub, or via this link - Unity Editor Alpha Releases. We are looking forward to hearing your feedback!