* | Going to make big changes, saving

This commit is contained in:
TheRedShip
2025-01-05 14:45:52 +01:00
parent d02b9ffb5d
commit 846efdd5c6
2 changed files with 7 additions and 6 deletions

View File

@ -4,9 +4,9 @@ MAT 255 255 255 3.0 0.0 0.0
MAT 255 100 100 0.0 0.0 0.0 MAT 255 100 100 0.0 0.0 0.0
MAT 100 100 255 0.0 0.0 0.0 MAT 100 100 255 0.0 0.0 0.0
MAT 100 255 100 0.0 0.5 0.0 MAT 100 255 100 0.0 1.0 1.0
MAT 255 255 255 0.0 1.0 0.0 MAT 255 255 255 0.0 1.0 1.0
sp 0 -1 0 1 5 sp 0 -1 0 1 5

View File

@ -73,7 +73,7 @@ hitInfo traceRay(Ray ray)
return (hit); return (hit);
} }
Ray newRay(hitInfo hit, Ray ray, bool is_specular, inout uint rng_state) Ray newRay(hitInfo hit, Ray ray, inout uint rng_state)
{ {
GPUObject obj; GPUObject obj;
Ray new_ray; Ray new_ray;
@ -83,6 +83,8 @@ Ray newRay(hitInfo hit, Ray ray, bool is_specular, inout uint rng_state)
vec3 diffuse_dir = normalize(hit.normal + randomDirection(rng_state)); vec3 diffuse_dir = normalize(hit.normal + randomDirection(rng_state));
vec3 specular_dir = reflect(ray.direction, hit.normal); vec3 specular_dir = reflect(ray.direction, hit.normal);
bool is_specular = (obj.metallic >= randomValue(rng_state));
new_ray.origin = hit.position + hit.normal * 0.001; new_ray.origin = hit.position + hit.normal * 0.001;
new_ray.direction = mix(diffuse_dir, specular_dir, obj.roughness * float(is_specular)); new_ray.direction = mix(diffuse_dir, specular_dir, obj.roughness * float(is_specular));
@ -107,14 +109,13 @@ vec3 pathtrace(Ray ray, inout uint rng_state)
GPUObject obj = objects[hit.obj_index]; GPUObject obj = objects[hit.obj_index];
bool is_specular = (obj.metallic >= randomValue(rng_state)); color *= obj.color;
color *= mix(obj.color, vec3(1.0, 1.0, 1.0), is_specular);
light += obj.emission * obj.color; light += obj.emission * obj.color;
if (obj.emission > 0.0) if (obj.emission > 0.0)
break; break;
ray = newRay(hit, ray, is_specular, rng_state); ray = newRay(hit, ray, rng_state);
} }
return (color * light); return (color * light);
} }