4
\$\begingroup\$

So I am working on a game, and I've noticed that everything in the world is sent to be rendered. Of course with the camera, only some of the world is rendered.

Does this mean there is there any expense for when I send all those extra vertices to OpenGL that don't show up on screen? Will OpenGL/LibGDX do it automatically?

If I should clip it, is ScissorStack the way to go?

\$\endgroup\$
2
  • \$\begingroup\$ LibGDX handles this automatically, but depends on how you implemented it. It would help us to see how you render (your code), so we can help you. \$\endgroup\$
    – Mayuso
    Jan 20, 2016 at 9:00
  • \$\begingroup\$ I can't really put my code here because the rendering spans a lot of classes. Essentially I Have a main spritebatch that is sent through to the Game state manager's render method. Then it is sent through to the current gamestate's render method. The level controls updates and renders the entities (they all render texture regions). In this level, the map is rendered under, and an additional spritebatch in level renders the overlay on top. \$\endgroup\$
    – Meeesh
    Jan 20, 2016 at 22:50

2 Answers 2

2
\$\begingroup\$

I'm not sure if this will help but the fastest thing to render is nothing at all.

Make sure to cull as much unseen data out as you can.

On the CPU use an octree or something and cull with view frustum, that get you everything in front of the camera, then cull that some more with occlusion query's to get only the objects that you can see.

Once this is done you will have a very small but visible set of objects to draw.

I have done this bit by bit as I need to get more and more drawn on screen I had to cull more and more.

For a long time I was just using the view frustum but that will only get you so far.

If you have shadows then use cascaded shadow maps because you can update the cascades at different intervals, also you only need to render everything in to one or two cascades the last two in my case get less and less drawn into them.

I do the same with water reflections, I skip grass and any small plants and undergrowth.

Just sit back and think to your self what do I really need to draw, think out side the box and just try stuff

\$\endgroup\$
0
\$\begingroup\$

Yes, if there's extra data/rendering being performed that's outside the bounds (frustum) of your camera, it would be more efficient to not attempt to render the geometry that can't be seen. How you actually do this depends on how your game is structured - tile-based 2D games can simply figure out what bounds of the world to draw, whereas 2D and 3D games not on a grid tend to use a space partitioning algorithm such as Binary Space Partitioning

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .