InlineRayTracingShadows
Sample scene that uses ray traced shadows generated by a compute shader using ray queries.
Install / Use
/learn @INedelcu/InlineRayTracingShadowsREADME
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
- Unity 2023.1 beta - inline ray tracing support in compute shaders.
- Unity 2023.2 beta and above - inline ray tracing support in any shader stage.
- SystemInfo.supportsInlineRayTracing must be true.
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:
- The Rendering Path must be set to Deferred in Camera settings.
- The shadow is currently generated on top of everything else so the regular shadows must be disabled from the Light settings.
- The effect works only in Game view.
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">Related Skills
node-connect
344.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
99.2kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
344.4kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
344.4kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
