public void CS() { UInt3 dtid = ShaderBuiltins.DispatchThreadID; Vector4 color = Vector4.Zero; uint randState = (dtid.X * 1973 + dtid.Y * 9277 + Params.FrameCount * 26699) | 1; uint rayCount = 0; for (uint smp = 0; smp < RayTracingApplication.NumSamples; smp++) { float u = (dtid.X + RandUtil.RandomFloat(ref randState)) / RayTracingApplication.Width; float v = (dtid.Y + RandUtil.RandomFloat(ref randState)) / RayTracingApplication.Height; Ray ray = Camera.GetRay(Params.Camera, u, v, ref randState); color += Color(Params.SphereCount, ref randState, ray, ref rayCount); } color /= RayTracingApplication.NumSamples; ShaderBuiltins.Store(Output, new UInt2(dtid.X, dtid.Y), color); ShaderBuiltins.InterlockedAdd(RayCount, 0, rayCount); }