Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Official [2020.1] New Feature - Baked Light Cookies

Discussion in 'Global Illumination' started by kristijonas_unity, Mar 17, 2020.

  1. kristijonas_unity

    kristijonas_unity

    Unity Technologies

    Joined:
    Feb 8, 2018
    Posts:
    898
    CookieSupport_Marketing_Final.jpg
    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.

    BakedLightCookiesSupport-ProjectSettings.jpg

    Select a light in the scene. In the Inspector, unfold the Emission header. Cookie texture field is located there.
    BakedCookies-LightInspector.jpg

    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 - https://unity3d.com/alpha/2020.1a#downloads. We are looking forward to hearing your feedback!
     
    Last edited: Jan 24, 2022
  2. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    9,435
    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? :)
     
  3. Jesper-Mortensen

    Jesper-Mortensen

    Unity Technologies

    Joined:
    Mar 15, 2013
    Posts:
    221
    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. JoNax97

    JoNax97

    Joined:
    Feb 4, 2016
    Posts:
    585
    Hey I just wanted to say it's nice to see this along with the other illumination goodies in the next release :) Thanks for the hard work!
     
    Last edited: Mar 18, 2020
    kristijonas_unity likes this.
  5. Gokcan

    Gokcan

    Joined:
    Aug 15, 2013
    Posts:
    282
    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?
     
  6. uy3d

    uy3d

    Unity Technologies

    Joined:
    Aug 16, 2016
    Posts:
    187
    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.
     
    Gokcan likes this.
  7. DryerLint

    DryerLint

    Joined:
    Feb 7, 2016
    Posts:
    56
    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.
     
  8. uy3d

    uy3d

    Unity Technologies

    Joined:
    Aug 16, 2016
    Posts:
    187
    You'll have to use the soon to be released HDRP version 8.1 for baked cookie support.
     
    DryerLint likes this.
  9. valarus

    valarus

    Joined:
    Apr 7, 2019
    Posts:
    349
  10. uy3d

    uy3d

    Unity Technologies

    Joined:
    Aug 16, 2016
    Posts:
    187
    Latest probably not. There'll be a proper 8.1 release and it should show up in the package manager.
     
  11. kristijonas_unity

    kristijonas_unity

    Unity Technologies

    Joined:
    Feb 8, 2018
    Posts:
    898
    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.
     
    Last edited: Apr 3, 2020
    JenniferNordwall and Gokcan like this.
  12. unit_dev123

    unit_dev123

    Joined:
    Feb 10, 2020
    Posts:
    990
    Thank you Jennifer, I just did test and it is working nicely.
     
  13. sandstedt

    sandstedt

    Joined:
    May 24, 2015
    Posts:
    50
    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 :D
     
    Last edited: Oct 8, 2021
  14. kristijonas_unity

    kristijonas_unity

    Unity Technologies

    Joined:
    Feb 8, 2018
    Posts:
    898
    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.
     
    sandstedt likes this.
  15. sandstedt

    sandstedt

    Joined:
    May 24, 2015
    Posts:
    50
    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.
     
  16. Kadae

    Kadae

    Joined:
    Dec 7, 2013
    Posts:
    42
    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.
     
    Last edited: Oct 31, 2021
  17. sidchou

    sidchou

    Joined:
    Apr 13, 2020
    Posts:
    3
    for realism the mask should be blurrier when the source is further, is it possible to implement that?
     
unityunity