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

Drawing entities from back to front

5 posts in this topic

My last problem has barely been solved and I have already encountered the next one.

 

I am making a simple 3D first-person game. I made trees by rendering 2D sprites in my 3D world wich are always turned toward the player.

 

The tree sprites have some transparent pixels in them. When a few of them overlap, sometimes, a part of the fruthest tree is not rendered behind the transparent pixels of the one in front of it. It's hard to explain so here is a screenshot:

2uh5kys.png

 

Anyway, I did some googling around and found out that the best solution would be to make sure everything is rendered from back to front.

 

Everything visible in my game is an entity and I just loop through them all every frame to render them, but now I'm going to have to make sure they are all rendered from far away from the player -> close to the player. That order could theoretically change every frame.

 

I wonder what would be an efficient way to make sure all entities are rendered ordered by their distance to the player? The height coordinate (Y-axis) does not matter in this case, because this is 0 for every entity.

 

Many thanks in advance,

Freek

0

Share this post


Link to post
Share on other sites

You could introduce a z-order component to each of your items. Then sort your list of items by z-order and draw them in order.

0

Share this post


Link to post
Share on other sites

I just did something like this. I just sorted all entities by the distance to the player, but when I turn the camera slightly, sometimes the transparent pixels still overlap.

 

By the way: The sprites only have fully transparent and fully visible pixels, so nothing in between.

0

Share this post


Link to post
Share on other sites

I just found out I could just do this:

glAlphaFunc(GL_GREATER, 0.1f);
glEnable(GL_ALPHA_TEST);

This does exactly what I wanted.

1

Share this post


Link to post
Share on other sites

It is better to not have the entities draw themselves and have them generate the data needed for rendering and passing this to the renderer. The renderer can then decide how this should be ordered and rendered, this allows you to not have to care about the update order in the entities. And you can do more sorting in the renderer other then back to front ordering.

0

Share this post


Link to post
Share on other sites

Even with sorting in the renderer, doing sorting for say alpha blending has a lot of difficult edge cases, especially if 2 things you want to alpha blend are allowed to intersect, since then there is no correct order unless you split the objects along the intersection. e.g had this playing around with some simple water and small piece of floating semi transparent ice, both using alpha. You need to draw the ice block below the water line first, then the water, then the part of the ice block above the water line. Didn't really solve it, although in that case make the ice not transparent at all was not a major loss.

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