Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - jpro

Pages: 1 [2]
16
Support / Re: Performance with many objects
« on: November 05, 2010, 11:20:31 pm »
This what I'm doing in an attempt to reuse the model/mesh:

Code: [Select]
public class Block extends Object3D
{
    public static Object3D MODEL = null;

    public static Object3D getModel()
    {
        if(MODEL == null)
        {
            MODEL = Primitives.getCube(0.5f);
            MODEL.setTexture("box");
            MODEL.setEnvmapped(Object3D.ENVMAP_ENABLED);
            MODEL.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
            
            MODEL.build();

            MODEL.rotateY((float) -Math.PI / 4f);
        }

        Object3D newModel = MODEL.cloneObject();
        newModel.shareCompiledData(MODEL);
        newModel.compile();
        
        return newModel;
    }

    public Block()
    {
        super(getModel());
    }

... etc.

Doing these steps improves framerate from ~5 FPS to ~15 FPS. Obviously still not enough to be playable so hopefully I'm just not doing this right or there are other steps that can be taken.

17
Support / Re: Performance with many objects
« on: November 05, 2010, 08:09:23 pm »
I apologize for the vagueness -- I don't have access to the code at the moment. I will give it another shot later tonight. Thanks for the advice/patience.

18
Support / Re: Performance with many objects
« on: November 05, 2010, 04:23:02 pm »
I got frustrated trying to make this work so I ended up prototyping with raw OpenGL. It works much faster with direct calls and now I'm wondering how I can reproduce these results using JPCT. My OpenGL solution uses a single display list (created via GL11.glGenLists(1)) which I reuse repeatedly (GL11.glCallList(that same id)) changing the position per cube of course.

I get up to around 10,000 cubes before performance is impacted, so I know this is possible. I'm sure there's a way to duplicate these results in JPCT with compile or clone, as you've stated above, but all of the combinations I've tried thus far haven't worked.

Long story short... what JPCT calls duplicate the display list functionality of OpenGL?

19
Support / Re: Performance with many objects
« on: November 02, 2010, 02:47:20 pm »
Excellent. I appreciate the advice. For the record I am using hardware rendering.

My current Cube implementation is something like:

Code: [Select]
class GameCube extends Object3D
{
    static Object3D MODEL = Primitives.getCube(1f);
   
    public GameCube()
    {
        super(MODEL);
    }
}

which I thought would reuse the same model, but it sounds like there's some additional steps that I need to take to make that happen. I'll report back once I've implemented the changes you've outlined.

20
Support / Performance with many objects
« on: November 02, 2010, 03:26:17 am »
Is there something I should be doing to prevent rendering objects that are not visible? In the simple demo app I've developed I build a 4x4x4 grid of cube Object3Ds, stacked into a block. That gives me around 250 FPS. If I increase the size of the stack to 16^3 or 4096 Cubes, FPS drops to about 15. I originally was doing this as a physics demo so I went ahead and disabled the physics entirely but that didn't change anything. Profiling the code indicates the bottleneck is rendering.

A lot of the cubes (the ones in the center) are not visible at all, but I imagine they are still being updated/rendered in some way? Is there something I should be doing to prevent this? Unless I'm mistaken I can't merge them into some united list or object, since the physics engine will be altering them individually.

Many apologies if this is obvious or has been covered. I spent about two hours trying to find a solution but nothing has worked yet so I got desperate.

edit:

Some of what I read online indicates that this type of culling is mostly unnecessary. If so, why does my performance drop so much when rendering a lot cubes? I'm not doing anything fancy like turning off back face culling.

Pages: 1 [2]