Python Occlusion Culling

1k views Asked by At

Quick summary:

I am looking for a pythonic implementation of Occlusion Culling (given a camera location and known polygon coordinates of a mesh) that does not use ray casting in (blender, numpy, OpenCV).

Background:

I have a dataset of simplified geometry coordinates represented as vectors and I would like to compute occlusion culling in a optimal manner as to turn that coordinate data into an SVG image. I am not so much concerned with the SVG implementation but rather the best mathematical solution to computing occlusion culling. The typical way render engines compute this is by casting rays from the camera to each mesh vertex and testing if they collide or not. Since I am looking to make simple SVG line images I would like to avoid ray casting.

Searching through the Hidden-surface determination wiki there are a few methods described. Some of those being Portal Rendering, Potentially visible set, and Z-culling. Given the few pythonic implementations of these algorithms I am wondering which implementation would be the most computationally efficient and yield the best looking results. If you have better methods or combinations feel free to suggest them. Occlusion culling has a lot of use cases but the two main ones I am concerned with are as follows.

Internal Mesh Occlusion

pictured: 1. 3d render in blender, 2. All visible mesh edges, 3. Mesh edges culled with ray casting plugin

For the coordinate data I have most of the geometry uses simple shapes. As such, back-face culling as described here is a quick and easy solution to rendering basic shapes. Problems arise however when there is geometry that is not back-facing and is inside visible geometry. As you can see with the ray casting example above when the camera is facing the flat surface the other polygon faces of the mesh are not visible. When using back-face culling pictured below

enter image description here

you can see the polygon faces that face away from the camera get culled but the faces that are pointed at the camera remain. Occlusion culling for mesh polygons given camera location is important for rendering small objects with some complexity.

Multiple Object Occlusion

pictured: 1. 3d render in blender, 2. All visible mesh edges, 3. Mesh edges culled with ray casting plugin

The more obvious example of occlusion culling is in the case of multiple objects. While I could simply draw the SVG layers from back to front this adds unneeded layers. Culling polygons in a way that solves internal mesh culling ideally would also allow for layered object culling.

Summary

I am looking for solutions to compute Occlusion Culling given a list of vertices (structured to form polygons) and calculate which ones are visible to the camera without casting rays to each vertex.

0

There are 0 answers