I am implementing foveated rendering. My FBO is divided into 2 layers which are concentric. First layer covers 1/3 of Framebuffer whereas second one covers rest of the screen. Now I want to avoid to render meshes in outer layer which are already in inner layer. I have implemented following culling algorithm which is only concerned with culling between the layers:
- I create a rectangles with min and max corner from the radius of 2 layers. Now these coordinates are in NDC.
-
I have min and max corner of each mesh in local coordinate system. so I transform them into NDC using:
vec4 min=mvp * vec4(min_corner,1.0); min=min.xyzw/min.w;
-
I create bounding box using min and max corners.
- Check whether 2 rectangles overlap or not.
Now, when I transform into clip space, the x or y coordinates of min are sometimes greater than max corner. Same issue occurs when I divide them by w. Whats going wrong here?