~ | Some map changing

This commit is contained in:
TheRedShip
2025-01-08 15:11:06 +01:00
parent 8e4d844f38
commit c414888f9e
5 changed files with 49 additions and 54 deletions

View File

@ -7,31 +7,11 @@ Ray lambertRay(hitInfo hit, Ray ray, GPUMaterial mat, uint rng_state)
bool is_specular = (mat.metallic >= randomValue(rng_state));
ray.origin = hit.position + hit.normal * 0.001;
ray.direction = mix(diffuse_dir, specular_dir, mat.roughness * float(is_specular));
ray.direction = normalize(mix(diffuse_dir, specular_dir, mat.roughness * float(is_specular)));
return (ray);
}
// Ray dieletricRay(hitInfo hit, Ray ray, GPUMaterial mat)
// {
// float refraction_ratio;
// vec3 unit_direction;
// refraction_ratio = 1.0f / mat.roughness; //mat.roughness = refraction (saving memory)
// if (dot(ray.direction, hit.normal) > 0.0f)
// {
// hit.normal = -hit.normal;
// refraction_ratio = mat.roughness;
// }
// unit_direction = normalize(ray.direction);
// ray.origin = hit.position + hit.normal * -0.0001f;
// ray.direction = refract(unit_direction, hit.normal, refraction_ratio);
// return (ray);
// }
Ray dieletricRay(hitInfo hit, Ray ray, GPUMaterial mat)
{
float refraction_ratio;
@ -39,19 +19,20 @@ Ray dieletricRay(hitInfo hit, Ray ray, GPUMaterial mat)
refraction_ratio = 1.0f / mat.roughness; //mat.roughness = refraction (saving memory)
float d = dot(ray.direction, hit.normal);
hit.normal *= sign(d);
if (d > 0.0f)
if (dot(ray.direction, hit.normal) > 0.0f)
{
hit.normal = -hit.normal;
refraction_ratio = mat.roughness;
}
unit_direction = normalize(ray.direction);
ray.origin = hit.position + hit.normal * 0.0001f;
ray.direction = refract(unit_direction, -hit.normal, refraction_ratio);
ray.origin = hit.position + hit.normal * -0.0001f;
ray.direction = refract(unit_direction, hit.normal, refraction_ratio);
return (ray);
}
Ray newRay(hitInfo hit, Ray ray, uint rng_state)
{
GPUObject obj;