Brak opisu
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TraceRays.hlsl 1004B

12345678910111213141516171819202122232425262728293031323334
  1. #include "Packages/com.unity.rendering.light-transport/Runtime/UnifiedRayTracing/TraceRay.hlsl"
  2. UNIFIED_RT_DECLARE_ACCEL_STRUCT(_AccelStruct);
  3. struct RayWithFlags
  4. {
  5. float3 origin;
  6. float tMin;
  7. float3 direction;
  8. float tMax;
  9. uint culling;
  10. uint instanceMask;
  11. uint padding;
  12. uint padding2;
  13. };
  14. StructuredBuffer<RayWithFlags> _Rays;
  15. RWStructuredBuffer<UnifiedRT::Hit> _Hits;
  16. void RayGenExecute(UnifiedRT::DispatchInfo dispatchInfo)
  17. {
  18. RayWithFlags rayWithFlags = _Rays[dispatchInfo.globalThreadIndex];
  19. UnifiedRT::Ray ray;
  20. ray.origin = rayWithFlags.origin;
  21. ray.direction = rayWithFlags.direction;
  22. ray.tMin = rayWithFlags.tMin;
  23. ray.tMax = rayWithFlags.tMax;
  24. UnifiedRT::RayTracingAccelStruct accelStruct = UNIFIED_RT_GET_ACCEL_STRUCT(_AccelStruct);
  25. UnifiedRT::Hit hitResult = UnifiedRT::TraceRayClosestHit(dispatchInfo, accelStruct, rayWithFlags.instanceMask, ray, rayWithFlags.culling);
  26. _Hits[dispatchInfo.globalThreadIndex] = hitResult;
  27. }