Ray-cast to find the closest geometry

I just checked my own project - 60k of triangles is the max along with particle emitters, blaster fire etc. I’m not that experienced (actually both Java and JME are just the hobby now) but I’m playing with 3D since I believe 1997, and I can say that you can create a million-faces cube in just couple of clicks (thanks to Autodesk) but effectively they’re still 12 triangles… and to drop them to that count way easier on preparation stage than to pass that million to JME or Unity and hope they will optimize it inside…
Update: that 60k are met only in extremely crowded volume, with 100+ ships which is good for debugging purposes but can hardly be achieved in a real game.

1 Like

Yes, if I check all the pixels in one frame, I will be doing it the slow way, so I will check all the pixels’s 1/4 or 1/9 and they are evenly distributed on the screen, and all the needed pixels will be checked in 25 frames or more, this need test but if I couldn’t get the closest geometry faster, what I will do is not needed.

And I should get the closest geometry which is not transparent, and all the translucent geomotry should add to my render list too. And I will update the render list in every frame.

Thank you very much. :smile:

Almost all occlusion culling technology requires preprocessing the scene at build time and the algorithms are typically quite complex …

It does help a lot though, especially in indoor scenes. If you run the jME3 example “TestQ3” and then look at a wall, you will notice that a lot of geometry gets submitted even though its not seen. The GPU still has to process each batch and the vertices, and since jME3 does not perform front-to-back sorting (it does it by state instead), it could cause quite a bit of overdraw. The overhead is not cheap especially if the stuff behind those walls has complex shaders. Deferred rendering will help alleviate this a bit, and so will a depth prepass filter (which is like a light-weight version of deferred rendering).

The offline version of occlusion culling is called PVS (Potentially Visible Sets) - you might want to look into the books on the subject.

1 Like

Yes, thank you very much, and I want to know will the JME support occlusion culling in the future?

I wonder which of the 10000000 techniques we should pick… hmmm…

Could the occlusion culling be integrated into the JME?

There is no plan for it.
However if you make something for your game and make a PR, we’ll consider it.

I don’t know how to deal with the single object in a batch, could you say it clearly?

As far as I know:

1, Batching means that all Geometries with the same Material are combined into one mesh.
2, Using GeometryBatchFactory merges individual Geometries into a single mesh. Thereby it becomes hard to apply specific Materials or to remove a single Geometry. Therefore it should be used for static Geometry only that does not require frequent changes or individual materials/texturing.

Thank you very much!

You shouldn’t use many different materials anyway but instead use a texture atlas. When picking you get info about the triangles and can deduce the selected object from that.

I won’t be any more specific as you still don’t say what you want to do and I don’t want to get into a discussion where its mainly about contradicting everything I say.

1 Like

To batch you might have to get clever with vertex attributes… maybe store the game-logic object ID for a mesh so you can identify it again post-batching. If you need to change it’s attributes at runtime then you will have to manually unbatch it somehow and batch it into a different set.

But you don’t have many options, really, for improving performance.

1 Like

Ok, thank you all very much!

I think what he wants is to do an Occlusion culling the same way games like Oblivion Elder Scrools do, not showing objects that are far away but still in the fustrung, you know, there is an option in this game to chouse the object fade distance , actor fade distance, tree fade distance, etc, I am right @ribuluo000 ?
Maybe you need to render the intire road, but dont want to render objects in it depending on the distance ?
I dont think there is some builtin solution in JM3 to do that right now thought, and its not so easy to implement.

That’s still frustum culling… the far plane.

We’ve already deciphered what he meant and that wasn’t it.

What you describe is LOD (Level of Detail). Occlusion culling is something different.

Humm really ? There is beeping some time I dont play it, but I had the impression it simple dont render selected type of objects out of the fade distance, not only decrease its detail, I remember it is bad because if you configure actor rendering for example, at low distances, you have the impression that enemies just spaws at your face when you are walking into the terrain…
Anyway, its an complex discussion, needs more information about what he wants.
I have a felling that he wants to render selected objects in defined ranges, but who knows.
Just saying I want to render what the camera can see dont say anything…

It is still a different technique. What you describe would cause popping as objects get within the threshold or outside of it. Occlusion culling attempts to determine by some means (build time or runtime) that an object is obstructed by another object and therefore is not visible and should not be rendered, hence there’s no visual artifacts or popping with occlusion culling.

I see, well, in my experience, I have the impression this type of occlusion culling is working at builtin in JM3, I have an case of a game with an planet and objects orbiting it, and when objects are at the other side of the planet where you cant see it, I see a big decrease in the triangles being render… I am correct or I just got the wrong impression ?

They must be being clipped by the far plane?

Otherwise, they are being rendered and you just can’t see them.

I see the reduction in triangles, but maybe its because they are out of screen, the camera dont have the entire orbit in the view. Thanks to pointout its not an vannila option.
I found the topic about this : Occlusion Culling - #2 by Momoko_Fan
I will try out.