Skip to content

Instantly share code, notes, and snippets.

@pushrax
Created June 23, 2016 17:56
Show Gist options
  • Save pushrax/78624d7016fc5c55868e33387799c868 to your computer and use it in GitHub Desktop.
Save pushrax/78624d7016fc5c55868e33387799c868 to your computer and use it in GitHub Desktop.
void aabbIntersectFast(vec3 P, vec3 R, vec3 invR, vec3 aabb[2], out float tmin, out float tmax)
{
vec3 t1 = (aabb[0] - P) * invR;
vec3 t2 = (aabb[1] - P) * invR;
vec3 tmins = min(t1, t2);
vec3 tmaxs = max(t1, t2);
tmin = max(max(tmins.x, tmins.y), tmins.z);
tmax = min(min(tmaxs.x, tmaxs.y), tmaxs.z);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment