Search Unity

We’ve just published a comprehensive expert guide (PDF) on advanced techniques to create high-quality light fixtures for real-time applications. Read it and find out how you can use light cookies and advanced shaders to create convincing artificial light sources in any project, from games or architectural visualizations to films and more!

Wait a minute, what are light cookies? These are 2D textures or cubemaps used to block parts of a light source in order to control the shape, the intensity, and the color of the emitted lighting. They can also be called “gobos”, “cucoloris” or “flags”, depending on the industry and their use case.

With their help, you can efficiently simulate ray-traced soft shadows, colored transmission, and even refractive caustics! Indeed, rendering these effects fully in real-time would be remarkably expensive in densely-lit environments, even for the most powerful GPUs on the market. This is why baked light cookies are still crucial to produce convincing lighting in real-time scenarios.

 

Good news: the Built-In Render Pipeline can also take advantage of (grayscale) light cookies! Therefore, you can also reproduce high-quality shadows on platforms incompatible with the High Definition Render Pipeline (HDRP), in real-time.

After pointing out some of the common lighting mistakes still found in CGI nowadays and giving you recommendations on how to prevent them, the expert guide walks you through all the steps required to generate beautiful noise-free cookies with a variety of 2D and 3D programs, such as Photoshop, 3ds Max and Unity itself.

Moreover, I will explain how to set up critical post-processing settings in Unity, such as Exposure and Tone Mapping, so that your interior scenes can be lit in a more physically-correct way, one of HDRP’s mottos.

Then, the guide gives an extensive review of the crucial Light properties in HDRP, such as the physical Intensity units, the Color modes, the  Shadows parameters, and the Light Layers used to restrict lighting to specific objects. Later, I present different methods to replicate the lampshade of a chandelier with HDRP’s highly flexible Lit shader.

Finally, I introduce an original workflow to generate appealing caustics to bring the final ultra-realistic touch to your light sources, by adding micro-details to simulate the self-reflections of the light fitting and the structural imperfections found in the reflectors and the lampshades.

 

Hopefully, thanks to our new expert guide, you will have many tools on hand to create convincing light sources, and raise the visual bar of your Unity Scenes!

Let’s get started!

Ya no se aceptan más comentarios.

  1. Will these techniques work for a VR environment? What if the environment is ‘fully dynamic’ (all of the objects are moving and all light sources are realtime)?

    1. Pierre Yves Donzallaz

      febrero 19, 2019 a las 7:26 pm

      Yes, it will work as well. The shadows baked in the cookie are only relative to the prop itself, not the rest of the environment. So if you do need real-time shadows, you can enable them simultaneously. Typically a lantern carried by a character or a moving chandelier. The performance considerations associated with real-time shadows remain, however. More often than not, having a good cookie, without real-time shadows, can go a long way (very common in games).

  2. Thank you for the great guide! Could you make the assets available as well to play around with to follow along with the guide?

    1. Pierre Yves Donzallaz

      febrero 19, 2019 a las 7:30 pm

      Thank you. The guide provides a link to some of the assets (the baking sphere and a wall lamp), this should be a good starting point. You just need to drop the lamp FBX into the scene and add the baked cookie texture to the Cookie property of the light gameobject. It’ll work for both HDRP and built-in render pipeline.

  3. Can you get Sykoo/Sam to do a video that shows the steps in this document?

  4. The part of the paper on fixing the results in photoshop is ineffective.
    You can rotate the uv faces correctly right in max, and combine them into a single 0-1 uv space, and render into a single 6/1 texture.

    1. Also can you remove my photo, why it it here even? Remove the post as well for good measure.

      1. nevermind, had to login into gravatar (hi 2000s) to change it.

    2. Pierre Yves Donzallaz

      febrero 7, 2019 a las 12:38 pm

      “Render to texture” in 3ds Max doesn’t support 6:1 aspect ratio, this means you’d have to crop your frame, and it is less efficient to render a 6144*6144 texture than 6 independent 1024 textures.

      Also, the shader handling the cookie could differ between rendering pipelines: for instance, one could expect a 3*2 format instead of 6*1, and it could have a different expectation for the orientation of the faces. So handling all these operations in Photoshop, with the unique square textures as Smart Objects, is a lot better in terms of iteration time and flexibility, compared to restricting yourself to a fixed UV setup. And it’s a lot faster and easier to rotate the already-rendered frames in Photoshop, instead of having to constantly re-render the frames with different UV orientations until you find the right UV setup… I’ve been there, it’s painful.

      See it as a way to distinguish the content (i.e. the faces rendered in Max, agnostically) and their format (i.e. their orientations and placements in Photoshop). Using your solution would work, for sure, that’s what I did initially, but it isn’t flexible, nor efficient.

      1. Makes sense, what about editor script that handles that automatically? Ill try writing it on weekend.

  5. Amazing guide Pierre, thank you. A bit depressing how much work is required just for light fittings though. Hopefully in a few years this could be more streamlined, all within Unity.

  6. Great to see guides like these being posted. It looks to be quite in depth – I’ll have to bookmark it for later!

  7. It says that HDRP’s Post Processing Stack supports EVs more than +9, however im on the latest HDRP version and it still only goes up to +9. Am i missing something? Is it just for PPS 5.0+?

    1. Pierre Yves Donzallaz

      febrero 6, 2019 a las 2:15 pm

      The new post-effects are getting fully integrated to HDRP itself. This is valid for HDRP 5.4, you can grab it from GitHub, “release\2019.1” branch. It isn’t available yet via the Package Manager, which is limited to 5.2.3 when using Unity 2019.1.0b2, as I write this message.

      If you grab the mentioned SRP branch from GitHub, and import the Core, Shadergraph and HDRP packages, you can then use the new exposure system by selecting your camera, adding a “Volume” component to it, and then clicking the “Add component override…” button, and picking the “Exposure” item.

      You can then override the exposure mode to “Auto”, this gives you a range from -10 to +20 EV by default, but you can go way beyond these values if you need to simulate a non Earth-based scenario or extremely bright light sources (e.g. way beyond 100’000 lux).

      You can also use the “Curve” mode, if you want to fully control the exposure with your own custom curve.

      And finally, you can also pick the “Use Physical Camera” mode, which ties the exposure to the new physical camera properties (ISO, aperture, shutter speed, etc.) set in the camera itself.

      It’s all becoming a lot more physically-correct!

  8. Really interesting, thanks so much for the detailed writeup!

  9. Those all look terrible.

    1. You’re being sarcastic I assume?

    2. They are intentionally exaggerated effects to show how they work, not practical examples.

      1. They’re probably based on photographs of real lights, they look great. Sometimes if you’re being critical and looking for flaws you’ll find them where they don’t exist. This image has all kinds of weird things you could nit pick about its lighting realism but its a photo https://kingfisher.scene7.com/is/image/Kingfisher/Category_Image_Indoor_Wall_Lights

  10. This is a great write up! Thanks!!

  11. So useful!
    ¿ How to set up critical post-processing settings in Unity Settings in Unity, such as Exposure and Tone Mapping, so that your interior scenes can be lit in a more physically-correct way, one of HDRP’s ? YES pease!!

    Pierre, Is only one channel or in the future, there will be colour in the texture?

    1. Pierre Yves Donzallaz

      febrero 5, 2019 a las 4:37 pm

      Hello Alan, HDRP does support colored cookie textures yes, you aren’t restricted to grayscale cookies like in the Built-In render pipeline.