Home

Awesome

Inline Ray Tracing Shadows

Sample scene that uses ray traced shadows generated by a compute shader using ray queries (DXR 1.1).

Technical Document

https://docs.google.com/document/d/1uRoUbW4m6Y_Bo7uCRUKwEhbKVTu5MKvto-Pm89DYXoY/edit

Requirements

Effect Description

The shadow texture is generated in screen space and blit directly on top of the rendered scene. To generate the screen space shadows texture, a compute shader reads the depth value from _CameraDepthTexture built-in texture. The world space position for a particular pixel is generated and from that point a number of rays are cast along the light direction with some random offsets for generating variable penumbra based on the distance from the shadow caster.

The world normal is read from the GBuffer _CameraGBufferTexture2 and is used to avoid generating shadows for surfaces that have the same orientation as the directional light.

There is a simple temporal accumulation of samples which resets when parameters related to camera change.

Limitations:

Examples using varying penumbra based on distance to shadow caster and Shadow Spread option (Main Camera).

<img src="Images/1.jpg" width="1280"> <img src="Images/2.jpg" width="1280"> <img src="Images/3.jpg" width="1280">