Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Frustum culling #3

Open
sweeneychris opened this issue May 13, 2016 · 4 comments
Open

Frustum culling #3

sweeneychris opened this issue May 13, 2016 · 4 comments

Comments

@sweeneychris
Copy link

Thanks for a great app for fast ray intersections! I was wondering what needs to be done in your opinion to add functionality for view frustum culling? It seems most of the constructs are in place to do this easily. I am new to this area but would be happy to take a stab at implementing it if you can provide a bit of guidance.

@nmoehrle
Copy link
Owner

Hi Chris,

since I have no concept of views or cameras within this project I don't think we should add the functionality. But you can implement a view frustum culling around the ray intersection tests within few lines as I did for example within the texturing project starting here.

Note that the code starting in line 182 does:

  1. Backface culling
  2. A halfspace culling (I falsely referred to it as basic view frustum culling)
  3. A culling base on ray impact angle (You don't want that in rendering)
  4. A projection onto the view plane (The real view frustum culling, although three is also a "valid" pixel check in there)

Thanks for the offer and the interest in the project :-) I'll leave this issue open if you have further questions - feel free to ask.

Cheers,
Nils

@sweeneychris
Copy link
Author

Even though there is no concept of cameras or views, I can still imagine an interface where clipping planes are provided and the method returns all geometry that satisfies those planes.

I will take a look at the referenced code. Thanks for the response!

@nmoehrle
Copy link
Owner

nmoehrle commented Jun 7, 2016

Sorry for the late response :-(

An culling based on clipping planes specified as point normal pairs sounds indeed like a good idea.
Are you imagining something like:

template <typename Vec3fType>
struct Plane {
    Vec3fType normal;
    Vec3fType origin;
}

template <typename IdxType, typename Vec3fType>
BVHTree<IdxType, Vec3fType>::inside(std::vector<typename Plane<Vec3fType> > convex,
    std::vector<IdxType> * faces, bool completely = false)

where the planes describe a convex subspace and all faces within that space are added to the faces vector.

However I am currently unsure how to efficiently check if a aabb is piercing a convex subspace.

@sweeneychris
Copy link
Author

Yes, that's exactly how I was imagining it!

I think it would need to explicitly check for a convex subspace -- it should simply return no faces if it is not possible to satisfy all plane boundaries. This would return immediately in this case since the largest BB would not satisfy the plane constraints.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants