28.11.2020

AMPLIFY SHADERS FOR BAKERY URP

Introduction

Bakery - is a GPU lightmapper plugin for Unity, which provides additional directional lightmap modes, such as Radiosity Normal Mapping (RNM), used in Half Life 2 and Spherical Harmonics, used in Frostbite engine.

The Spherical Harmonics mode gives much more realism for baked lighting. It allows to build a fully static lighting which has a zero runtime overhead, but to have beautiful highlight on surfaces and working normal maps, like if you have realtime lights in your scene.

I've created a shader for the Universal Render Pipeline, using Amplify Shader Editor, that utilizes Spherical Harmonics, baked by Bakery.
You can see a comparison between Unity's progressive lightmapper with a standard Lit shader and Bakery's result with my shaders bellow(drag the line using your mouse):



Unity has no Box Projection support for Reflection Probes in URP, so if you want to have at least some reflections and highlights you will see this ugly reflection on the floor. But when you use Bakery, you can just sacrifice reflections by disabling reflection probes on big plane objects like floor, wall and ceiling, but still have hightlights from baked light sources and even simply bright areas in your environment. Just look how solid the Bakery image looks. All objects just stand on the floor, unlike the same objects on Unity image, where they are "flying".

Also with the Bakery v1.8 release we now have an awesome feature, called Bakery Volume. This thing allows to bake a 3D-texture volume in a Unity scene and then use the baked information (3x Texture3D) in a shader to lit dynamic objects instead of lit them with Light Probes.

Here you can see two GIFs that demonstrate this feature in action and compare it with Unity Light Probes:



As you can see the chair from the first GIF receives the light and shadow like if it affected by a realtime light, because the 3D-texture volume is samples per pixel in the shader, when the Unity Light Probes have a per-object sampling and the object receives very approximate lighting. Of course, you can use Light Probe Proxy volumes, but: a) LPPV not supported in URP; b) even in other render pipelines, where LPPV supported, you need to place light probes manually and only then use LPPV per object which will sample these light probes on it. It's very time consuming tasks as minimum, and to get the same level of details in your lighting, you will need a very dense light probes grid.

On second GIF you can see the result of a very small local volume, baked only for the cupboard doors. Now the doors have a proper lighting and shadow.

Now it's a time for shaders itselfs

The NL_Bakery_SH shader is used for static lightmapped objects.
This shader mimics the standard Lit shader (almost). Its Spherical Harmonics feature based on the BakerySpecSH node, created by Ben Woodford.
Also it has integrated Specular AA technique (not exposed in material UI) and two additional sliders under the Fresnel Modifiers header. These sliders allow to get rid of very thin outline that appers on curved objects like spheres and flickers on distance. Just almost the same that Specular AA makes, but more agressive and can give physically incorrect results. But sometimes it's a good compromise, especially in VR.



The NL_Bakery_Dynamic_SH shader is almost the same as the previous shader, but it utilizes the power of Bakey Volumes, and provides some more features to adjust your materials.
For more information you can simply move your mouse cursor over a feature name and you will see a tooltip for it.

These shaders provided "as is", so I may not be able to support them fast or at all.

>Download shaders< (click right mouse button and choose "Save as...")

The models, used in this article, can be found >here<

Just import this unitypackage (right mouse button click in the Project window > Import Package > Custom Package), and you will find the shaders under NOT_Lonely/URP/ shader selector dropdown in your materials.