only reflections

This commit is contained in:
any
2026-07-26 20:56:07 +02:00
parent 1c4dce53c1
commit fb44398c24
3 changed files with 5 additions and 4 deletions
+2
View File
@@ -17,12 +17,14 @@ vec3 collisionPointSphere(ray *lightray, sphere *object)
if (discriminant < 0) return collisionPoint;
if (discriminant > 0) {
double S = (-b - sqrt(discriminant)) / (2 * a);
if (S < 0) return collisionPoint;
collisionPoint.x = S * lightray->direction.x + lightray->origin.x;
collisionPoint.y = S * lightray->direction.y + lightray->origin.y;
collisionPoint.z = S * lightray->direction.z + lightray->origin.z;
return collisionPoint;
}
double S = (-b)/(2*a);
if (S < 0) return collisionPoint;
collisionPoint.x = S * lightray->direction.x + lightray->origin.x;
collisionPoint.y = S * lightray->direction.y + lightray->origin.y;
collisionPoint.z = S * lightray->direction.z + lightray->origin.z;
+3 -4
View File
@@ -37,15 +37,14 @@ RGBA raytraceSphere(sphere **objectList, ray *lightray) {
lightray->origin = nearestCollisionPoint;
}
else {
sphereNormal = (vec3){0,0,0};
sphereNormal = (vec3){1,1,1};
}
}
if (nearestSphere != nullptr)
{
//pixel.r = -vec3Product(sphereNormal, lightray->direction);
pixel = (RGBA){1 - 0.5 *( sphereNormal.x + 1), 1 - 0.5 * (sphereNormal.y +1), 1 -0.5* (sphereNormal.z + 1),1};
}
free(spheresHitList);
return pixel;
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 520 KiB

After

Width:  |  Height:  |  Size: 116 KiB