diff --git a/3GoodResult.png b/3GoodResult.png new file mode 100644 index 0000000..e7ca0b0 Binary files /dev/null and b/3GoodResult.png differ diff --git a/examples.c b/examples.c index f591db2..f86cb1f 100644 --- a/examples.c +++ b/examples.c @@ -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); diff --git a/main.c b/main.c index 506348f..8ac2405 100644 --- a/main.c +++ b/main.c @@ -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 ); diff --git a/raytrace.c b/raytrace.c index 4cd9ed3..c3eea55 100644 --- a/raytrace.c +++ b/raytrace.c @@ -7,8 +7,9 @@ #include "helper.h" #include #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; } diff --git a/test.png b/test.png new file mode 100644 index 0000000..cd7912b Binary files /dev/null and b/test.png differ