// Trace a ray into the scene; get back data in the payload.
// Trace a ray into the scene; get back data in the payload.
traceRayEXT(tlas, // Acceleration structure
traceRayEXT(tlas, // Acceleration structure
gl_RayFlagsOpaqueEXT, // Ray flags, here saying "ignore intersection shaders"
gl_RayFlagsOpaqueEXT, // Ray flags, here saying "ignore intersection shaders"
0xFF, // 8-bit instance mask, here saying "trace against all instances"
0xFF, // 8-bit instance mask, here saying "trace against all instances"
0, // SBT record offset
0, // SBT record offset
0, // SBT record stride for offset
0, // SBT record stride for offset
0, // Miss index
0, // Miss index
orig, // Ray origin
orig, // Ray origin
0.0, // Minimum t-value
0.0, // Minimum t-value
dir, // Ray direction
dir, // Ray direction
1000.0, // Maximum t-value
1000.0, // Maximum t-value
0); // Location of payload
0); // Location of payload
// Read the values from the payload:
// Read the values from the payload:
hitSky = (payload.hitSky > 0.0);
hitSky = (payload.hitSky > 0.0);
pos = payload.worldPosition;
pos = payload.worldPosition;
norm = payload.worldNormal;
norm = payload.worldNormal;
}
}
/**
/**
...
@@ -67,7 +82,7 @@ void GetPixelInfo(out bool hitSky, out vec3 pos, out vec3 norm){
...
@@ -67,7 +82,7 @@ void GetPixelInfo(out bool hitSky, out vec3 pos, out vec3 norm){
* @param[in] orig The point of origin of the shadow ray.
* @param[in] orig The point of origin of the shadow ray.
* @param[in] dir The direction of the shadow ray.
* @param[in] dir The direction of the shadow ray.
*/
*/
float ShadowRay(vec3 orig, vec3 dir){
float CastShadowRay(vec3 orig, vec3 dir){
payload.hitSky = 0.0f; // Assume ray is occluded
payload.hitSky = 0.0f; // Assume ray is occluded
traceRayEXT(tlas, // Acceleration structure
traceRayEXT(tlas, // Acceleration structure
gl_RayFlagsOpaqueEXT | gl_RayFlagsSkipClosestHitShaderEXT | gl_RayFlagsTerminateOnFirstHitEXT, // Ray flags, here saying "ignore any hit shaders and closest hit shaders, and terminate the ray on the first found intersection"
gl_RayFlagsOpaqueEXT | gl_RayFlagsSkipClosestHitShaderEXT | gl_RayFlagsTerminateOnFirstHitEXT, // Ray flags, here saying "ignore any hit shaders and closest hit shaders, and terminate the ray on the first found intersection"