Checks to see if a ray intersects with the area light
| 175 | |
| 176 | // Checks to see if a ray intersects with the area light |
| 177 | static float AreaLightIntersection(const Float3& rayStart, const Float3& rayDir, float tStart, float tEnd) |
| 178 | { |
| 179 | |
| 180 | DirectX::BoundingSphere areaLightSphere; |
| 181 | areaLightSphere.Center = XMFLOAT3(AppSettings::AreaLightX, AppSettings::AreaLightY, AppSettings::AreaLightZ); |
| 182 | areaLightSphere.Radius = AppSettings::AreaLightSize; |
| 183 | |
| 184 | float intersectDist = FLT_MAX; |
| 185 | bool intersects = areaLightSphere.Intersects(rayStart.ToSIMD(), rayDir.ToSIMD(), intersectDist); |
| 186 | intersects = intersects && (intersectDist >= tStart && intersectDist <= tEnd); |
| 187 | return intersects ? intersectDist : FLT_MAX; |
| 188 | } |
| 189 | |
| 190 | // Computes the difuse and specular contribution from the sun, given a 2D random sample point |
| 191 | // representing a location on the surface of the light |