Support Forum G3D Web Page |
Our ray-box intersection. More...
Classes | |
class | glsl::our_glsl |
Our ray-box intersection More... | |
Namespaces | |
glsl | |
glsl::our_glsl::glsl | |
Macros | |
#define | our_glsl |
#define | TEST(U, VW) |
#define | TEST(U, V, W) |
Variables | |
class { | |
}; | |
Shader program. More... | |
Our ray-box intersection.
Parameterized on three macros (can be const in bool GLSL, but that changes the signature of the function):
RAY_CAN_START_IN_BOX : You can avoid three operations if you know that the ray origin is outside of the box. That's true for scenes modeled from opaque objects.
In the general case of transparent objects (or two-sided boxes), you need to test for this case and flip the sense of the backface test when the ray is in the box. Note that if all that you care about is the intersection itself (e.g., you're doing BVH traversal without looking at the distance), then the answer is always "yes, the ray hits the box", since you're inside of it, and this isn't necessary.
If a distanceToPlane is negative, then the intersection is behind the ray origin and we want to ignore it. If a distance is positive, then we need to find the intersection point and see if the hit is in bounds. Because we're only considering front faces and boxes are convex, we don't have to see which intersection occurs first–any intersection with a face must be the only one.
G3D Innovation Engine http://casual-effects.com/g3d Copyright 2000-2019, Morgan McGuire All rights reserved Available under the BSD License
#define our_glsl |
#define TEST | ( | U, | |
VW | |||
) |