raytracer fr eine sphere ist fertig, aber das gerenderte bild sieht komisch aus, als wrden zeilen verschoben werden und keine kugel ist zu erkennen. ausserdem gibt es jetzt vektor operationen wie das skalarprodukt.

This commit is contained in:
any
2026-07-26 17:54:45 +02:00
parent 361eaefdb5
commit 72d683c1f2
11 changed files with 150 additions and 14 deletions
+17
View File
@@ -0,0 +1,17 @@
#include "structs.h"
#include "collision.h"
#include "vectorOp.h"
RGBA raytraceSphere(sphere *obj, ray *lightray) {
RGBA pixel;
pixel.r = 0;
pixel.g = 0;
pixel.b = 0;
pixel.a = 1;
vec3 collisionPoint = collisionPointSphere(lightray, obj);
vec3 sphereNormal = vec3Normalize(vec3Subtract(collisionPoint, obj->origin));
pixel.r = -vec3Product(sphereNormal, lightray->direction);
return pixel;
}