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!
TJ Jordan
February 18, 2019 at 7:07 pmWill 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)?
Pierre Yves Donzallaz
February 19, 2019 at 7:26 pmYes, 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).
Markus
February 18, 2019 at 10:24 amThank you for the great guide! Could you make the assets available as well to play around with to follow along with the guide?
Pierre Yves Donzallaz
February 19, 2019 at 7:30 pmThank 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.
Beard or Die
February 12, 2019 at 6:55 pmCan you get Sykoo/Sam to do a video that shows the steps in this document?
pointcache
February 7, 2019 at 3:27 amThe 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.
pointcache
February 7, 2019 at 3:29 amAlso can you remove my photo, why it it here even? Remove the post as well for good measure.
pointcache
February 7, 2019 at 4:15 amnevermind, had to login into gravatar (hi 2000s) to change it.
Pierre Yves Donzallaz
February 7, 2019 at 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.
pointcache
February 7, 2019 at 1:11 pmMakes sense, what about editor script that handles that automatically? Ill try writing it on weekend.
Ted
February 6, 2019 at 2:55 pmAmazing 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.
Mac
February 5, 2019 at 9:38 pmGreat to see guides like these being posted. It looks to be quite in depth – I’ll have to bookmark it for later!
Custom Phase
February 5, 2019 at 9:38 pmIt 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+?
Pierre Yves Donzallaz
February 6, 2019 at 2:15 pmThe 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!
GZ
February 5, 2019 at 8:30 pmReally interesting, thanks so much for the detailed writeup!
Bryan
February 5, 2019 at 7:09 pmThose all look terrible.
Daniel
February 5, 2019 at 8:23 pmYou’re being sarcastic I assume?
Liz
February 6, 2019 at 1:09 amThey are intentionally exaggerated effects to show how they work, not practical examples.
sterling crispin
February 6, 2019 at 5:07 pmThey’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
Justin
February 5, 2019 at 6:21 pmThis is a great write up! Thanks!!
Alan Mattano
February 5, 2019 at 3:56 pmSo 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?
Pierre Yves Donzallaz
February 5, 2019 at 4:37 pmHello Alan, HDRP does support colored cookie textures yes, you aren’t restricted to grayscale cookies like in the Built-In render pipeline.