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

particles and depth testing

6 posts in this topic

First question:

 

My particle systems currently supports a few blend modes. For example: Additive, multiplicative or alpha blending.

 

Everything works fine so far, yet I am struggling with the actual understanding.

 

Lets take additive blending as an example and assume we are drawing two particles. Either Particle 1 (P1) or Particle 2 (P2) is drawn first. Which leads to one of the images shown below:

 

alpha_blending.png

 

On the right side is how it should look. The left side is how it shouldn't. The problem here is even though I use additive blending, which is for itself order independent, the output merger does some depth testing magic which results in the image shown on the left. The area T overlaps P2 and all fragments of P2 being removed (or never drawn). 

 

My question is why or how the output merger exactly performs that depth test. And how that error on the left side of the image can occur. I mean it is clear that it is the drawing order that causes the problem but how the rasterizer does the depth test per fragment is a mystery. 

 

I also know that if I disable depth write for my particles everything works fine since no fragments getting rejected.

----

 

Second question:

 

So far I have disabled depth writing for all blend modes but alpha blending. Since they are order independent blend modes. But now I am wondering if I even need depth writing for alpha blending. In fact I wonder if I ever need depth writing for any blend mode? Maybe it has some performance advantages?

Edited by me_12
0

Share this post


Link to post
Share on other sites


I also know that if I disable depth write for my particles everything works fine since no fragments getting rejected.

 

Yes, that's typically what you want to do. Disable depth write for drawing particles. Particles usually need alpha-blending, and the depth buffer doesn't exactly work well with that (since it only holds a single depth value).

1

Share this post


Link to post
Share on other sites

But now I am wondering if I even need depth writing for alpha blending. In fact I wonder if I ever need depth writing for any blend mode? Maybe it has some performance advantages?

Particles should be treated like any other translucent object. Generally that implies depth-writing is disabled. Enabling it often results in artifacts, particularly when translucent objects overlap.

Where performance is concerned, you should be batching as many particles from a single emitter as you can into a single draw call. An updating bounding box around that entire set of particles improves culling and gives you reasonable sorting (back-to-front) capabilities. That means you are sorting by close-together groups of individual particles rather than by individual particles, which means you don’t sort on a per-particle basis (highly discouraged for real-time applications) but close enough.


L. Spiro
2

Share this post


Link to post
Share on other sites

Thank you for your replies.

 

Where performance is concerned, you should be batching as many particles from a single emitter as you can into a single draw call. An updating bounding box around that entire set of particles improves culling and gives you reasonable sorting (back-to-front) capabilities. That means you are sorting by close-together groups of individual particles rather than by individual particles, which means you don’t sort on a per-particle basis (highly discouraged for real-time applications) but close enough.

 

I am always drawing all particles per emitter in a single draw call. I never heard about using bounding boxes for particle sorting, but it sounds interesting.

 

Anyways, what I meant with performance is that, if I have the particles sorted anyways for an order dependent blending like alpha blending,I might as well activate depth writing. This would not produce any artifacts since the particles are drawn in correct order. Yet I still wonder if it has any advantage? Like maybe some fragments getting rejected in step 1 and don't have to be blended in step 2?

0

Share this post


Link to post
Share on other sites

* Disabling depth testing means that the depth buffer doesn't have to be read/written, which slightly reduces your bandwidth per-pixel (save a 24bit read+write per pixel).
* Disabling depth writing means that the depth buffer doesn't have to be written, which (even more) slightly reduces your bandwidth per-pixel (save a 24bit write per pixel).
* Enabling depth testing will also enable "early Z" / "HiZ" on modern GPU's (assuming that alpha-testing or shader discard/clip statements aren't used -- these features kill early Z). This allows the depth test to occur before the pixel shader is executed (technically the GPU is supposed to waste time executing the pixel shader, then throwing away the results if the depth-test fails -- 'early Z' fixes this), and the pixel shader is skipped if that pixel doesn't have to be drawn. However, this is only an advantage when rendering opaque geometry from front-to-back -- it is of no use when rendering translucent geometry from back-to-front.

 

Oh nice! Thank you that is what I was waiting for.

0

Share this post


Link to post
Share on other sites

* Disabling depth testing means that the depth buffer doesn't have to be read/written, which slightly reduces your bandwidth per-pixel (save a 24bit read+write per pixel).
* Disabling depth writing means that the depth buffer doesn't have to be written, which (even more) slightly reduces your bandwidth per-pixel (save a 24bit write per pixel).


I'm pretty certain that on anything released in the last few years this would be a 32bit read/write; certainly on GCN as depth and stencil are stored seperately so a D24_S8 format takes up the same memory as a D32_S8 one where depth and stencil are stored as seperate chunks of memory.

(Which doesn't dispute your points, just highlights the extra savings).
2

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