Shaders are an essential component of game development, providing the visual effects that help to…
Unity 2022 is here and with URP 14 comes Forward Plus (F+), an important enhancement to the previous forward rendering path in relation to the number of lights that can be rendered in a more performant way.
In F+, URP divides the view space into tiles and each tile in an array of bins based on distance to near clip plane (z-depth). Every frame, the Universal Renderer will execute dedicated jobs to assign each visible light into one or more bins of the previous structure. Then, during the forward light pass of a fragment shader, the NDC or screen uv coordinate of each pixel is used to locate the appropriate tile and it’s position z to gather the visible lights from its “z-bin”. This technique ensures that only the valid lights that affect each pixel are parsed and evaluated even if the scene contains hundred of lights. Depending on the platform, the maximum visible lights can be up to 256.
In Volumetric Fog & Mist 12.0 we added support to F+. When the “Enable Native Lights” option is used, the shader will grab the lights which influence the fog using the z-bin structures above which produces a more accurate result than before. In the previous and simpler forward rendering path approach, all visible lights would be iterated causing an important performance loss if many lights are visible at the same time.
Note that even with F+, performance depends on the number of lights per tile, so even if you can now use hundred of lights, it’s important to distribute them wisely and avoid excessive overlap (check light range setting) so only a few lights are evaluated per pixel. Light evaluation includes shadow sampling.
Volumetric Fog & Mist 2 includes support for the directional light (+ shadows), fast point lights and native lights. Fast point lights is an optimization that only takes into account point lights in the scene (without shadows) while the native lights option, now with F+ support, implements all light types + shadows (requires a fast graphics card on PC or Mac).
In order to test the new F+ support, we made a demo using the Vikings Village for URP. You can use the on-screen menu to toggle on/off a few options to compare how it impacts performance on your specific graphics card.