8
\$\begingroup\$

http://amd-dev.wpengine.netdna-cdn.com/wordpress/media/2012/10/Mitchell_LightShafts.pdf

SOURCE : http://amd-dev.wpengine.netdna-cdn.com/wordpress/media/2012/10/Mitchell_LightShafts.pdf

This process is part of creating light draft effect. And I am suggested to do the described process in order to enhance performance and I really want to do it.

However I am clueless on how I can apply "frustrum perspective matrix" from other camera to my camera perspective to chop off that square plane into shapes that fit into the "frustrum perspective matrix".

I am guessing I need to do this on CPU side first? But that's as far as my wild guess goes

\$\endgroup\$
0
\$\begingroup\$

For a simple way of doing it, you’ll need two things:

First, you’re looking for the Sutherland-Hodgman Clipping algorithm, or some other type of clipping algorithm. Sutherland-Hodgman is very easy to understand and implement, and it is used in some physics engines for this even today. This will clip your shapes given a clipping volume.

The second thing you’re looking for is some background on projection matrices and how the frustum is formed.

Matrices are used by multiplying them with coordinates to produce a transformed set of points. A typical example would be mapping the vertices of the unit cube to the canonical view frustum. Now treat your new frustum as the clipping object from the first step and viola. A decent way of doing it on the CPU.

There are lots of optimizations you can make as well and different approaches such as taking the 6 faces of a box, and instead of transforming their vertices, use the matrix to transform their homogeneous half-space representation for frustum culling

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.