versuch quad szene zu machen zeigt dass meine kollisions erkennung nicht klappt. ich habe versucht eine neue fuer quadrate zu inplementieren, aber ich sehe nur einen weissen streifen

This commit is contained in:
any
2026-08-26 02:13:28 +02:00
parent 9478c655a9
commit 5111a7693c
9 changed files with 118 additions and 14 deletions
+7 -6
View File
@@ -7,6 +7,7 @@
#include "helper.h"
#include <math.h>
#define epsilon 1e-8
#define RAYSPERPIXEL 3
#define lightBounces 3
enum objectType {
SPHERETYPE,
@@ -25,6 +26,7 @@ RGBA getRayColor(RGBA colorList[], bool isLightList[]) {
if (firstLightHitIndex == -1) {
rayColor = (RGBA){0,0,0,1};
return rayColor;
}
else
{
@@ -41,9 +43,9 @@ RGBA getRayColor(RGBA colorList[], bool isLightList[]) {
//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};
return rayColor;
}
}
RGBA raytrace(object objectList[], int objectCount, ray *lightray) {
@@ -119,10 +121,9 @@ RGBA raytrace(object objectList[], int objectCount, ray *lightray) {
RGBA getPixelColor(object objectList[], int objectCount, ray *lightray) {
RGBA pixel = (RGBA){0,0,0,0};
int raysPerPixel = 2;
ray originalRay = *lightray;
for (int k = 0; k < raysPerPixel; k++) {
for (int k = 0; k < RAYSPERPIXEL; k++) {
*lightray = originalRay;
RGBA tempPixel = raytrace(objectList, objectCount, lightray);
@@ -134,9 +135,9 @@ RGBA getPixelColor(object objectList[], int objectCount, ray *lightray) {
}
//average pixelData
pixel.r = pixel.r / raysPerPixel;
pixel.g = pixel.g / raysPerPixel;
pixel.b = pixel.b / raysPerPixel;
pixel.r = pixel.r / RAYSPERPIXEL;
pixel.g = pixel.g / RAYSPERPIXEL;
pixel.b = pixel.b / RAYSPERPIXEL;
//pixel.a = pixel.a / raysPerPixel;