very fizzely and green junk but overall believable defusion

This commit is contained in:
any
2026-07-30 00:54:59 +02:00
parent 43dc073622
commit e0096dce11
3 changed files with 8 additions and 6 deletions
+1 -1
View File
@@ -47,7 +47,7 @@ void exampleSphere( int width, int height, int channels, unsigned char **image)
objectList[2] = &obj3;
sphere obj4 = (sphere){vec3Add(sphereOrigin, (vec3){1,1,3}), sphereRadius, (RGBA){0.5,1,1,1},0};
objectList[3] = &obj4;
sphere light1 = (sphere){(vec3){2,1,0}, sphereRadius, (RGBA){1,1,1,1},1};
sphere light1 = (sphere){(vec3){1,2,4.5}, sphereRadius, (RGBA){1,1,1,1},1};
objectList[4] = &light1;
int objectCount = 5;
+7 -5
View File
@@ -7,15 +7,17 @@
RGBA raytraceSphere(sphere **objectList, ray *lightray) {
RGBA pixel = (RGBA){0,0,0,0};
const int lightBounces = 2;
sphere **spheresHitList = (sphere **)calloc( (lightBounces + 1),sizeof(sphere*) );
vec3 *spheresNormalList = (vec3 *)calloc( lightBounces + 1,sizeof(vec3) );
#define lightBounces 1
//sphere **spheresHitList = (sphere **)calloc( (lightBounces + 1),sizeof(sphere*) );
//vec3 *spheresNormalList = (vec3 *)calloc( lightBounces + 1,sizeof(vec3) );
int hitLightIndex = -1;
vec3 sphereNormal;
int raysPerPixel = 50;
ray originalRay = *lightray;
for (int k = 0; k < raysPerPixel; k++) {
sphere *spheresHitList[lightBounces + 1] = {0};
vec3 spheresNormalList[lightBounces + 1] = {0};
*lightray = originalRay;
RGBA tempPixel = (RGBA){1,1,1,1};
sphere *nearestSphere = nullptr;
@@ -92,8 +94,8 @@ RGBA raytraceSphere(sphere **objectList, ray *lightray) {
pixel.a = pixel.a / raysPerPixel;
free(spheresHitList);
free(spheresNormalList);
//free(spheresHitList);
//free(spheresNormalList);
return pixel;
}
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 760 KiB

After

Width:  |  Height:  |  Size: 525 KiB