• 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
RobMaddison

Chunked Terrain and Component Entity Systems

10 posts in this topic

I'm just wondering what the best practice is with chunked terrains and component entity systems.  Should each chunk be an entity in itself?  Or should the whole terrain be an entity?

 

I'm trying to streamline and refactor my rendering process, and indeed, design parts of it that haven't been done yet.  I have a sandbox project that doesn't use my new architecture and it has my terrain system in it, which is honed and extremely efficient.  Porting it to my new game engine is throwing up lots of design decisions.  My rendering engine essentially works sequentially through a vector of render 'tokens' which allow me to sort it on various criteria.  My main question is "should" my terrain parts (i.e. chunks) be just another render token in the list or should I contain my specialised terrain rendering code in its own render method.

 

It feels wrong to keep it in its own method, but its quadtree and relational nature doesn't really lend itself to a linear list of completely unrelated render tokens.  My set up is essentially like this at the moment:

 

Entity (contains standard orientation data)

---> RenderableComponent (there is a link to this object in each 'RenderToken' which just holds the sortable key, the material and link)

---> SkeletonComponent (this is just the skeleton data)

---> MeshComponent (this is just the mesh data)

---> AnimatorComponent (this builds skeletal poses based on animation data)

---> etc..

 

My entity system doesn't really have 'systems' that control the entities/components, rather the functionality exists within the components.  This was an early design decision that I quite like but it's easily changable.

 

So how would you go about moving a quadtree-based terrain system into this architecture?  Keep it a self-contained terrain system or integrate it into the pipeline properly?

 

1

Share this post


Link to post
Share on other sites


I'm just wondering what the best practice is with chunked terrains and component entity systems.  Should each chunk be an entity in itself?  Or should the whole terrain be an entity?

Wrong abstraction, in my book. Why would you want it to be either?

 

Unless you have many different terrains on screen at once, it's basically a background construct of both the rendering and physics systems.

2

Share this post


Link to post
Share on other sites

It really depends how your engine works, and how much work you want to put in the Terrain.

Can terrain patches have different shaders ? (For LoD for example) If so, do they need to be different render 'tokens' ?

 

There are a number of questions like that you'll need to ask yourself.

I'm a little familiar with entity systems but they always seemed to be more engineering fun that real benefit to me... ie Keep It Simple, Stupid.

0

Share this post


Link to post
Share on other sites

 


I'm just wondering what the best practice is with chunked terrains and component entity systems.  Should each chunk be an entity in itself?  Or should the whole terrain be an entity?

Wrong abstraction, in my book. Why would you want it to be either?

 

Unless you have many different terrains on screen at once, it's basically a background construct of both the rendering and physics systems.

 

 

It keeps everything neat and generic I think.  I've implemented it using my component entity system and it works a treat, I can sort my terrain chunks as if they were any object.

0

Share this post


Link to post
Share on other sites


It keeps everything neat and generic I think.  I've implemented it using my component entity system and it works a treat, I can sort my terrain chunks as if they were any object.

I mean, if it works, go for it.

0

Share this post


Link to post
Share on other sites


My main question is "should" my terrain parts (i.e. chunks) be just another render token in the list or should I contain my specialised terrain rendering code in its own render method.

 

my chunks are basically memory images of my renderables list (my drawlist of Zdrawinfos) for a single chunk, ready to draw. but i use separate dedicated code to do it. 

 

in your token system, the equivalent would be breaking a chunk into its tokens in a dedicated list, and strong the chunk that way. then having dedicated code just to draw that.

 

however it appears you want to treat a chunk as a single renderable. my chunks consist of 1 ground mesh per texture, plus all the plants, rocks, and water in the chunk. obviously more than one renderable. a complex chunk can have 4000+ renderables.

 

my layout happened by accident. the current drawlist data structure was originally invented for the chunk system. its worked so well, the drawlist was changed to use it. thus the two dedicated drawing routines. it could probably be done as one routine.

 

treating a chunk as just another token is the clean way to do it. everything is just a token, one token drawer. job done. gimme a beer! <g>.

0

Share this post


Link to post
Share on other sites


It feels wrong to keep it in its own method, but its quadtree and relational nature doesn't really lend itself to a linear list of completely unrelated render tokens.

 

sounds like its just a token with a very complex draw method, that's all.

 

OTOH, rendering a scene is usually easier accomplished in stages, rater than just stuffing everything in one big list and going for it.

 

even with my drawlist, i actually clear, populate, and draw it 3 or 4 time each frame. only then do i draw the ground - with a separate but almost identical routine.

 

so from that point of view, it would be nice to be able to draw the ground separately, before or after other things in the scene.

 

so that's a good case for having a stand alone ground drawing routine.

 

also, it would probably be faster / easier to implement as two routines. that's basically what you already have in separate files. another good case for having two. 

0

Share this post


Link to post
Share on other sites

