mirror of
https://github.com/TheRedShip/RT_GPU.git
synced 2025-09-27 18:48:36 +02:00
+ | Portals now handled correctly + support
This commit is contained in:
@ -74,17 +74,14 @@ Ray portalRay(Ray ray, hitInfo hit)
|
||||
portal_1 = objects[hit.obj_index];
|
||||
portal_2 = objects[int(portal_1.radius)]; // saving memory radius = portal_index
|
||||
|
||||
vec3 portal_2_normal = portal_2.normal * sign(dot(ray.direction, portal_2.normal));
|
||||
|
||||
relative = hit.position - portal_1.position;
|
||||
|
||||
ray.origin = portal_2.position + mat3(portal_2.transform) * relative;
|
||||
ray.origin += portal_2_normal * 0.01;
|
||||
mat3 rotation = mat3(portal_2.transform) * transpose(mat3(portal_1.transform));
|
||||
|
||||
if (dot(ray.direction, portal_2_normal) < 0.0)
|
||||
ray.direction = reflect(ray.direction, portal_2_normal);
|
||||
ray.origin = portal_2.position + rotation * relative;
|
||||
ray.direction = normalize(rotation * ray.direction);
|
||||
|
||||
ray.direction = normalize(mat3(portal_2.transform) * ray.direction);
|
||||
ray.origin += ray.direction * 0.01f;
|
||||
|
||||
return (ray);
|
||||
}
|
||||
|
Reference in New Issue
Block a user