# Need help with basic frustum culling

This topic is 1048 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I'm making a 3D RTS, and I want to see if a tile is in the window or not. I have been told to multiply the MVP matrix by the vector position (im using the center position) of the tiles, and I am to somehow get some value between -1 and 1 to see if it is in view.

I am confused how I get a value like this from a vec4. Also when I multiply by the position, do I just put 0.0 for the w component?

My view frustum is extremely simple. The tiles will always be within the near and far planes, it's always guaranteed a single tile will not fill the screen etc. I'm looking for fast, but asking people and searching google has not yielded a demonstration of the vec4*mat4 approach.

Help is appreciated/

##### Share on other sites
Put 1 for the w component before the multiply, then divide the resulting vector by the w value after the multiply

// first you find the clipping space matrix
clippingSpacePoint = MVP_matrix * vec4(x, y, z, 1)
// then you normalize the point by dividing by w
clippingSpacePoint.x /= w
clippingSpacePoint.y /= w
clippingSpacePoint.z /= w
// now any point that is on screnn will have a clippingSpacePoint x and y coordinate between -1 and 1

To do this accurately you will need to transform 4 corners of the tile and determine if any point lies inside the -1 to 1 range. You will also need to determine if a tile edge intersect the frustrum. It is possible for a tile edge to be on screen with none of the corners on screen.

##### Share on other sites

If you check against w itself, you don't have to do the divide.

Simplest way to test if a tile can be culled is to see if all of its four vertices lie outside at least one of the clipping planes.

1. 1
2. 2
Rutin
23
3. 3
4. 4
5. 5
khawk
14

• 9
• 11
• 11
• 23
• 12
• ### Forum Statistics

• Total Topics
633653
• Total Posts
3013160
×