My main question is "should" my terrain parts (i.e. chunks) be just another render token in the list or should I contain my specialised terrain rendering code in its own render method.

 my chunks are basically memory images of my renderables list (my drawlist of Zdrawinfos) for a single chunk, ready to draw. but i use separate dedicated code to do it.  in your token system, the equivalent would be breaking a chunk into its tokens in a dedicated list, and strong the chunk that way. then having dedicated code just to draw that. however it appears you want to treat a chunk as a single renderable. my chunks consist of 1 ground mesh per texture, plus all the plants, rocks, and water in the chunk. obviously more than one renderable. a complex chunk can have 4000+ renderables. my layout happened by accident. the current drawlist data structure was originally invented for the chunk system. its worked so well, the drawlist was changed to use it. thus the two dedicated drawing routines. it could probably be done as one routine. treating a chunk as just another token is the clean way to do it. everything is just a token, one token drawer. job done. gimme a beer! <g>.

Well after a whole day of refactoring yesterday, my terrain chunks are now just normal render tokens. My ground chunks don't have anything else associated with them (foliage, trees, etc), but that's not to say they won't at some point ( in some spatial form). There won't be any special links between eye candy and the terrain where the renderer is concerned though, it just takes a token and renders it, all the ordering is done before that. This feels like a nice system.

My terrain works in blended layers for texturing so if a chunk (32x32) has x number of textures on it, that's x draw calls - I didn't want to be restricted by passing all of my textures in one draw call especially as I have normal, specular, bump, etc too. So each terrain layer is also a token now and they are sorted to be drawn after the base terrain detail and blended on top. I blend out the detail texture layers at a very short distance (40m or so) so you only ever end up drawing layers on one or two chunks keeping the draw count down nicely - the overall surface texture (which covers 512x512 of the terrain) blends in beautifully - think Crysis,

It's really interesting to hear all your views. Norm, do you have any demos/screenshots of your engine in action?
0

Share this post


Link to post
Share on other sites

OTOH, rendering a scene is usually easier accomplished in stages, rater than just stuffing everything in one big list and going for it.
 
even with my drawlist, i actually clear, populate, and draw it 3 or 4 time each frame. only then do i draw the ground - with a separate but almost identical routine.
 
so from that point of view, it would be nice to be able to draw the ground separately, before or after other things in the scene.


Even though everything is in one big list, the list is keyed on a sort code which can contain any criteria you like, so if I 'or' in a numerical hash of 'TerrainPatch' for instance, all terrain patches will be batched together, this makes perfect sense as they all use the same shader.

So it's both generic and flexible. I've even pushed my post processing filters onto the renderqueue. Their mesh being just a full screen quad and the RenderableComponent having some specialised shader setup code (for passing results of previous renders, etc). I know with this type of development (if not, all) if something doesn't feel right, it probably isn't and this does feel very right (for once!). I'm on my 4th engine now so hopefully I'm starting to get things right. Getting some game logic in there too now, so it's coming together nicely.
0

Share this post


Link to post
Share on other sites


It's really interesting to hear all your views. Norm, do you have any demos/screenshots of your engine in action?

 

CAVEMAN, and Airships! both use the "drawlist" render queue. CAVEMAN also uses the chunk based terrain system.

 

right now, i use tiled ground textures, no blending. but i too do one draw call per ground texture. i actually create one mesh for each ground texture in the chunk, and draw each separately.

 

 

gallery_197293_593_71361.jpg

 

 

gallery_197293_672_66488.jpg

 

 

more screenshots:

http://www.gamedev.net/gallery/member/197293-norman-barrows/

0

Share this post


Link to post
Share on other sites

I'm on my 4th engine now so hopefully I'm starting to get things right. Getting some game logic in there too now, so it's coming together nicely.

 

sounds like we're working the same issues. but you're doing a full engine / game, while i'm playing with a testbed just to implement different architectures and code organization. the testbed program is yet another app of mine, and it's not yet up in my gallery.  but already you can move around and shoot stuff, with about 200 lines of user code. implementing the user collision handler in the demo program is next. right now its just displays a message saying "target x collided with (whatever)" for testing purposes.  the nice thing about the testbed is you can try things quickly. I've done 4 engine designs in the last 2 weeks with it.

 

now i need to figure out the best way to implement an optional ground drawing routine. i already have both chunk and dynamic mesh technology working. but i need to figure out what's best for all types of ground: shooters, flight sims, RTS, etc.   one ground drawing routine to rule them all.

 

any suggestions?

 

 

 

i've got about 6 titles on my short todo list (beyond CAVEMAN, AIrships!, Armies of Steel II, and CIty States) , so i'm trying to get my library / boilerplate code / engine whipped into shape so i can use it for all of them.   but the REAL problem is content. all those models required. as coders, we can use libraries, engines, and good old copy / paste / edit to get the coding done quickly. but i see no speedups for the typical week+ required for a fully rigged and animated character model with matching equipment.

other types of models also take time to create.   until there's a good supply of ready to go content available free/cheap, it will be a barrier to those without artists on the team or deep pockets.

Edited by Norman Barrows
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