Sign in to follow this  

Quick frustum wrapping Q

Recommended Posts

So im working on my rain system (decided to go particles unless you can convince me otherwise ;p), and I need to know how to 'wrap' particles from one frustum plain to another. Im using the code found here... I know which plain a particle has gone 'behind'. Now I want to wrap a particle to the oposite plain (if it crosses the left plain, wrap it to the right plain, ect) so that particles are only inside the view frustum. Can anyone tell me what the math for that would look like?

Share this post

Link to post
Share on other sites
Well, telling if it's crossed the left plane is easy assuming you know what the plane is. Any plane can be written as r.n = c, where n is the normal vector to that plane and c is a constant. Just calculate p.n for a point p; if it's bigger than c it's on one side, smaller then the other. Moving it to the other side is a little trickier because it demands that you know where to place it on the other plane; I'd suggest at the same depth ('camera Y', depends on your view direction) and Z (vertical) co-ordinates.

Share this post

Link to post
Share on other sites
Original post by ZealousEngine
Nobody knows?
I would imagine there are some standard approaches to rendering rain; I don't know what they are, but a google search might be informative (if you haven't done it already).

As for your question, here's what comes to mind:

1. Intersect the line segment representing the particle displacement with the frustum
2. If a frustum plane is intersected...
3. Store the intersection point
4. Project the particle velocity vector onto the ground plane (just drop the component corresponding to height)
5. Create a ray with the intersection point as origin and the above vector as direction
6. Intersect this ray with the frustum, excluding the plane that was already hit from the test
7. Move the particle to the intersection point resulting from this test

This would all be done in world space, and of course would not apply to rain that was falling straight down. The generality is intended to allow for any view orientation (looking straight up, rolled to one side, and so on). The above is just off the top of my head, and may not generate the desired results (or may simply be incorrect).

[Edit: A google for 'rendering rain' turned up some good hits; depending on what effect you're after, there may be other approaches that might be worth investigating.]

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this