Skip to content

INedelcu/RayTracingDynamicMeshGeometry

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RayTracingDynamicMeshGeometry

Unity sample project using dynamic Mesh geometries in a RayTracingAccelerationStructure (RTAS).

Description

The project uses RayTracingAccelerationStructure.AddInstance function to add ray tracing instances that use dynamic geometries to the RTAS. The function signature used is:

int AddInstance(ref Rendering.RayTracingMeshInstanceConfig config, Matrix4x4 matrix, Nullable<Matrix4x4> prevMatrix, uint id);

There are 2 dynamic Meshes in the Scene - the left Mesh is animated on the CPU in C# while the right one on the GPU in a compute shader. Check MeshInstanceDynamicGeometry.cs. After animation, CommandBuffer.BuildRayTracingAccelerationStructure is called where the acceleration structures (BLAS) associated with the 2 geometries are built on the GPU.

The ray generation shader in MeshInstanceDynamicGeometry.raytrace casts the rays into the view frustum by calling TraceRay and generates the resulting image into a RenderTexture which is displayed in the Game View output.

The hit shader used by the 2 geometries is MeshInstanceDynamicGeometry.shader, second SubShader.

After opening the project, switch to Game view and press Play to animate the geometries.

Prerequisites

Resources

About

Unity sample project using dynamic Mesh geometries in a RTAS

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published