| 12345678910111213141516171819202122232425262728293031 |
- #include "Common.hlsl"
- [shader("closesthit")]
- void ChunkClosestHit(inout HitInfo currentPayload, ChunkHitAttributes attrib)
- {
- if (currentPayload.hitCount == 0)
- {
- return; // already inside of shadow ray
- }
- HitInfo tmpPayload;
- // shadow rays
- for (int i = 0; i < currentPayload.hitCount; i++)
- {
- tmpPayload.hitCount = -1; // shadow ray
- RayDesc ray;
- ray.Origin = WorldRayOrigin() + (currentPayload.distance[i] - 0.001) * WorldRayDirection();
- ray.Direction = dayLightDirection;
- ray.TMin = 0.00001;
- ray.TMax = 1000;
- TraceRay(TLAS,
- 0, 0xFF, 0,
- 0, 0, ray, tmpPayload);
- float3 color = unpackLight(currentPayload.dayLight[i]) * dayLightFactor;
- if (tmpPayload.hitCount == 0)
- {
- color = color / 2;
- }
- currentPayload.dayLight[i] = packLight(color);
- }
- // TODO: reflection rays
- }
|