ChunkClosestHit.hlsl 1004 B

12345678910111213141516171819202122232425262728293031
  1. #include "Common.hlsl"
  2. [shader("closesthit")]
  3. void ChunkClosestHit(inout HitInfo currentPayload, ChunkHitAttributes attrib)
  4. {
  5. if (currentPayload.hitCount == 0)
  6. {
  7. return; // already inside of shadow ray
  8. }
  9. HitInfo tmpPayload;
  10. // shadow rays
  11. for (int i = 0; i < currentPayload.hitCount; i++)
  12. {
  13. tmpPayload.color[0].rgb = unpackLight(currentPayload.dayLight[i]) * dayLightFactor;
  14. /*tmpPayload.hitCount = -1; // shadow ray
  15. RayDesc ray;
  16. ray.Origin = WorldRayOrigin() + (currentPayload.distance[i] - 0.0001) * WorldRayDirection();
  17. ray.Direction = -dayLightDirection;
  18. ray.TMin = 0.1;
  19. ray.TMax = 1000;
  20. TraceRay(TLAS,
  21. 0, 0xFF, 0,
  22. 0, 0, ray, tmpPayload);
  23. if (tmpPayload.hitCount == 0)
  24. {
  25. tmpPayload.color[0].rgb = tmpPayload.color[0].rgb / 2;
  26. }*/
  27. currentPayload.dayLight[i] = packLight(tmpPayload.color[0].rgb);
  28. }
  29. // TODO: reflection rays
  30. }