particles and depth testing???

Started by
9 comments, last by mictian 20 years, 8 months ago
hail, in my particle system ( as well as in others i have studied ) depth testing is disabled to allow all particles to render and blend properly... i want to render particles but i want them to be occluded by objects in the foreground, how can i accomplish this?
¿We Create World?
Advertisement
when you render your room/terrain take the particle system as an entire entity. Then drawing from the back forward. When you reach your particle system, render it with depth test disabled, then continue drawing objects closer.

the simplist way to do this is to do a distance check on objects in your scene (quite CPU expensive).

it would help if i knew what rendering technique you''re using and what you are rendering. BSP, Portal, ? and Terrain, Indoors, ?
I burn cold
Hello,

a really good way is to disable z writes when rendering the particles. This way the particles are occluded by near objects, because of depth test, but they don't occlude farther objects, because the z values aren't stored.

Ciao, Thorris.

EDIT: correctness

[edited by - Thorris on August 14, 2003 5:50:43 AM]


The suggestion above will work. Generally you will want to render your opaque objects first with z-testing and z-writing on. Then you can turn off z-writing and render your transparent elements from a depth sorted list.
yup, wat the AP said is a proper way to do it. Remember, disabling depth-testing and disabling depth-writing are two different thing. Just in case (to be safe), here''s a brief rundown.

Depth-testing, i''m sure u know, is all about z-buffer usage. Without that, the z-buffer is completely disabled. Thus all objects will be displayed in order of rendering, irrespective of their position in the virtual scene.

Depth-writing is the current state of the z-buffer. By default it is enabled and thats how objects in front write over previous values IF the data in the z-buffer contains more ''distant'' objects. By disabling z-writing, any new objects will still be tested for depth accuracy and wont be drawn in the color buffer if they fail. But if they succeed, rendering will occur BUT these new objects will not update the existing state of the z-buffer.
- To learn, we share... Give some to take some -
The OpenGL command to enable/disable depth writing glDepthMask(true/false). Also remember: If you use additive blending like glBlendFunc(GL_SRC_ALPHA, GL_ONE) you do not need to sort your particles back to front. With all the other blending equations you will need to sort the particles.

Sander Maréchal
[Lone Wolves Game Development][RoboBlast][Articles][GD Emporium][Webdesign][E-mail]


GSACP: GameDev Society Against Crap Posting
To join: Put these lines in your signature and don''t post crap!

<hr />
Sander Marechal<small>[Lone Wolves][Hearts for GNOME][E-mail][Forum FAQ]</small>

thankyou all for your responses.

i have obtained the desired effect by a simple bubble sort to order all particles for back->front rendering. i render them last after other objects and with depth testing turned on, so as to allow other objects in the scene to occlude them, depth writing is also turned on, but due to the order of rendering it makes no difference.

i also do use additive blending as you mentioned, but sorting is in this case necessary as i left depth testing on
¿We Create World?
i would also me much obliged if you could tell me what fps you get from running my demo which is here:

http://people.umass.edu/rwhall/particle_demo.exe

( it is from the same workspace as an earlier demo, and i forgot to remove the check for the cubemapping extension, so if you have an old gpu it might give you an error about that )

i got 80fps on my 2.4ghz p4, but my friend on his athlon 1.2 got only 20 ( same GPU ), so i am wondering whether i need to optimize way more ( there is _plenty_ to be done...did i mention i bubble sorted heheheh ) also there is no occluder in this demo as i removed the metaballs, so the sort is not really necessary
¿We Create World?
why would I test your demo for performance, when you say it''s not done yet? How about finishing your demo, and THEN let people test it?
-----------------------------Amma
yeah thats true i suppose...just wondering how bad this section actually is though, i got a few of my friends to do it and they reported 40-50 on some old school-ish pentiums so i guess i am happy
¿We Create World?

This topic is closed to new replies.

Advertisement