Support Forum       G3D Web Page     
Classes | Namespaces | Macros | Variables
our.glsl File Reference

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...
 

Detailed Description

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

Macro Definition Documentation

◆ our_glsl

#define our_glsl

◆ TEST [1/2]

#define TEST (   U,
  VW 
)
Value:
/* Is there a hit on this axis in front of the origin? Use multiplication instead of && for a small speedup */\
(distanceToPlane.U >= 0.0) && \
/* Is that hit within the face of the box? */\
all(lessThan(abs(ray.origin.VW + ray.direction.VW * distanceToPlane.U), box.radius.VW))
G3D::Matrix abs(const G3D::Matrix &M)
Definition: Matrix.h:633

◆ TEST [2/2]

#define TEST (   U,
  V,
 
)
Value:
(float(distanceToPlane.U >= 0.0) * \
float(abs(rayOrigin.V + rayDirection.V * distanceToPlane.U) < boxRadius.V) *\
float(abs(rayOrigin.W + rayDirection.W * distanceToPlane.U) < boxRadius.W))
G3D::Matrix abs(const G3D::Matrix &M)
Definition: Matrix.h:633

documentation generated on Wed Nov 24 2021 08:01:50 using doxygen 1.8.15