Cornellbox demo mit gigantischem licht

This commit is contained in:
any
2026-08-26 17:26:14 +02:00
parent 0712e988df
commit 428da5a4bb
5 changed files with 17 additions and 7 deletions
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 MiB

+11 -3
View File
@@ -75,10 +75,10 @@ void exampleCornell( int width, int height, int channels, unsigned char **image)
cam1.screenDistance = 0.6;
cam1.width = 1.080;
cam1.height = 1.080;
int objectCount = 13;
int objectCount = 19;
object objectList[objectCount];
cube makroObj1 = createCuboid((vec3){-1,-2,3}, (vec3){1.5,0,0}, (vec3){0,1.5,0}, (vec3){0,0,1.5},(RGBA){1,1,0.5,1});
cube makroObj1 = createCuboid((vec3){1,-2,2.2}, (vec3){0.75,0,0.75}, (vec3){0,1.2,0}, (vec3){-0.75,0,0.75},(RGBA){1,1,0.5,1});
objectList[0] = (object){1, &(makroObj1.quad1), 0};
objectList[1] = (object){1, &(makroObj1.quad2), 0};
objectList[2] = (object){1, &(makroObj1.quad3), 0};
@@ -86,7 +86,7 @@ void exampleCornell( int width, int height, int channels, unsigned char **image)
objectList[4] = (object){1, &(makroObj1.quad5), 0};
objectList[5] = (object){1, &(makroObj1.quad6), 0};
quad light1 = (quad){(vec3){-0.5,1.9,2.5}, (vec3){0,0,1}, (vec3){1,0,0}, (vec3){0,-1,0}, (RGBA){1,1,1,1}};
quad light1 = (quad){(vec3){-2,1.9,0.5}, (vec3){0,0,4}, (vec3){4,0,0}, (vec3){0,-1,0}, (RGBA){1,1,1,1}};
objectList[6] = (object){1, &(light1), 1};
cube makroObj2 = createCuboid((vec3){-2,-2,-0.1}, (vec3){4,0,0}, (vec3){0,4,0}, (vec3){0,0,4},(RGBA){1,1,1,1});
@@ -104,6 +104,14 @@ void exampleCornell( int width, int height, int channels, unsigned char **image)
objectList[11] = (object){1, &(makroObj2.quad5), 0};
objectList[12] = (object){1, &(makroObj2.quad6), 0};
cube makroObj3 = createCuboid((vec3){-1,-2,2.5}, (vec3){0.75,0,0.45}, (vec3){0,2,0}, (vec3){-0.45,0,0.75},(RGBA){1,0.5,1,1});
objectList[13] = (object){1, &(makroObj3.quad1), 0};
objectList[14] = (object){1, &(makroObj3.quad2), 0};
objectList[15] = (object){1, &(makroObj3.quad3), 0};
objectList[16] = (object){1, &(makroObj3.quad4), 0};
objectList[17] = (object){1, &(makroObj3.quad5), 0};
objectList[18] = (object){1, &(makroObj3.quad6), 0};
displaySzene(objectList, objectCount, cam1, width, height, channels, image);
+2 -2
View File
@@ -13,8 +13,8 @@
#include "collision.h"
#include "raytrace.h"
int main() {
int width = 1080;
int height = 1080;
int width = 720;
int height = 720;
int channels = 4;
unsigned char *image = (unsigned char*)malloc(width * height * channels );
+4 -2
View File
@@ -7,8 +7,9 @@
#include "helper.h"
#include <math.h>
#define epsilon 1e-8
#define RAYSPERPIXEL 100
#define lightBounces 6
#define RAYSPERPIXEL 40
#define lightBounces 5
#define GLOBALILLUMINATION 0.1
enum objectType {
SPHERETYPE,
QUADTYPE
@@ -25,6 +26,7 @@ RGBA getRayColor(RGBA colorList[], bool isLightList[]) {
}
if (firstLightHitIndex == -1) {
//rayColor = (RGBA){GLOBALILLUMINATION * colorList[0].r,GLOBALILLUMINATION * colorList[0].g,GLOBALILLUMINATION * colorList[0].b,1};
rayColor = (RGBA){0,0,0,1};
return rayColor;
}
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB