Tech News
← Back to articles

Shaping Light – Volumetric Lighting

read original related products more articles

As I became more familiar with post-processing over the past few months, I was curious to push those newly learned techniques beyond pure stylization to achieve something more functional. I wanted to find new ways to enrich my 3D work which wouldn't be possible without leveraging effects and passes alongside custom shaders.

As it turns out, post-processing is great entrypoint to enhance a 3D scene with atmospheric and lighting effects, allowing for more realistic and dramatic visuals. Because these effects operate in screen space, their performance cost is decoupled from the underlying scene's complexity, making them an efficient solution for balancing performance and visual quality. At the end of the day, when we work with effects, we are still just drawing pixels on a screen.

Among those effects, Volumetric Lighting was the first one to catch my attention as I always wanted to create those beautiful beams of light, shining through trees or buildings, creating a dreamy and atmospheric vibe to my work (heavily featured in "Clair Obscur: Expedition 33" which I've been playing a lot recently for "research purposes"). On top of that, I found out that these light effects can be made possible with Volumetric Raymarching, a topic I've covered in the past but haven't found any practical application in my React Three Fiber work so far!

Thus, by combining these two seemingly unrelated pieces, that are post-processing and raymarching, in the context of volumetric lighting, I discovered a new set of tricks to complement my shader work, enhance the visual of my scenes, and, more importantly, share with you. In this article, I'll showcase not only what makes a good volumetric lighting effect using raymarching, but also detail every technique behind it, such as coordinate space transformations, shadow mapping, and new usage of depth buffers, as well as further expansions into multi-directional lighting and multi-light examples.

The scenes of the demos featured throughout this article are inspired by the work of the following talented folks: hmans.dev for his space scene which inspired one of my demos and from which I borrowed the asteroid asset.

jackdavenport who made a beautiful scene applying volumetric lighting on ShaderToy

Vlad Ponomarenko whose Spline work helped me craft a great demo to apply volumetric lighting and make this effect shine.

Support my work Enjoying the content and feeling like supporting my work? You can show your appreciation by You can show your appreciation by buying me a coffee which will give me the much-needed energy to take on more ambitious/high-quality articles and projects. Thank you for reading!

Raymarching Light with Post-Processing As someone whose only experience with post-processing was for stylization purposes, leveraging it alongside volumetric raymarching, which I studied in depth separately, was enticing. The resulting combination would allow one to paint arbitrary light effects onto a scene based on the camera's position, the source of the light, and all of that while taking into account the many objects that could compose the scene. However, there was still a clear divide that made the result feel unreachable at first: raymarching operates in a three-dimensional space, while post-processing lives in screen space, which is two-dimensional. Thus, before diving into anything related to volumetric lighting proper, we should first learn about the process allowing us to jump from one to the other: coordinate system transformations. Coordinate systems and transformations 3D scenes operate across several coordinate systems that each have a specific role: Object/Model space : where coordinates are relative to the object's origin.

World space : the shared coordinate system between all objects on the scene.

... continue reading