Skip to content

Commit

Permalink
Update BVH_Spot_Light_Source_Fragment.glsl
Browse files Browse the repository at this point in the history
  • Loading branch information
erichlof authored Nov 13, 2023
1 parent 95a776d commit a35fa31
Showing 1 changed file with 57 additions and 26 deletions.
83 changes: 57 additions & 26 deletions shaders/BVH_Spot_Light_Source_Fragment.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -114,35 +114,66 @@ float SceneIntersect( out int isRayExiting )
int triangleLookupNeeded = FALSE;


for (int i = 0; i < N_SPHERES; i++)
{
d = SphereIntersect( spheres[i].radius, spheres[i].position, rayOrigin, rayDirection );
if (d < t)
{
t = d;
hitNormal = (rayOrigin + rayDirection * t) - spheres[i].position;
hitEmission = spheres[i].emission;
hitColor = spheres[i].color;
hitType = spheres[i].type;
hitObjectID = float(objectCount);
}
objectCount++;
d = SphereIntersect( spheres[0].radius, spheres[0].position, rayOrigin, rayDirection );
if (d < t)
{
t = d;
hitNormal = (rayOrigin + rayDirection * t) - spheres[0].position;
hitEmission = spheres[0].emission;
hitColor = spheres[0].color;
hitType = spheres[0].type;
hitObjectID = float(objectCount);
}
objectCount++;

d = SphereIntersect( spheres[1].radius, spheres[1].position, rayOrigin, rayDirection );
if (d < t)
{
t = d;
hitNormal = (rayOrigin + rayDirection * t) - spheres[1].position;
hitEmission = spheres[1].emission;
hitColor = spheres[1].color;
hitType = spheres[1].type;
hitObjectID = float(objectCount);
}
objectCount++;

d = SphereIntersect( spheres[2].radius, spheres[2].position, rayOrigin, rayDirection );
if (d < t)
{
t = d;
hitNormal = (rayOrigin + rayDirection * t) - spheres[2].position;
hitEmission = spheres[2].emission;
hitColor = spheres[2].color;
hitType = spheres[2].type;
hitObjectID = float(objectCount);
}
objectCount++;

for (int i = 0; i < N_BOXES; i++)
{
d = BoxIntersect( boxes[i].minCorner, boxes[i].maxCorner, rayOrigin, rayDirection, normal, isRayExiting );
if (d < t)
{
t = d;
hitNormal = normal;
hitEmission = boxes[i].emission;
hitColor = boxes[i].color;
hitType = boxes[i].type;
hitObjectID = float(objectCount);
}
objectCount++;

d = BoxIntersect( boxes[0].minCorner, boxes[0].maxCorner, rayOrigin, rayDirection, normal, isRayExiting );
if (d < t)
{
t = d;
hitNormal = normal;
hitEmission = boxes[0].emission;
hitColor = boxes[0].color;
hitType = boxes[0].type;
hitObjectID = float(objectCount);
}
objectCount++;

d = BoxIntersect( boxes[1].minCorner, boxes[1].maxCorner, rayOrigin, rayDirection, normal, isRayExiting );
if (d < t)
{
t = d;
hitNormal = normal;
hitEmission = boxes[1].emission;
hitColor = boxes[1].color;
hitType = boxes[1].type;
hitObjectID = float(objectCount);
}
objectCount++;

d = DiskIntersect( diskRadius, diskPos, diskNormal, rayOrigin, rayDirection );
if (d < t)
Expand Down

0 comments on commit a35fa31

Please sign in to comment.