www.jpct.net
jPCT - a 3d engine for Java => Support => Topic started by: Mr_Chaos on May 27, 2014, 01:43:54 pm
-
I'm making a small project that uses JPCT to create a 3D view of a train track with straight, curves, merges, diverter, etc.
I have a model with 2000 objects consisting of a total of 43000 triangles all elements are static, so I use CompileAndStrip on all of them, but I'm still only seeing 40 fps when running fullscreen at 800x600 on a laptop with a Nvidia Quadro 2000M with 2Gigabyte memory.
Can someone give a hint if this is the expected kind of performance, or if I can tweak some settings ?
-
This highly depends on the scene, the size of the objects on screen, the overdraw, the rendering attributes and stuff. Are these 2000 objects all individual objects that are visible all the time?
-
And are you using the software renderer or the hardware one?
-
This highly depends on the scene, the size of the objects on screen, the overdraw, the rendering attributes and stuff. Are these 2000 objects all individual objects that are visible all the time?
It's 2000 individual objects and at the moment I place them by creating them with center at 0,0,0 and then rotating and translating them to their correct location, they have no texture at the moment and the coloring is done using setAdditionalColor.
99% of the objects are static, but I hope later to add some animation to the mergers/diverters and maybee some textures to some of the objects.
Bumped the performance by quite a bit, by using compileAndStrip on all objects.
[attachment deleted by admin]
-
And are you using the software renderer or the hardware one?
I hope I'm using the hardware one
buffer = new FrameBuffer(800, 600, FrameBuffer.SAMPLINGMODE_HARDWARE_ONLY);
buffer.disableRenderer(IRenderer.RENDERER_SOFTWARE);
buffer.enableRenderer(IRenderer.RENDERER_OPENGL);
-
Yes, you are using hardware. Otherwise, the strip operation would cause problems.
Anyway, 2000 objects is quite lot. Each object requires at least one draw call and these are expensive. Try to merge multiple objects into one if possible. In addition, you might want to give multi-threading a try: http://www.jpct.net/wiki/index.php/Multithreading (http://www.jpct.net/wiki/index.php/Multithreading)
-
Yes, you are using hardware. Otherwise, the strip operation would cause problems.
Anyway, 2000 objects is quite lot. Each object requires at least one draw call and these are expensive. Try to merge multiple objects into one if possible. In addition, you might want to give multi-threading a try: http://www.jpct.net/wiki/index.php/Multithreading (http://www.jpct.net/wiki/index.php/Multithreading)
I'll look into merging some of the objects into bigger ones, but there are gaps between then, so do I need to insert transperant triangles or does the engine handle that case without problems ?
I allready have the following for multithreading
Config.useMultipleThreads = true;
Config.glVSync = false;
Config.maxNumberOfCores = 4;
Config.maxPolysVisible = 25000;
-
Gaps are no problem. You just have to make sure that any translations or rotations that you apply to the individual objects are made permanent to the mesh before merging (have a look at rotateMesh and translateMesh for more information).
-
Gaps are no problem. You just have to make sure that any translations or rotations that you apply to the individual objects are made permanent to the mesh before merging (have a look at rotateMesh and translateMesh for more information).
Tried merging into 10 big object, but performance dropped a lot. I suspect it's because the big objects consists of objects from all over the worldspace (I merged all straight objects into 1 big objects, all diverters into 1 big objects and so forth).
I was thinking about dividing the world into 64 pieces and then merging all objects inside into 1, so instead of 2000 objects, I would end up with 64.
Does it sound like something that could work ?, also is it possible to buy support ?
-
It highly depends on the scene what's best. If one or more of your objects are really huge compared to the visible area, you might also want to consider to use an octree (http://www.jpct.net/doc/com/threed/jpct/OcTree.html (http://www.jpct.net/doc/com/threed/jpct/OcTree.html)). If not for the rendering, it will come in handy when doing collision detection on the object.
-
...also is it possible to buy support ?
Rather not, at least not from me. If you need some more in depth support, you can always create a test case for me and i'll see what i can do, but i don't offer commercial support.
-
It highly depends on the scene what's best. If one or more of your objects are really huge compared to the visible area, you might also want to consider to use an octree (http://www.jpct.net/doc/com/threed/jpct/OcTree.html (http://www.jpct.net/doc/com/threed/jpct/OcTree.html)). If not for the rendering, it will come in handy when doing collision detection on the object.
Well I forgot to call CompileAndStrip and it gave a huge boost. From 60fps to 900-1000fps. I merged every type of element (straight, curve, etc) into 1 big object3D, so I have have 1 object3D pr. elementType, and that works fine, except for Mergers and Diverters.
For some reason that "merged" object cannot be displayed, my guess is that somehow the mesh is not drawable or something, but there are no errors from jpct, any ideas ?
-
For some reason that "merged" object cannot be displayed, my guess is that somehow the mesh is not drawable or something, but there are no errors from jpct, any ideas ?
There shouldn't be such a thing as a "not drawable mesh". Are these objects from the others in some way? Are you applying transformations to them before or after the merge?
-
For some reason that "merged" object cannot be displayed, my guess is that somehow the mesh is not drawable or something, but there are no errors from jpct, any ideas ?
There shouldn't be such a thing as a "not drawable mesh". Are these objects from the others in some way? Are you applying transformations to them before or after the merge?
They are part of the same railroadtrack, they are where the track splits and joins (The blue and green parts of the screenshot). All transformations and rotation is applied before the merge.
The strange thing is, that I can add 1-3 mergers with no problem, but add any more and it just doesn't show anything.
[attachment deleted by admin]
-
That shouldn't happen. Can you provide a test case for it that shows the problem?
-
Try calling Object3D.setCulling(false) (or else invertCulling()) in the invisible objects just to see if the normals weren't exported or imported wrong.
-
Did you figure this one out?
-
Did you figure this one out?
Hi, sorry for the late reply, have been on a business trip, so haven't had time to check it.
But tested with the suggestions you had and still no dice. The funny thing is, if I have 1 merge object and I draw it by itself, it renders just fine, if I merge it into another Object3D it doesn't render.
I'll make a test case and submit
-
It's big and ugly, but I pasted it here
http://pastie.org/9292745
-
I'll look at it when i'm back from holiday in 2 weeks.
-
I'll look at it when i'm back from holiday in 2 weeks.
Have a nice one
-
Well, found the problem in my testCase, forgot to call world.addObject for the merged object.
So right now it works in my testcase, but not in my real code :/
I'll try to update my testcode
-
Found the problem, and if was very simple.
To generate the elements I have 3 points, and calculate all intersections based on that, the algorithm didn't account for elements running along the y-axis which generated an Infinite slope and an invalid triangle.
Don't know if JPCT should add a check to Float.isInfinite when adding triangles (eventhough it will slow stuff down)
-
If you're not adding triangles in the game loop, it shouldn't slow down noticeably.
-
If you're not adding triangles in the game loop, it shouldn't slow down noticeably.
Even better, Merged everything into 1 element, so now I just rotate the object, piece of cake.
Thanks