weirdes farb artefakte auf den kugeln wenn ein licht zu nah dran ist
This commit is contained in:
+6
-1
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user