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

chunks of cubes

2 posts in this topic

A few months ago i was working on a voxel engine, but gave up after facing a lot of problems. Ive done a lot of 2d and some 3d programming since then so i decided to give this another shot.

I have a cube class that draws a singke textured cube, using a BuildFace method. This method will be very useful when culling the sides of cubes. Im not dealing with indices right now, i only have a vertex buffer. The cube constructor has three parameters, graphicsdevice, a vector3 location, and a texture.

My next step is figuring out how to store cubes in chunks of 50x50x50. I think that would be reasonable enough speed-wise.
Each chunk would have its own vertex buffer im guessing? but what confuses me is how to add cubes to that buffer. What kind of helper methods would i need? If im going for the minimum amount of draw calls id somehow need to use one giant buffer.

The other thing is the actual draw call itself. Looping through a chunk of cubes and calling each cubes draw method doesnt seem very effective and it hasn't worked in the past. But what if a cube has a different texture? I would want a single draw call from each chunk.

Im trying to take this as slow as possible so i.don't end up with the mess i had months ago :p
0

Share this post


Link to post
Share on other sites

If you want to draw chunks in one call, what I'd do is maintain the cube data, vertex buffer, and index buffer separately, you don't want to waste time drawing faces that couldn't possibly be seen, like the common face of two adjacent cubes.

 

Have all the textures for the faces in a single texture. The texture coordinates you need to give to each face are implied by the face (North, South, East, West, Top, Bottom), and the kind of the cube (Dirt, rock, whatever). Really, the vertices never change -- they might belong to 0, one, or many cubes, but they don't change. You can probably have a single, unchanging vertex buffer for all chunks, even, or compute it as needed. Build the chunk index buffer initially by iterating over the cubes and adding indexes into the vertex buffer for every face that's shared with an adjacent cube that's transparent (e.g. "air", water, ice, glass), as well as the very outside faces (if you want each chunk fully independent of its neighbors for drawing purposes). A further possible optimization would be to then make a second pass and collect together similar adjacent faces in a triangle strip, but I suspect its more trouble than its worth.

 

Also, the chunk size is not arbitrary, it's size is bound by the worst-case scenario size of the vertex and index buffer (if your aim is a single draw call per chunk). The number of vertices required is (W+1) x (H+1) x (D+1) where W, H, and D are the width, height and depth of a chunk measured in cubes. Assuming cubes only,  the worst-case scenario for indices is chunk filled with semi-transparent cubes (like ice or glass -- you can see through it, but it has a face and a texture). With a triangle list, this is 48 indices per cube, so 48 x INDEX_SIZE x (W+1) x (H+1) x (D+1) < MAX_INDEX_BUFFER_SIZE will give you the largest chunk that's drawable in a single call. allowing blocks to have more complicated geometry greatly complicates this scheme.

 

You could also just used instance rendering, and draw each chunk in several calls, one for each permutation of geometry, texture, orientation, etc. You could find which cubes need to be draw similar to above, or possibly by ray-casting.

0

Share this post


Link to post
Share on other sites
There's really only two types of block, dirt and grass. If a blocks top face is visible its grass. Empty blocks could be made with an IsActive bool i would think. The texture for each block is the same on all.sides.


While adding each block to the chunk, i coukd check if sides are adjacent, but i don't know how to do that.

I have looked at instance rendering, but the blocks will be manipulated almost all the time so i don't know if that's the best choice right now
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