weirdes farb artefakte auf den kugeln wenn ein licht zu nah dran ist

This commit is contained in:
any
2026-07-30 18:12:19 +02:00
parent 82ab538095
commit 2ebc5f03bb
7 changed files with 31 additions and 4 deletions
+6 -1
View File
@@ -4,6 +4,8 @@
#include "vectorOp.h"
#define MAXSPHERES 100
#include "helper.h"
#include <math.h>
#define epsilon 1e-8
RGBA raytraceSphere(sphere **objectList, ray *lightray) {
RGBA pixel = (RGBA){0,0,0,0};
@@ -12,7 +14,7 @@ RGBA raytraceSphere(sphere **objectList, ray *lightray) {
//vec3 *spheresNormalList = (vec3 *)calloc( lightBounces + 1,sizeof(vec3) );
int hitLightIndex = -1;
vec3 sphereNormal;
int raysPerPixel = 2000;
int raysPerPixel = 20;
ray originalRay = *lightray;
for (int k = 0; k < raysPerPixel; k++) {
@@ -46,6 +48,9 @@ RGBA raytraceSphere(sphere **objectList, ray *lightray) {
spheresNormalList[j] = sphereNormal;
//diffus:
lightray->direction = vec3Add(sphereNormal, randUnitVector());
if (fabs(lightray->direction.x ) <= epsilon || fabs(lightray->direction.y ) <= epsilon || fabs(lightray->direction.z) <= epsilon) {
lightray->direction = sphereNormal;
}
//reflektion:
//lightray->direction = vec3Add(lightray->direction, vec3Scale(sphereNormal, 2));
lightray->origin = nearestCollisionPoint;