SlideShare a Scribd company logo
1 of 20
Getting Started with Ray
Tracing in Unity 2019.3
Dany Ayoub - Technical Artist
Kate McFadden - Senior Demo Artist
Soner Sen - Desktop Graphics Lead
Overview
3
— Technical details
– DXR
– Acceleration Structure
– Ray tracing shaders
– HDRP integration
— Demo and Samples
— We’re done!
How Ray Tracing Works
in Unity 2019.3
4
DXR Overview
5
API designed to leverage hardware-accelerated ray
tracing
Why trace rays?
— Off-screen rendering (reflection, refraction)
— Algorithms that calls for raycasting
Two major concepts to be concerned with:
— Ray Tracing Acceleration Structures:
What are we drawing?
— Ray Tracing Shaders:
How should we draw things?
Acceleration Structure
6
— Bottom-Level AS: only geometry
— BVH: construction done by driver
— Top-Level AS: Materials,
transforms, hierarchy
Acceleration Structure
7
— New Unity class: RayTracingAccelerationStructure
— Manually or automatically managed
– Manual: AddInstance(), UpdateInstanceTransform()
— Specify layer masks to filter GameObjects to be added
— Call BuildRayTracingAccelerationStructure once a frame
— New Renderer setting: RayTracingMode
— In the order of least to most expensive
– Off
– Static
– DynamicTransform
– DynamicGeometry (WIP)
Acceleration Structure
8
Ray Tracing Shaders
9
— Raytrace shaders
– Raygeneration: First shader executed during dispatch
– Miss: Executes only if ray fails to intersect any object
— Surface shaders
– ClosestHit: Executes for the intersection nearest to ray
origin
– AnyHit: Executes for every intersection
— Callable Shaders
Ray Tracing Shaders
10
— New shader type: RayTracingShader
– Extension is .raytrace
— CommandBuffer API additions
– CommandBuffer.SetRayTracingShaderPass
– CommandBuffer.SetRayTracingAccelerationStructure
– CommandBuffer.SetRayTracing*Param
– e.g. SetRayTracingMatrixParam, SetRayTracingIntParam, etc.
– CommandBuffer.DispatchRays
– Analogous bindings also available from RayTracingShader class
itself, for immediate execution
Ray Tracing Shader API
11
Ray Tracing Shader Authoring
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Dispatch shader: Defines at minimum a ray generation shader, often also a miss shader.
// This is the shader that is dispatched, as one would a compute shader,
// for a given ray traced pass.
struct RayPayload { float4 color; uint2 launchIdx; }; // User-defined
[shader(“raygeneration”)]
void FullResRayGen()
{
uint2 launchIdx = DispatchRaysIndex().xy; // DXR callback
uint2 launchDim = DispatchRaysDimensions().xy; // DXR callback
float2 ndcCoords = (launchIdx / float2(launchDim.x - 1, launchDim.y - 1)) * 2 - float2(1, 1);
float3 viewDirection = normalize(float3(ndcCoords.x * aspectRatio, ndcCoords.y, -1);
RayDesc ray; // DXR defined
ray.Origin = float3(camera_IV[0][3], camera_IV[1][3], camera_IV[2][3]);
ray.Direction = normalize(mul(camera_IV, viewDirection));
ray.TMin = 0;
ray.TMax = 1e20f;
RayPayLoad payload;
payload.color = float4(0, 0, 0, 0);
TraceRay(accelerationStructure, 0, 0xFF, 0, 1, 0, ray, payload); // DXR callback
}
12
Ray Tracing Shader Authoring
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
[shader(“miss”)]
void SampleSkybox(inout RayPayload payload : SV_RayPayload)
{
rayDirection = WorldRayDirection();
float4 skyboxColor = skyboxTex.SampleLevel(linearRepeatSampler, rayDirection, 0);
payload.color = skyboxColor;
}
// These slides have a good introduction to built-in DXR callbacks:
// http://intro-to-dxr.cwyman.org/presentations/IntroDXR_RaytracingShaders.pdf
13
Surface Shader Authoring for Ray Tracing
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Material/Surface shader: Hit shaders should be defined as a pass in a shader used for a
// material in the scene.
Shader “FlatColor”
{
SubShader { Pass { CGPROGRAM
#pragma vertex vert
#pragma fragment frag
v2f vert (appdata v) { return UnityObjectToClipPos(v.vertex); }
fixed4 frag (v2f i) : SV_Target { return albedo; }
ENDCG
} }
SubShader { Pass Name "DefaultRTPass" { HLSLPROGRAM // Pass name must match that specified
by SetShaderPass()
#pragma raytracing
struct AttributeData { float2 barycentrics; }; // User-defined
[shader(“closesthit”)]
void FullResRayGen(inout RayPayload payload : SV_RayPayload,
AttributeData attribs : SV_IntersectionAttributes)
{ // A trivial hit shader that populates a bound RT with albedo of hit object
payload.color = albedo;
outputRT[payload.launchIdx] = albedo;
} ENDHLSL
} }
}
14
— Windows 10 v1809+
— Unity 2019.3b1+
— DXR capable graphics card with
latest drivers
Requirements for Ray Tracing
15
Unity > Edit > Project Settings > Player:
— Select DX12 as Windows Graphics
API
State of Ray Tracing in Unity
16
— Ray tracing API is pipeline-agnostic
– Officially supported for only HDRP
– HDRP is the only pipeline that actually implements features using ray
tracing
– Users can still use the public C# API to build their own features!
— Unsupported in 19.3:
– Intersection shaders
– Animated meshes
– Procedural geometry
HDRP Ray Tracing Architecture
17
— Primary rays for most effects are computed from depth/normal buffers
— Cluster-based lighting added to HDRP for ray tracing
— Render graph here is simplified and omits many HDRP stages
TransparencyShadowsIndirect Lighting
Ray Traced Effects on HDRP
18
Thank You!
Any Questions?
dany@unity3d.com
katem@unity3d.com
soner@unity3d.com
Want to learn more?
Project:
Unity Lighting Fundamentals
Tutorial:
Post-Processing Effects
(2018.x+)
Tutorial:
HDRP Material Properties
Subscribe now for a 3-month free trial at unity.com/learn-
premium with code: UNITECPH19
*Learn Premium is included in Unity Plus and Pro licenses. Just sign in with your Unity ID.

More Related Content

What's hot

Frostbite Rendering Architecture and Real-time Procedural Shading & Texturing...
Frostbite Rendering Architecture and Real-time Procedural Shading & Texturing...Frostbite Rendering Architecture and Real-time Procedural Shading & Texturing...
Frostbite Rendering Architecture and Real-time Procedural Shading & Texturing...Johan Andersson
 
【Unite Tokyo 2019】Unityプログレッシブライトマッパー2019
【Unite Tokyo 2019】Unityプログレッシブライトマッパー2019【Unite Tokyo 2019】Unityプログレッシブライトマッパー2019
【Unite Tokyo 2019】Unityプログレッシブライトマッパー2019UnityTechnologiesJapan002
 
FrameGraph: Extensible Rendering Architecture in Frostbite
FrameGraph: Extensible Rendering Architecture in FrostbiteFrameGraph: Extensible Rendering Architecture in Frostbite
FrameGraph: Extensible Rendering Architecture in FrostbiteElectronic Arts / DICE
 
Low-level Shader Optimization for Next-Gen and DX11 by Emil Persson
Low-level Shader Optimization for Next-Gen and DX11 by Emil PerssonLow-level Shader Optimization for Next-Gen and DX11 by Emil Persson
Low-level Shader Optimization for Next-Gen and DX11 by Emil PerssonAMD Developer Central
 
Unite2019 HLOD를 활용한 대규모 씬 제작 방법
Unite2019 HLOD를 활용한 대규모 씬 제작 방법Unite2019 HLOD를 활용한 대규모 씬 제작 방법
Unite2019 HLOD를 활용한 대규모 씬 제작 방법장규 서
 
4K Checkerboard in Battlefield 1 and Mass Effect Andromeda
4K Checkerboard in Battlefield 1 and Mass Effect Andromeda4K Checkerboard in Battlefield 1 and Mass Effect Andromeda
4K Checkerboard in Battlefield 1 and Mass Effect AndromedaElectronic Arts / DICE
 
Lighting Shading by John Hable
Lighting Shading by John HableLighting Shading by John Hable
Lighting Shading by John HableNaughty Dog
 
Optimizing the Graphics Pipeline with Compute, GDC 2016
Optimizing the Graphics Pipeline with Compute, GDC 2016Optimizing the Graphics Pipeline with Compute, GDC 2016
Optimizing the Graphics Pipeline with Compute, GDC 2016Graham Wihlidal
 
Five Rendering Ideas from Battlefield 3 & Need For Speed: The Run
Five Rendering Ideas from Battlefield 3 & Need For Speed: The RunFive Rendering Ideas from Battlefield 3 & Need For Speed: The Run
Five Rendering Ideas from Battlefield 3 & Need For Speed: The RunElectronic Arts / DICE
 
OpenGL 3.2 and More
OpenGL 3.2 and MoreOpenGL 3.2 and More
OpenGL 3.2 and MoreMark Kilgard
 
Graphics Gems from CryENGINE 3 (Siggraph 2013)
Graphics Gems from CryENGINE 3 (Siggraph 2013)Graphics Gems from CryENGINE 3 (Siggraph 2013)
Graphics Gems from CryENGINE 3 (Siggraph 2013)Tiago Sousa
 
SIGGRAPH 2018 - Full Rays Ahead! From Raster to Real-Time Raytracing
SIGGRAPH 2018 - Full Rays Ahead! From Raster to Real-Time RaytracingSIGGRAPH 2018 - Full Rays Ahead! From Raster to Real-Time Raytracing
SIGGRAPH 2018 - Full Rays Ahead! From Raster to Real-Time RaytracingElectronic Arts / DICE
 
A Bit More Deferred Cry Engine3
A Bit More Deferred   Cry Engine3A Bit More Deferred   Cry Engine3
A Bit More Deferred Cry Engine3guest11b095
 
Unity - Internals: memory and performance
Unity - Internals: memory and performanceUnity - Internals: memory and performance
Unity - Internals: memory and performanceCodemotion
 
A Bizarre Way to do Real-Time Lighting
A Bizarre Way to do Real-Time LightingA Bizarre Way to do Real-Time Lighting
A Bizarre Way to do Real-Time LightingSteven Tovey
 
Ndc12 이창희 render_pipeline
Ndc12 이창희 render_pipelineNdc12 이창희 render_pipeline
Ndc12 이창희 render_pipelinechangehee lee
 

What's hot (20)

Frostbite Rendering Architecture and Real-time Procedural Shading & Texturing...
Frostbite Rendering Architecture and Real-time Procedural Shading & Texturing...Frostbite Rendering Architecture and Real-time Procedural Shading & Texturing...
Frostbite Rendering Architecture and Real-time Procedural Shading & Texturing...
 
【Unite Tokyo 2019】Unityプログレッシブライトマッパー2019
【Unite Tokyo 2019】Unityプログレッシブライトマッパー2019【Unite Tokyo 2019】Unityプログレッシブライトマッパー2019
【Unite Tokyo 2019】Unityプログレッシブライトマッパー2019
 
Unity3D Programming
Unity3D ProgrammingUnity3D Programming
Unity3D Programming
 
FrameGraph: Extensible Rendering Architecture in Frostbite
FrameGraph: Extensible Rendering Architecture in FrostbiteFrameGraph: Extensible Rendering Architecture in Frostbite
FrameGraph: Extensible Rendering Architecture in Frostbite
 
Low-level Shader Optimization for Next-Gen and DX11 by Emil Persson
Low-level Shader Optimization for Next-Gen and DX11 by Emil PerssonLow-level Shader Optimization for Next-Gen and DX11 by Emil Persson
Low-level Shader Optimization for Next-Gen and DX11 by Emil Persson
 
Unite2019 HLOD를 활용한 대규모 씬 제작 방법
Unite2019 HLOD를 활용한 대규모 씬 제작 방법Unite2019 HLOD를 활용한 대규모 씬 제작 방법
Unite2019 HLOD를 활용한 대규모 씬 제작 방법
 
4K Checkerboard in Battlefield 1 and Mass Effect Andromeda
4K Checkerboard in Battlefield 1 and Mass Effect Andromeda4K Checkerboard in Battlefield 1 and Mass Effect Andromeda
4K Checkerboard in Battlefield 1 and Mass Effect Andromeda
 
Frostbite on Mobile
Frostbite on MobileFrostbite on Mobile
Frostbite on Mobile
 
Lighting Shading by John Hable
Lighting Shading by John HableLighting Shading by John Hable
Lighting Shading by John Hable
 
Stochastic Screen-Space Reflections
Stochastic Screen-Space ReflectionsStochastic Screen-Space Reflections
Stochastic Screen-Space Reflections
 
Optimizing the Graphics Pipeline with Compute, GDC 2016
Optimizing the Graphics Pipeline with Compute, GDC 2016Optimizing the Graphics Pipeline with Compute, GDC 2016
Optimizing the Graphics Pipeline with Compute, GDC 2016
 
Five Rendering Ideas from Battlefield 3 & Need For Speed: The Run
Five Rendering Ideas from Battlefield 3 & Need For Speed: The RunFive Rendering Ideas from Battlefield 3 & Need For Speed: The Run
Five Rendering Ideas from Battlefield 3 & Need For Speed: The Run
 
Hair in Tomb Raider
Hair in Tomb RaiderHair in Tomb Raider
Hair in Tomb Raider
 
OpenGL 3.2 and More
OpenGL 3.2 and MoreOpenGL 3.2 and More
OpenGL 3.2 and More
 
Graphics Gems from CryENGINE 3 (Siggraph 2013)
Graphics Gems from CryENGINE 3 (Siggraph 2013)Graphics Gems from CryENGINE 3 (Siggraph 2013)
Graphics Gems from CryENGINE 3 (Siggraph 2013)
 
SIGGRAPH 2018 - Full Rays Ahead! From Raster to Real-Time Raytracing
SIGGRAPH 2018 - Full Rays Ahead! From Raster to Real-Time RaytracingSIGGRAPH 2018 - Full Rays Ahead! From Raster to Real-Time Raytracing
SIGGRAPH 2018 - Full Rays Ahead! From Raster to Real-Time Raytracing
 
A Bit More Deferred Cry Engine3
A Bit More Deferred   Cry Engine3A Bit More Deferred   Cry Engine3
A Bit More Deferred Cry Engine3
 
Unity - Internals: memory and performance
Unity - Internals: memory and performanceUnity - Internals: memory and performance
Unity - Internals: memory and performance
 
A Bizarre Way to do Real-Time Lighting
A Bizarre Way to do Real-Time LightingA Bizarre Way to do Real-Time Lighting
A Bizarre Way to do Real-Time Lighting
 
Ndc12 이창희 render_pipeline
Ndc12 이창희 render_pipelineNdc12 이창희 render_pipeline
Ndc12 이창희 render_pipeline
 

Similar to Getting started with Ray Tracing in Unity 2019.3 - Unite Copenhagen 2019

02 direct3 d_pipeline
02 direct3 d_pipeline02 direct3 d_pipeline
02 direct3 d_pipelineGirish Ghate
 
Custom SRP and graphics workflows - Unite Copenhagen 2019
Custom SRP and graphics workflows - Unite Copenhagen 2019Custom SRP and graphics workflows - Unite Copenhagen 2019
Custom SRP and graphics workflows - Unite Copenhagen 2019Unity Technologies
 
Khronos Munich 2018 - Halcyon and Vulkan
Khronos Munich 2018 - Halcyon and VulkanKhronos Munich 2018 - Halcyon and Vulkan
Khronos Munich 2018 - Halcyon and VulkanElectronic Arts / DICE
 
Your Game Needs Direct3D 11, So Get Started Now!
Your Game Needs Direct3D 11, So Get Started Now!Your Game Needs Direct3D 11, So Get Started Now!
Your Game Needs Direct3D 11, So Get Started Now!Johan Andersson
 
vkFX: Effect(ive) approach for Vulkan API
vkFX: Effect(ive) approach for Vulkan APIvkFX: Effect(ive) approach for Vulkan API
vkFX: Effect(ive) approach for Vulkan APITristan Lorach
 
Syysgraph 2018 - Modern Graphics Abstractions & Real-Time Ray Tracing
Syysgraph 2018 - Modern Graphics Abstractions & Real-Time Ray TracingSyysgraph 2018 - Modern Graphics Abstractions & Real-Time Ray Tracing
Syysgraph 2018 - Modern Graphics Abstractions & Real-Time Ray TracingElectronic Arts / DICE
 
Minko stage3d 20130222
Minko stage3d 20130222Minko stage3d 20130222
Minko stage3d 20130222Minko3D
 
3 boyd direct3_d12 (1)
3 boyd direct3_d12 (1)3 boyd direct3_d12 (1)
3 boyd direct3_d12 (1)mistercteam
 
Shape12 6
Shape12 6Shape12 6
Shape12 6pslulli
 
Summer Games University - Day 3
Summer Games University - Day 3Summer Games University - Day 3
Summer Games University - Day 3Clemens Kern
 
Introduction to Direct 3D 12 by Ivan Nevraev
Introduction to Direct 3D 12 by Ivan NevraevIntroduction to Direct 3D 12 by Ivan Nevraev
Introduction to Direct 3D 12 by Ivan NevraevAMD Developer Central
 
Implementing a modern, RenderMan compliant, REYES renderer
Implementing a modern, RenderMan compliant, REYES rendererImplementing a modern, RenderMan compliant, REYES renderer
Implementing a modern, RenderMan compliant, REYES rendererDavide Pasca
 
Creating Custom Charts With Ruby Vector Graphics
Creating Custom Charts With Ruby Vector GraphicsCreating Custom Charts With Ruby Vector Graphics
Creating Custom Charts With Ruby Vector GraphicsDavid Keener
 
Minko stage3d workshop_20130525
Minko stage3d workshop_20130525Minko stage3d workshop_20130525
Minko stage3d workshop_20130525Minko3D
 
Android RenderScript
Android RenderScriptAndroid RenderScript
Android RenderScriptJungsoo Nam
 
GS-4108, Direct Compute in Gaming, by Bill Bilodeau
GS-4108, Direct Compute in Gaming, by Bill BilodeauGS-4108, Direct Compute in Gaming, by Bill Bilodeau
GS-4108, Direct Compute in Gaming, by Bill BilodeauAMD Developer Central
 
Optimizing unity games (Google IO 2014)
Optimizing unity games (Google IO 2014)Optimizing unity games (Google IO 2014)
Optimizing unity games (Google IO 2014)Alexander Dolbilov
 
Optimizing NN inference performance on Arm NEON and Vulkan
Optimizing NN inference performance on Arm NEON and VulkanOptimizing NN inference performance on Arm NEON and Vulkan
Optimizing NN inference performance on Arm NEON and Vulkanax inc.
 

Similar to Getting started with Ray Tracing in Unity 2019.3 - Unite Copenhagen 2019 (20)

NvFX GTC 2013
NvFX GTC 2013NvFX GTC 2013
NvFX GTC 2013
 
02 direct3 d_pipeline
02 direct3 d_pipeline02 direct3 d_pipeline
02 direct3 d_pipeline
 
Custom SRP and graphics workflows - Unite Copenhagen 2019
Custom SRP and graphics workflows - Unite Copenhagen 2019Custom SRP and graphics workflows - Unite Copenhagen 2019
Custom SRP and graphics workflows - Unite Copenhagen 2019
 
Khronos Munich 2018 - Halcyon and Vulkan
Khronos Munich 2018 - Halcyon and VulkanKhronos Munich 2018 - Halcyon and Vulkan
Khronos Munich 2018 - Halcyon and Vulkan
 
Your Game Needs Direct3D 11, So Get Started Now!
Your Game Needs Direct3D 11, So Get Started Now!Your Game Needs Direct3D 11, So Get Started Now!
Your Game Needs Direct3D 11, So Get Started Now!
 
vkFX: Effect(ive) approach for Vulkan API
vkFX: Effect(ive) approach for Vulkan APIvkFX: Effect(ive) approach for Vulkan API
vkFX: Effect(ive) approach for Vulkan API
 
Syysgraph 2018 - Modern Graphics Abstractions & Real-Time Ray Tracing
Syysgraph 2018 - Modern Graphics Abstractions & Real-Time Ray TracingSyysgraph 2018 - Modern Graphics Abstractions & Real-Time Ray Tracing
Syysgraph 2018 - Modern Graphics Abstractions & Real-Time Ray Tracing
 
Minko stage3d 20130222
Minko stage3d 20130222Minko stage3d 20130222
Minko stage3d 20130222
 
3 boyd direct3_d12 (1)
3 boyd direct3_d12 (1)3 boyd direct3_d12 (1)
3 boyd direct3_d12 (1)
 
Shape12 6
Shape12 6Shape12 6
Shape12 6
 
Summer Games University - Day 3
Summer Games University - Day 3Summer Games University - Day 3
Summer Games University - Day 3
 
Introduction to Direct 3D 12 by Ivan Nevraev
Introduction to Direct 3D 12 by Ivan NevraevIntroduction to Direct 3D 12 by Ivan Nevraev
Introduction to Direct 3D 12 by Ivan Nevraev
 
Implementing a modern, RenderMan compliant, REYES renderer
Implementing a modern, RenderMan compliant, REYES rendererImplementing a modern, RenderMan compliant, REYES renderer
Implementing a modern, RenderMan compliant, REYES renderer
 
Creating Custom Charts With Ruby Vector Graphics
Creating Custom Charts With Ruby Vector GraphicsCreating Custom Charts With Ruby Vector Graphics
Creating Custom Charts With Ruby Vector Graphics
 
Minko stage3d workshop_20130525
Minko stage3d workshop_20130525Minko stage3d workshop_20130525
Minko stage3d workshop_20130525
 
Android RenderScript
Android RenderScriptAndroid RenderScript
Android RenderScript
 
FLAR Workflow
FLAR WorkflowFLAR Workflow
FLAR Workflow
 
GS-4108, Direct Compute in Gaming, by Bill Bilodeau
GS-4108, Direct Compute in Gaming, by Bill BilodeauGS-4108, Direct Compute in Gaming, by Bill Bilodeau
GS-4108, Direct Compute in Gaming, by Bill Bilodeau
 
Optimizing unity games (Google IO 2014)
Optimizing unity games (Google IO 2014)Optimizing unity games (Google IO 2014)
Optimizing unity games (Google IO 2014)
 
Optimizing NN inference performance on Arm NEON and Vulkan
Optimizing NN inference performance on Arm NEON and VulkanOptimizing NN inference performance on Arm NEON and Vulkan
Optimizing NN inference performance on Arm NEON and Vulkan
 

More from Unity Technologies

Build Immersive Worlds in Virtual Reality
Build Immersive Worlds  in Virtual RealityBuild Immersive Worlds  in Virtual Reality
Build Immersive Worlds in Virtual RealityUnity Technologies
 
Augmenting reality: Bring digital objects into the real world
Augmenting reality: Bring digital objects into the real worldAugmenting reality: Bring digital objects into the real world
Augmenting reality: Bring digital objects into the real worldUnity Technologies
 
Let’s get real: An introduction to AR, VR, MR, XR and more
Let’s get real: An introduction to AR, VR, MR, XR and moreLet’s get real: An introduction to AR, VR, MR, XR and more
Let’s get real: An introduction to AR, VR, MR, XR and moreUnity Technologies
 
Using synthetic data for computer vision model training
Using synthetic data for computer vision model trainingUsing synthetic data for computer vision model training
Using synthetic data for computer vision model trainingUnity Technologies
 
The Tipping Point: How Virtual Experiences Are Transforming Global Industries
The Tipping Point: How Virtual Experiences Are Transforming Global IndustriesThe Tipping Point: How Virtual Experiences Are Transforming Global Industries
The Tipping Point: How Virtual Experiences Are Transforming Global IndustriesUnity Technologies
 
Unity Roadmap 2020: Live games
Unity Roadmap 2020: Live games Unity Roadmap 2020: Live games
Unity Roadmap 2020: Live games Unity Technologies
 
Unity Roadmap 2020: Core Engine & Creator Tools
Unity Roadmap 2020: Core Engine & Creator ToolsUnity Roadmap 2020: Core Engine & Creator Tools
Unity Roadmap 2020: Core Engine & Creator ToolsUnity Technologies
 
How ABB shapes the future of industry with Microsoft HoloLens and Unity - Uni...
How ABB shapes the future of industry with Microsoft HoloLens and Unity - Uni...How ABB shapes the future of industry with Microsoft HoloLens and Unity - Uni...
How ABB shapes the future of industry with Microsoft HoloLens and Unity - Uni...Unity Technologies
 
Unity XR platform has a new architecture – Unite Copenhagen 2019
Unity XR platform has a new architecture – Unite Copenhagen 2019Unity XR platform has a new architecture – Unite Copenhagen 2019
Unity XR platform has a new architecture – Unite Copenhagen 2019Unity Technologies
 
Turn Revit Models into real-time 3D experiences
Turn Revit Models into real-time 3D experiencesTurn Revit Models into real-time 3D experiences
Turn Revit Models into real-time 3D experiencesUnity Technologies
 
How Daimler uses mobile mixed realities for training and sales - Unite Copenh...
How Daimler uses mobile mixed realities for training and sales - Unite Copenh...How Daimler uses mobile mixed realities for training and sales - Unite Copenh...
How Daimler uses mobile mixed realities for training and sales - Unite Copenh...Unity Technologies
 
How Volvo embraced real-time 3D and shook up the auto industry- Unite Copenha...
How Volvo embraced real-time 3D and shook up the auto industry- Unite Copenha...How Volvo embraced real-time 3D and shook up the auto industry- Unite Copenha...
How Volvo embraced real-time 3D and shook up the auto industry- Unite Copenha...Unity Technologies
 
QA your code: The new Unity Test Framework – Unite Copenhagen 2019
QA your code: The new Unity Test Framework – Unite Copenhagen 2019QA your code: The new Unity Test Framework – Unite Copenhagen 2019
QA your code: The new Unity Test Framework – Unite Copenhagen 2019Unity Technologies
 
Engineering.com webinar: Real-time 3D and digital twins: The power of a virtu...
Engineering.com webinar: Real-time 3D and digital twins: The power of a virtu...Engineering.com webinar: Real-time 3D and digital twins: The power of a virtu...
Engineering.com webinar: Real-time 3D and digital twins: The power of a virtu...Unity Technologies
 
Supplying scalable VR training applications with Innoactive - Unite Copenhage...
Supplying scalable VR training applications with Innoactive - Unite Copenhage...Supplying scalable VR training applications with Innoactive - Unite Copenhage...
Supplying scalable VR training applications with Innoactive - Unite Copenhage...Unity Technologies
 
XR and real-time 3D in automotive digital marketing strategies | Visionaries ...
XR and real-time 3D in automotive digital marketing strategies | Visionaries ...XR and real-time 3D in automotive digital marketing strategies | Visionaries ...
XR and real-time 3D in automotive digital marketing strategies | Visionaries ...Unity Technologies
 
Real-time CG animation in Unity: unpacking the Sherman project - Unite Copenh...
Real-time CG animation in Unity: unpacking the Sherman project - Unite Copenh...Real-time CG animation in Unity: unpacking the Sherman project - Unite Copenh...
Real-time CG animation in Unity: unpacking the Sherman project - Unite Copenh...Unity Technologies
 
Creating next-gen VR and MR experiences using Varjo VR-1 and XR-1 - Unite Cop...
Creating next-gen VR and MR experiences using Varjo VR-1 and XR-1 - Unite Cop...Creating next-gen VR and MR experiences using Varjo VR-1 and XR-1 - Unite Cop...
Creating next-gen VR and MR experiences using Varjo VR-1 and XR-1 - Unite Cop...Unity Technologies
 
What's ahead for film and animation with Unity 2020 - Unite Copenhagen 2019
What's ahead for film and animation with Unity 2020 - Unite Copenhagen 2019What's ahead for film and animation with Unity 2020 - Unite Copenhagen 2019
What's ahead for film and animation with Unity 2020 - Unite Copenhagen 2019Unity Technologies
 
How to Improve Visual Rendering Quality in VR - Unite Copenhagen 2019
How to Improve Visual Rendering Quality in VR - Unite Copenhagen 2019How to Improve Visual Rendering Quality in VR - Unite Copenhagen 2019
How to Improve Visual Rendering Quality in VR - Unite Copenhagen 2019Unity Technologies
 

More from Unity Technologies (20)

Build Immersive Worlds in Virtual Reality
Build Immersive Worlds  in Virtual RealityBuild Immersive Worlds  in Virtual Reality
Build Immersive Worlds in Virtual Reality
 
Augmenting reality: Bring digital objects into the real world
Augmenting reality: Bring digital objects into the real worldAugmenting reality: Bring digital objects into the real world
Augmenting reality: Bring digital objects into the real world
 
Let’s get real: An introduction to AR, VR, MR, XR and more
Let’s get real: An introduction to AR, VR, MR, XR and moreLet’s get real: An introduction to AR, VR, MR, XR and more
Let’s get real: An introduction to AR, VR, MR, XR and more
 
Using synthetic data for computer vision model training
Using synthetic data for computer vision model trainingUsing synthetic data for computer vision model training
Using synthetic data for computer vision model training
 
The Tipping Point: How Virtual Experiences Are Transforming Global Industries
The Tipping Point: How Virtual Experiences Are Transforming Global IndustriesThe Tipping Point: How Virtual Experiences Are Transforming Global Industries
The Tipping Point: How Virtual Experiences Are Transforming Global Industries
 
Unity Roadmap 2020: Live games
Unity Roadmap 2020: Live games Unity Roadmap 2020: Live games
Unity Roadmap 2020: Live games
 
Unity Roadmap 2020: Core Engine & Creator Tools
Unity Roadmap 2020: Core Engine & Creator ToolsUnity Roadmap 2020: Core Engine & Creator Tools
Unity Roadmap 2020: Core Engine & Creator Tools
 
How ABB shapes the future of industry with Microsoft HoloLens and Unity - Uni...
How ABB shapes the future of industry with Microsoft HoloLens and Unity - Uni...How ABB shapes the future of industry with Microsoft HoloLens and Unity - Uni...
How ABB shapes the future of industry with Microsoft HoloLens and Unity - Uni...
 
Unity XR platform has a new architecture – Unite Copenhagen 2019
Unity XR platform has a new architecture – Unite Copenhagen 2019Unity XR platform has a new architecture – Unite Copenhagen 2019
Unity XR platform has a new architecture – Unite Copenhagen 2019
 
Turn Revit Models into real-time 3D experiences
Turn Revit Models into real-time 3D experiencesTurn Revit Models into real-time 3D experiences
Turn Revit Models into real-time 3D experiences
 
How Daimler uses mobile mixed realities for training and sales - Unite Copenh...
How Daimler uses mobile mixed realities for training and sales - Unite Copenh...How Daimler uses mobile mixed realities for training and sales - Unite Copenh...
How Daimler uses mobile mixed realities for training and sales - Unite Copenh...
 
How Volvo embraced real-time 3D and shook up the auto industry- Unite Copenha...
How Volvo embraced real-time 3D and shook up the auto industry- Unite Copenha...How Volvo embraced real-time 3D and shook up the auto industry- Unite Copenha...
How Volvo embraced real-time 3D and shook up the auto industry- Unite Copenha...
 
QA your code: The new Unity Test Framework – Unite Copenhagen 2019
QA your code: The new Unity Test Framework – Unite Copenhagen 2019QA your code: The new Unity Test Framework – Unite Copenhagen 2019
QA your code: The new Unity Test Framework – Unite Copenhagen 2019
 
Engineering.com webinar: Real-time 3D and digital twins: The power of a virtu...
Engineering.com webinar: Real-time 3D and digital twins: The power of a virtu...Engineering.com webinar: Real-time 3D and digital twins: The power of a virtu...
Engineering.com webinar: Real-time 3D and digital twins: The power of a virtu...
 
Supplying scalable VR training applications with Innoactive - Unite Copenhage...
Supplying scalable VR training applications with Innoactive - Unite Copenhage...Supplying scalable VR training applications with Innoactive - Unite Copenhage...
Supplying scalable VR training applications with Innoactive - Unite Copenhage...
 
XR and real-time 3D in automotive digital marketing strategies | Visionaries ...
XR and real-time 3D in automotive digital marketing strategies | Visionaries ...XR and real-time 3D in automotive digital marketing strategies | Visionaries ...
XR and real-time 3D in automotive digital marketing strategies | Visionaries ...
 
Real-time CG animation in Unity: unpacking the Sherman project - Unite Copenh...
Real-time CG animation in Unity: unpacking the Sherman project - Unite Copenh...Real-time CG animation in Unity: unpacking the Sherman project - Unite Copenh...
Real-time CG animation in Unity: unpacking the Sherman project - Unite Copenh...
 
Creating next-gen VR and MR experiences using Varjo VR-1 and XR-1 - Unite Cop...
Creating next-gen VR and MR experiences using Varjo VR-1 and XR-1 - Unite Cop...Creating next-gen VR and MR experiences using Varjo VR-1 and XR-1 - Unite Cop...
Creating next-gen VR and MR experiences using Varjo VR-1 and XR-1 - Unite Cop...
 
What's ahead for film and animation with Unity 2020 - Unite Copenhagen 2019
What's ahead for film and animation with Unity 2020 - Unite Copenhagen 2019What's ahead for film and animation with Unity 2020 - Unite Copenhagen 2019
What's ahead for film and animation with Unity 2020 - Unite Copenhagen 2019
 
How to Improve Visual Rendering Quality in VR - Unite Copenhagen 2019
How to Improve Visual Rendering Quality in VR - Unite Copenhagen 2019How to Improve Visual Rendering Quality in VR - Unite Copenhagen 2019
How to Improve Visual Rendering Quality in VR - Unite Copenhagen 2019
 

Recently uploaded

Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetEnjoy Anytime
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 

Recently uploaded (20)

Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 

Getting started with Ray Tracing in Unity 2019.3 - Unite Copenhagen 2019

  • 1.
  • 2. Getting Started with Ray Tracing in Unity 2019.3 Dany Ayoub - Technical Artist Kate McFadden - Senior Demo Artist Soner Sen - Desktop Graphics Lead
  • 3. Overview 3 — Technical details – DXR – Acceleration Structure – Ray tracing shaders – HDRP integration — Demo and Samples — We’re done!
  • 4. How Ray Tracing Works in Unity 2019.3 4
  • 5. DXR Overview 5 API designed to leverage hardware-accelerated ray tracing Why trace rays? — Off-screen rendering (reflection, refraction) — Algorithms that calls for raycasting Two major concepts to be concerned with: — Ray Tracing Acceleration Structures: What are we drawing? — Ray Tracing Shaders: How should we draw things?
  • 6. Acceleration Structure 6 — Bottom-Level AS: only geometry — BVH: construction done by driver — Top-Level AS: Materials, transforms, hierarchy
  • 7. Acceleration Structure 7 — New Unity class: RayTracingAccelerationStructure — Manually or automatically managed – Manual: AddInstance(), UpdateInstanceTransform() — Specify layer masks to filter GameObjects to be added — Call BuildRayTracingAccelerationStructure once a frame
  • 8. — New Renderer setting: RayTracingMode — In the order of least to most expensive – Off – Static – DynamicTransform – DynamicGeometry (WIP) Acceleration Structure 8
  • 9. Ray Tracing Shaders 9 — Raytrace shaders – Raygeneration: First shader executed during dispatch – Miss: Executes only if ray fails to intersect any object — Surface shaders – ClosestHit: Executes for the intersection nearest to ray origin – AnyHit: Executes for every intersection — Callable Shaders
  • 11. — New shader type: RayTracingShader – Extension is .raytrace — CommandBuffer API additions – CommandBuffer.SetRayTracingShaderPass – CommandBuffer.SetRayTracingAccelerationStructure – CommandBuffer.SetRayTracing*Param – e.g. SetRayTracingMatrixParam, SetRayTracingIntParam, etc. – CommandBuffer.DispatchRays – Analogous bindings also available from RayTracingShader class itself, for immediate execution Ray Tracing Shader API 11
  • 12. Ray Tracing Shader Authoring 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 // Dispatch shader: Defines at minimum a ray generation shader, often also a miss shader. // This is the shader that is dispatched, as one would a compute shader, // for a given ray traced pass. struct RayPayload { float4 color; uint2 launchIdx; }; // User-defined [shader(“raygeneration”)] void FullResRayGen() { uint2 launchIdx = DispatchRaysIndex().xy; // DXR callback uint2 launchDim = DispatchRaysDimensions().xy; // DXR callback float2 ndcCoords = (launchIdx / float2(launchDim.x - 1, launchDim.y - 1)) * 2 - float2(1, 1); float3 viewDirection = normalize(float3(ndcCoords.x * aspectRatio, ndcCoords.y, -1); RayDesc ray; // DXR defined ray.Origin = float3(camera_IV[0][3], camera_IV[1][3], camera_IV[2][3]); ray.Direction = normalize(mul(camera_IV, viewDirection)); ray.TMin = 0; ray.TMax = 1e20f; RayPayLoad payload; payload.color = float4(0, 0, 0, 0); TraceRay(accelerationStructure, 0, 0xFF, 0, 1, 0, ray, payload); // DXR callback } 12
  • 13. Ray Tracing Shader Authoring 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 [shader(“miss”)] void SampleSkybox(inout RayPayload payload : SV_RayPayload) { rayDirection = WorldRayDirection(); float4 skyboxColor = skyboxTex.SampleLevel(linearRepeatSampler, rayDirection, 0); payload.color = skyboxColor; } // These slides have a good introduction to built-in DXR callbacks: // http://intro-to-dxr.cwyman.org/presentations/IntroDXR_RaytracingShaders.pdf 13
  • 14. Surface Shader Authoring for Ray Tracing 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 // Material/Surface shader: Hit shaders should be defined as a pass in a shader used for a // material in the scene. Shader “FlatColor” { SubShader { Pass { CGPROGRAM #pragma vertex vert #pragma fragment frag v2f vert (appdata v) { return UnityObjectToClipPos(v.vertex); } fixed4 frag (v2f i) : SV_Target { return albedo; } ENDCG } } SubShader { Pass Name "DefaultRTPass" { HLSLPROGRAM // Pass name must match that specified by SetShaderPass() #pragma raytracing struct AttributeData { float2 barycentrics; }; // User-defined [shader(“closesthit”)] void FullResRayGen(inout RayPayload payload : SV_RayPayload, AttributeData attribs : SV_IntersectionAttributes) { // A trivial hit shader that populates a bound RT with albedo of hit object payload.color = albedo; outputRT[payload.launchIdx] = albedo; } ENDHLSL } } } 14
  • 15. — Windows 10 v1809+ — Unity 2019.3b1+ — DXR capable graphics card with latest drivers Requirements for Ray Tracing 15 Unity > Edit > Project Settings > Player: — Select DX12 as Windows Graphics API
  • 16. State of Ray Tracing in Unity 16 — Ray tracing API is pipeline-agnostic – Officially supported for only HDRP – HDRP is the only pipeline that actually implements features using ray tracing – Users can still use the public C# API to build their own features! — Unsupported in 19.3: – Intersection shaders – Animated meshes – Procedural geometry
  • 17. HDRP Ray Tracing Architecture 17 — Primary rays for most effects are computed from depth/normal buffers — Cluster-based lighting added to HDRP for ray tracing — Render graph here is simplified and omits many HDRP stages
  • 20. Want to learn more? Project: Unity Lighting Fundamentals Tutorial: Post-Processing Effects (2018.x+) Tutorial: HDRP Material Properties Subscribe now for a 3-month free trial at unity.com/learn- premium with code: UNITECPH19 *Learn Premium is included in Unity Plus and Pro licenses. Just sign in with your Unity ID.

Editor's Notes

  1. Hello Everyone. My name is Soner, I’m a lead developer at Unity. Today me, Kate and Dany will be going over the details of ray tracing in Unity 2019.3 we are aiming to provide you enough background to start your own ray tracing projects
  2. Our talk will start with me trying to explain the technical details of ray tracing in Unity. I will go over DXR, acceleration structure and ray tracing shaders API. I will continue with the integration into High Definition Render Pipeline. then Kate and Dany will take over to give you some examples and demo of how to get started with ray tracing in Unity.
  3. Lets start with explaining how ray tracing works in Unity 2019.3. Disclaimer: ray tracing is still in preview mode as of today, September 26th. The core should not change, but there may be slight changes in the future.
  4. I’ll start with an introduction to DXR and its integration with Unity. As many of you may already know, DXR is a DX12 feature designed to leverage the hardware acceleration some graphics cards provide for ray tracing. For real time rendering, we generally do this as a complement to rasterization rather than a replacement. For example when rendering reflections or refractions that capture objects obscured from camera view, like in the screenshots to the right Or as a direct upgrade for compute shaders in algorithms that call for raycasting, (like participating media/translucents, caustics, ambient occlusion or dynamic diffuse global illumination) To start with, I wanna go over two main concepts: (verbatim) (verbatim)
  5. The acceleration structure captures the scene we want to render in 3D space. This is the data structure against which we cast our rays, it is illustrated on the right here for the cornell box shown on the left. We begin by defining one bottom-level acceleration structure for each unique mesh, in this case a sphere, a prism, and a plane. Then in the next level up of this diagram, instances are constructed by pointing to an associated BLAS, including relevant transform and material information Instances are then grouped together in a Bounding Volume Hierarchy by the driver, finally producing the top-level acceleration structure
  6. This is exposed in Unity 2019.3 through the RayTracingAccelerationStructure class. It can be managed automaticaly or manually If managed automatically, all eligible GameObjects are added to the AS as they are added to the scene If managed manually, the user must explicitly add GameObjects to the AS using AddInstance and update transforms using UpdateInstanceTransform you can specify layer masks on creation to filter which GameObjects may be added to your acceleration structure you need to call BuildRayTracingAccelerationStructure once a frame This command checks for updates to transforms in automatically managed structures, then either rebuilds or updates the AS on the GPU as needed.
  7. Aside from layer masks, GameObjects are also filtered based on RayTracingMode, a new setting that’s been added to the Renderer RayTracingMode lets the acceleration structure know how frequently an instance will be updated, and in what way If raytracingmode is off, it’s trivially cheap since it won’t be ray traced. If raytracing mode is static, the accelerationstructure expects that it will never be updated in any way. For dynamictransform, the accelerationstructure will allow for updates of the renderer’s transform only While for DynamicGeometry, both the renderer’s transform and vertex and index buffers may be updated. Currently only Static and DynamicTransform are supported for ray tracing DynamicGeometry is next on our list!
  8. Next I want to go over ray tracing shaders, and I find it helpful to group them into two categories based on their use in Unity: raytrace shaders and surface shaders. Raytrace shaders are generally defined in a .raytrace file on which you then call Dispatch, much like compute shaders (verbatim) (verbatim) Surface shaders, on the other hand, are defined in the shaders used in materials applied to objects in the scene (verbatim)x3 Note that a material with a closesthit shader may also have an anyhit shader for the same pass, since these hit shaders are executed at different points in the control flow. Callable shaders also exist in DXR and are supported in Unity 2019.3, however I won’t go into detail on them here, but they’re basically function calls
  9. So to illustrate these shaders in action, We start with the RayGen shader, which casts all these rays into the acceleration structure In this case the rays are casted originated from the camera, but you can cast them however you want One of those rays doesn’t hit anything in the scene, and so executes the miss shader Next we have a ray that intersects two objects, both with a ClosestHit shader. In this case, even if the hit on the cylinder gets registered first, only the sphere executes its ClosestHit shader, since ClosestHit shaders don’t execute until acceleration structure traversal is complete and the actual closest hit has been found. In contrast, we have this ray that intersects both a ClosestHit and an AnyHit shader. Now if the prism gets intersection tested first, it will execute its AnyHit shader before acceleration structure traversal is complete. This means that when we later find the ClosestHit shader on the occluding cylinder, we end up discarding the results of the AnyHit shader. So AnyHit shaders can be more expensive than ClosestHit shaders, but the reason you’d like to use them is for situations like these two transparent objects down here, where you would want to add surface information to the ray payload from every object hit for some simple alpha blend transparency. // AnyHit shaders can be used at lower cost by calling AcceptHitAndEndSearch, for example when testing for visibility (shadows, AO). Technically an intersection shader is executed for every geometry; the built-in intersection shader is for triangle intersection.
  10. Here’s how that fits into Unity. If you save your raygeneration and miss shaders in a .raytrace file, it will get imported as the new RayTracingShader class we have in 2019.3. Then, the order of operations for dispatching a ray tracing shader goes as follows: Specify the pass name you’re using for this dispatch. This needs to match the pass name used for your hit shaders in your surface shaders! Bind the acceleration structure you’re tracing against, and any other properties like matrices, textures, etc. Finally, call DispatchRays for a given dispatch width, height, and depth. (verbatim)
  11. So here’s a basic example of a ray generation shader. In red we have DXR-specific features, and in blue we have properties that are declared and bound elsewhere. Firstly you have to declare what kind of ray tracing shader you’re authoring You need to populate a description of the ray you are casting, and then you call TraceRay() to cast that ray into the acceleration structure. This ray generation shader assumes the dispatch dimensions match the screen size, from that calculates the direction for the ray originated from the camera and through each pixel in the screen //The rays cast in this ray generation shader are a little off (for brevity); you’d want to fudge the ray direction to shoot through the center of the pixel rather than the edge
  12. In the same .raytrace shader, you usually also see a miss shader. Notice that the shader type is declared as “miss”. The SV_RayPayload semantic is available to all shaders that are executed as a result of a TraceRay() call. RayPayload is entirely user-defined, the larger the payloads the more expensive it is. Try to keep payload as small as possible This miss shader simply samples a sky cubemap based on the direction of the ray. More detailed information on DXR callbacks and shader authoring may be found at the link to slides from Chris Wyman’s intro to DXR talk.
  13. As for surface shaders, here’s an example of a Unity shader that has both a pass for rasterization and a pass for ray tracing. You’ll notice that the ray tracing shader must be written in HLSL, must include an additional ray tracing pragma, and must include a pass name, which must be the pass name set to the raytrace shader prior to dispatch. The SV_IntersectionAttributes semantic is available to hit shaders. AttributeData is also user defined, but usually it includes barycentrics, which define the position in a given triangle the ray intersects (in terms of distance from each vertex) This closest hit shader does the same thing as the raterization shader- simply returning the albedo set to the material.
  14. Now that you have some background, here’s what you need to get started with Unity Ray tracing. (win10 verbatim) (unity verbatim) (So our implementation technically isn’t vendor-specific because DXR isn’t technically vendor-specific, but) you will need a graphics card that supports DXR for now, As DXR is a DX12 fature dont forget to set your graphics api in the Player settings window to DX12
  15. Ok, everything’s set up, and you’re ready to trace rays! The Ray tracing API works on any graphics pipeline, but... We only officially support it for HDRP, which takes care of everything for you to provide state of the art ray-traced effects in a handy UI inspector If you’re feeling adventurous, you’re still welcome to author your own ray tracing features using the API described before. I also want to call out a few features that aren’t yet supported for ray tracing in Unity: (verbatim)
  16. Here is how it fits into the High Definition Rendering Pipeline Shown in green here we have the ray traced effects supported by HDRP, and roughly where they fit into the HDRP render graph. Note that this graph is condensed and many unrelated features are omitted For these six ray tracing passes, we skip the primary eye raycast, instead we cast rays using the depth and normal GBuffers An exception to this is transparents transparents are handled after opaques have already been fully rendered, but before postprocessing Acceleration structures are built and updated in immediate mode, asynchronously with the render graph shown here which is serialized on a rendering command buffer.
  17. Now take a look at the these effects more closely. Kate and Dany the stage is yours.
  18. If you want to continue learning, check out our learning platform at learn.unity.com. You’ll find free learning resources, and you can sign up for a 30-day trial of Learn Premium to access live sessions with Unity experts, and the best learning resources updated for the latest Unity release.