Files
Seele/res/shaders/raytracing/RayGen.slang
T

32 lines
874 B
Plaintext
Raw Normal View History

2024-07-08 13:46:49 +02:00
import Common;
import RayTracingData;
[shader("raygeneration")]
2024-07-12 13:33:52 +02:00
void raygen()
2024-07-08 13:46:49 +02:00
{
const float2 pixelCenter = float2(DispatchRaysIndex().xy) + float2(0.5);
const float2 inUV = pixelCenter / float2(DispatchRaysDimensions().xy);
float2 d = inUV * 2.0 - 1.0;
float4 origin = mul(pViewParams.inverseViewMatrix, float4(0, 0, 0, 1));
2024-07-12 13:33:52 +02:00
float4 target = mul(pViewParams.inverseProjection, float4(d.x, d.y, 1, 1));
float4 direction = mul(pViewParams.inverseViewMatrix, float4(target.xyz, 0));
2024-07-08 13:46:49 +02:00
float tmin = 0.0001;
float tmax = 10000.0;
uint max_rays = 24;
2024-07-12 13:33:52 +02:00
RayPayload payload;
2024-07-08 13:46:49 +02:00
2024-07-12 13:33:52 +02:00
RayDesc desc;
desc.Origin = origin.xyz;
desc.Direction = direction.xyz;
desc.TMin = tmin;
desc.TMax = tmax;
2024-07-08 13:46:49 +02:00
2024-07-13 16:22:56 +02:00
TraceRay(pRayTracingParams.scene, 0, 0xff, 0, 0, 0, desc, payload);
2024-07-12 13:33:52 +02:00
pRayTracingParams.image[DispatchRaysIndex().xy] = float4(payload.color, 1.0f);
2024-07-08 13:46:49 +02:00
}