mirror of
https://github.com/TheRedShip/RT_GPU.git
synced 2025-09-27 10:48:34 +02:00
~ | Materials in a seperate SSBO
This commit is contained in:
@ -2,17 +2,19 @@
|
||||
Ray newRay(hitInfo hit, Ray ray, inout uint rng_state)
|
||||
{
|
||||
GPUObject obj;
|
||||
GPUMaterial mat;
|
||||
Ray new_ray;
|
||||
|
||||
obj = objects[hit.obj_index];
|
||||
|
||||
mat = materials[obj.mat_index];
|
||||
|
||||
vec3 diffuse_dir = normalize(hit.normal + randomDirection(rng_state));
|
||||
vec3 specular_dir = reflect(ray.direction, hit.normal);
|
||||
|
||||
bool is_specular = (obj.metallic >= randomValue(rng_state));
|
||||
bool is_specular = (mat.metallic >= randomValue(rng_state));
|
||||
|
||||
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, mat.roughness * float(is_specular));
|
||||
|
||||
return (new_ray);
|
||||
}
|
Reference in New Issue
Block a user