[2020.1] New Feature - Baked Light Cookies


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:

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!

7 Likes

Didn’t play with it yet, might have more to say once I do, but from first glance this looks great!

Baked IES Support next? :slight_smile:

4 Likes

The IES support will sit on top of this feature. Work is underway on an IES importer. Once that is done we can connect the dots.

4 Likes

Hey I just wanted to say it’s nice to see this along with the other illumination goodies in the next release :slight_smile: Thanks for the hard work!

1 Like

Thanks for the baked light cookies and hope to see baked ies support. But, I will criticize that do u think editor section of project settings is right place to put check box for cookie??? Shouldnt it be somewhere else ? Maybe lighting tab? Second, İts name should be “Enable Baked light Cookie” , not start with “Disable” word, isnt it?

This setting is a guard to ensure legacy behavior. By default support will be enabled for new projects (the new scene templates are being updated currently). Unless you’re upgrading an old project and want to start using cookies, you shouldn’t even have to know about this setting.

1 Like

I was extremely excited about this new feature, but it doesn’t seem to work with HDRP.

I have the latest beta build of Unity (2020.1.0b4), and my version of HDRP is up to date (8.0.1). I can neither get directional cookies nor cubemap cookies to work. I did get baked cookies to work in the default pipeline, but I need RGB cookies.

Any advice? Thanks.

You’ll have to use the soon to be released HDRP version 8.1 for baked cookie support.

1 Like

Is this 8.1?
https://github.com/Unity-Technologies/ScriptableRenderPipeline/releases/tag/LatestGreen

Latest probably not. There’ll be a proper 8.1 release and it should show up in the package manager.

PSA: @JenniferNordwall has made some UI usability improvements to this feature. The checkbox in the Project Settings window has been renamed from Disable cookies support to Enable baked cookies support.

We will now also show a warning when assigning a cookie to baked light when baked cookie support is not enabled. Same goes for mixed lights.

This change will land soon in the latest 2020.2 alpha. 2020.1 backport is on its way.

2 Likes

Thank you Jennifer, I just did test and it is working nicely.

Not sure of this is the right place to ask. But now when URP 12 supports light cookies, I tried to play around with them a bit.

But I noticed you can’t have a directional light AND a spot light with a cookie texture in the same time. As soon as I enable the cookie texture, it will completely disable the directional light.

In rendering settings I have a maximal light per object set to 8. So can have multiple point lights without any problem, so that shouldn’t be a problem. Is it a bug? Or did I miss some settings somewhere?

Edit:
Tried now again, and the directional light is not deactivated, it’s just over-shadowed. So what’s happening hear is that the spot light doesn’t use a additive light, it’s subtractive. So where it’s white in the cookie, the original light from the directional light shines through. And where it’s black, it will reduce the amount of light the directional light produces. This seems in my world completely the wrong way of doing it.

If anyone knows how to change spotlight with cookies to additive mode in the URP 12 code somewhere, I would be a very happy artist :smile:

Baked and realtime cookies were implemented by the URP team. I would suggest asking in the URP sub-forum. Better yet, submit a bug report and they will take a look.

1 Like

I thing it’s more of a feature to be able to switch between subtractive and additive blend modes on the light cookie. Maybe. But I have sent in a bug report now.

Tones of errors “unity light type needs 2d texture”, then Unity crashing, PC goes black screen.

Unity 2022/2021.2…

Scene is dead, because I can’t change there anything. Project is dead because I can’t change the scene.

UPD: So, I found a problem… Deleted my textures from the folder for Cookies, so my light Prefabs objects lost them and scene rendered. But something with your Cookies, guys. I will try to create a small project and will try to reproduce this bug and send a bug…

“unity light type needs 2d texture” is all I have now.

for realism the mask should be blurrier when the source is further, is it possible to implement that?

1 Like

Hi all!
I haven’t “Emission” section in lights parameters!
(Unity 2021.2.19 …///…)…

baked light cookie may have some problem, it only support some specific cookie texture format(et. BCT1), other format con`t bake successfully

1 Like

I believe the location of the cookie property depends on which render pipeline you are using. If you still haven’t found it, leave a screenshot of what you are seeing when you select a light :slight_smile:

1 Like