• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Tchom

Game engine: Batch rendering advice?

8 posts in this topic

Hey guys, I looking for some advice/insights into render batching. I've been building my own game engine for Android (OpenGL ES 2.0) and at the moment, I feel like I am handling my game object rendering very inefficiently.

 

Currently, I have GameObjects that have are stored in a list in a GameWorld. GameObjects have a reference to a texture and a mesh. At the moment, all I do is loop through the GameObjects in my renderer, binding textures and unbinding them object by object. My understanding is that binding is quite an expensive process. So, I guess my question is... does anyone have an elegant way to handle this?

 

Some of the ideas I had were:

 

- Sort the GameObjects list on the texture id (possibly also expensive to do) so that objects with the same texture render together

- Instead of an array with everything in it,  GameObjects of the same type are kept in their own arrays, and each one of those is looped through with only one 'bind' call required per group.

 

I hope I was clear enough to create some idea of where I'm at and what I'm trying to do, I can't wait to hear your feedback.

0

Share this post


Link to post
Share on other sites

@L.Spiro

 

Thank you! Great answer and a super helpful link! I really appreciate it!

0

Share this post


Link to post
Share on other sites
Thanks from me too Spiro!

I've read your article and i was interested in the DX9 32 bit padding, since XNA is DX9 based it is supposed to work too, isnt it? If you had any experience with it i'd be glad to hear from you :)

Thank you for your time and happy coding!!
0

Share this post


Link to post
Share on other sites

I have not done anything low-level in XNA.

You should be able to run your own tests though; it should be fairly straightforward to set up both cases.  I would expect it to have similar results, but less of an impact overall.

 

 

L. Spiro

0

Share this post


Link to post
Share on other sites
Thank you for the answer, as soon as i get home i'll make a couple of tests with the particle engine!

Btw great blog, bookmarked :)

Happy coding !
0

Share this post


Link to post
Share on other sites

There are two big considerations to have when optimizing render systems, my knowledge is PC based but for all I know mobile devices are subject to the same bottlenecks.

 

First is graphics device states, the configurations of how the graphics card should do things, changing these settings, such as Wireframe vs Solid fill mode, or which shader to use is expensive on its own, but also kills pipelining, in case you don't know what that is, think of it as assembly line process, as long as a buch of objects require the same processes, you don't need to wait for one object to finish completely before sending the next one, if the process has 5 steps, you can have 5 objects going through the pipeline at the same time, which saves A LOT of time.

So with that in mind, objects should be grouped toghether based on how similar their rendering process is, Textures are important, specially the large ones, but in my experience shaders and render states are more important.

The other thing to keep in mind is that while the graphics card will skip content that it resolves not to be within the drawing area on its own, the objects need to be in the graphics card for that to be evaluated and that is already a lot of wasted time, it is your responsibility to give the graphics card the least possible number of out of scope objects, this is whats called Potentially Visible Set optimization, and Space Partitioning structures are the fastest way to do it (as far as I know), you should read up on that. Doing it object by object in the CPU is almost as wastefull as letting the GPU do it.

A third thing you might want to be carefull about is clipping, when an object is only partially visible, that is, a part of it is within the view cube, the graphics device must cut the mesh to include only what is within the cube and ignore the rest, this is because if it didn't do so, the pixel shader would likely go through a hell of a lot of pixels that aren't visible anyway. Small objects are not a problem, since they are likely to fit within the view or be completely outside of it most of the time, but large objects, as say a mountain cliff, are likely to be partially visible a LOT, sometimes its better to make these meshes in such a way its easy to discard most of them. I haven't really dug into this concern myself, but you might want to read up on it, I think Polygon Clipping or Trimming are good search terms.

UPDATE: I've asked around with some engine developers, apparently the biggest bottleneck in consoles and PC right now, is texture size and count, however states may still be a big deal on mobile platforms.

Edited by NEXUSKill
1

Share this post


Link to post
Share on other sites

Usually, most modern engines usually allow a number of objects to be outside the view window, and render any object they touch (leaving the level designer to make sure they break down big objects into pieces so those completely hidden are not rendered). If you use LODing, it doesn't matter much anyway, as they should not be on the screen often, and large objects will be low detail at distance.This is how CryEngine does it. Note, they also use culling objects (PC only) so level designers can further mask out portions that would otherwise get rendered using this technique, 

 

Oops edit: Another reason, if memory serves, is even if you are rendering something off-screen -at the edge of the screen atm, it will likely be on screen in a short time.. My experience in CE3 is it's rather more liberal in it's default setting..

Edited by SinisterRainbow
0

Share this post


Link to post
Share on other sites

I'm not incredibly experienced, so this may be a royal pain on larger systems, but it may or may not be beneficial to try maintaining a list of meshes containing references to a particular texture or shader.  Presumably you would place this list in the wrapper class for shaders and textures, and then when it comes time to render, your rendering list can go through the texture pool to grab each texture, bind it, then render the objects using that texture, unbind, then repeat the process with your other meshes.  This way you can lessen some of the sorting pains that would normally occur at render time.  Of course, you wouldn't necessarily be able to do that for anything requiring alpha blending, but that is a black art in of itself (I guess recent API updates to DirectX and OpenGL allow for order-independent rendering of sorts, but I don't think OpenGL ES has received this sort of attention yet).

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0