Detect if entity rendered

Hi guys,

Is there a way to check if a object is within any cameras render area?

Thank you for any advices.

Hmm. Haven’t done it myself and there’s no inbuilt function that I know of that does it.

However, you could use the frustum to check if the bounding sphere of the object is in view which might be enough for your use case?

You may also want to look at the engine code to see how the engine determines what to cull.

Thank you. But if desired entity is covered with other object so camera do not see him but is in frustum …

Any other advices ?

You potentially have to look at spatial partitioning, shape/ray casting to see if object is in front of it partially or fully.

I can’t think of anything off the top of my head that could do it. Maybe @Mr_F has some ideas what can be done in the graphics pipeline.

It seems occlusion culling is not builtin in playcanvas ?

That should soon become very easy to do after we release some engine updates :wink:

And yeah, there’s no occlusion culling at the moment (only frustum culling).

1 Like

I need this
I couldn’t Implement it can you convert it to playcanvas?



You can try getting the camera frustum and check if the ball is in it?

thanks I will check it out

Occlusion culling tends to be application-specific, unless you are refering to hardware-based occlusion culling which is a different story and is slightly more standardised… .

Are you sure the engine dev team is working to add hardware occlusion culling and queries?

The non-hardware approach:

Based off a given triangle, or convex hull for the obstacle, etc. you generate a bunch of 3D frustum planes for the obstacle in relation to the camera in which you then test with dot products to see if a particular object is fully covered (ie. fully enclosed within the obstacle’s frustum) to varying degrees of accruacy ( depending on what you need… bounding box in frustum, sphere in frustum etc.). (Hint: For convex hull obstacles, find the visible ‘outer’ edges of the convex hull obstacle by flagging edges which contain 1 face on one side of it being a backface (hidden) and the other face on the other side of that edge being frontface (visible to camera), order those edges and generate frustum planes in 3D for the convex hull obstacle. You’d need to set up a convex hull object structure that keeps track of each edge of the mesh, and the 2 face references connected by each edge.

Like for this case: I have an actual percentage cover system:
But instead of dealing with convex hull obstacles, i incrementally clip away a view-aligned target bounding box’s area via a polygon soup (the polygons are optimised-searched via a bounding volume hierachy) and then see if there is any remaining clipped area left. Essentially, each environment triangle polygon that is detected to be “potentially blocking” the view-aligned target bounding box is used to clip away the bounding box’s polygon area.

1 Like