diffuses raytracing implementiert

This commit is contained in:
any
2026-07-30 00:23:47 +02:00
parent caced0f81e
commit f4a36fc98d
6 changed files with 95 additions and 46 deletions
+24
View File
@@ -0,0 +1,24 @@
//
// Created by ary on 29.07.2026.
//
#include "helper.h"
#include <stdlib.h>
#include <math.h>
#include "structs.h"
vec3 randUnitVector() {
double x1,x2,lengthSquared;
do {
x1 = (rand() / (double) RAND_MAX) * 2 - 1; //random zahl zwischen -1 und 1
x2 = (rand() / (double) RAND_MAX) * 2 - 1;
lengthSquared = x1 * x1 + x2 * x2;
}while (lengthSquared >= 1);
double weirdFactor = 2.0 * sqrt(1.0 - lengthSquared);
return (vec3){
x1 * weirdFactor,
x2 * weirdFactor,
1.0 - 2.0 * lengthSquared};
}