Hi guys,
Is there a way to check if a object is within any cameras render area?
Thank you for any advices.
Radek
Hi guys,
Is there a way to check if a object is within any cameras render area?
Thank you for any advices.
Radek
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?
https://developer.playcanvas.com/en/api/pc.Frustum.html#containsSphere
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 ?
Radek
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
And yeah, thereās no occlusion culling at the moment (only frustum culling).
I need this
I couldnāt Implement it can you convert it to playcanvas?
while(notRender){
FollowTheBall();
}
You can try getting the camera frustum and check if the ball is in it?
https://developer.playcanvas.com/en/api/pc.CameraComponent.html#frustum
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⦠https://github.com/tsherif/webgl2examples/blob/master/occlusion.html . https://tsherif.github.io/webgl2examples/occlusion.html
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.
https://playcanvas.com/project/573035/overview/sketchfab-assets-tests