View Full Version : Point Parameters Extension blending
04-23-2000, 12:59 AM
Hello out there!
Wenn I use the POINT PARAMETERS Extension to draw my GL_POINTS i have to disable DEPTH_TEST otherwise the Particles (or Points) are just black Squares with a colored filled circle in the center.
If i disable DEPTH_TEST the Black Square is blended nicely. But the Problem now is that the Particles won't fit in my geometry any more. ('caus I disabled GL_DEPTH_TEST)
Is there any possability to blend the Points without disabling DEPTH_TEST?
Perhaps using another BlendFunc?
(i use the GL_SRC_ALPHA and GL_ONE_MINUS_SRC_ALPHA settings - as used in the tutorial i have; it's one of Nates great Tutorials BTW)
Perhaps anyone knows how the Particle Effect in Quake 2 is achieved (I think JohnC did it with the Extension too !?)
Thanks in advance for any suggestions!
alpha blending for point primitives is needed to render antialiased GL_POINTS, and to correctly render alpha, you need to depth sort them!
render them from back to front, and you'll do good.
at least, this is the way i do for the leaves of my trees...
another way is to use the gl alpha test capability:
this will tell opengl to render pixels into the framebuffer only where the alpha values are > 0 (not transparent), so you'll finally draw only the circular shape of the point, and not the whole square.
i know it works, but i didn't give it a chance, so i don't know if it will look good http://www.opengl.org/discussion_boards/ubb/smile.gif
04-24-2000, 10:57 PM
Thanks for your help first of all.
I didn't have much time to check the boards lately thats why I didn't post earlier. I hope you will read this Message though http://www.opengl.org/discussion_boards/ubb/smile.gif
The GL_ALPHA_TEST trick works fine.
The only thing about it is that as you said the Point Primitives aren't blended as well as without GL_ALPHA_TEST.
So what I wanted to ask is what exactly was ment by depth sorting the Particles (or whatever)
Doesn't depth sorting in my case mean checkeng whether a Particle is visible from the point of view? Do i have to cast a ray from the viewer to each particle to see whether it hits any geometry or not, and only draw a particle when its ray is not blocked by any obstacle (=visible)
Maybe the whole idea is wrong but at least implementing my idea would cost a lot of CPU.
If i misunderstood what you ment by depth sorting (and i suggest i did http://www.opengl.org/discussion_boards/ubb/smile.gif please explain what you ment.
Thanks in Advance
about the alpha test, that's exactly what i supposed: since you are making a binary decision by thresholding the alpha value, you loose the fuzzy region where blending gives the best results... oh well...
about depth sort yes, the concept is right.
but you don't have to do ray tracing/collision/casting/whatever: just evaluate the depth value (z coord) of your particle with some math.
then, sort the drawing of the particles from back to front, and remember to disable GL_ALPHA_TEST and enable GL_DEPTH_TEST.
to quickly implement a working solution for depth sorting i would (or rather i'm using http://www.opengl.org/discussion_boards/ubb/smile.gif ) use c standard function qsort.
...maybe you understood yet why with your previous test there was a square shape around the point, but let me explain it the same.
opengl creates antialiased points with a 2-pass approach (loosely speaking: i don't mean it draw to the framebufer twice)
first, it creates a square shape with a solid color (the current glColor() state)
secont, it builds another square with the circular path, but instead storing a color, it stores a alpha value. that's why you need GL_BLEND enabled to render antialiased primitives.
then, when it's time to draw to the framebuffer, opengl transforms the vertex you passed between the glBegin()/glEnd() pair and obtain a eye-space point, wich has x,y and z coordinate.
opengl then blit the square to the framebuffer, and since this blitting operation follows the rules of any other opengl system call, if depth test is enabled, it draws to the screen only if the point is nearer than the current depth, wich is expressed by the depth buffer values at that point.
that's why you need to do depth sorting, with depth ordering from back to front.
at least, with a Q2-particle-style.
04-26-2000, 06:37 AM
It works now! And the good thing about it is, that I know why http://www.opengl.org/discussion_boards/ubb/smile.gif
Thanks a lot!
04-26-2000, 11:24 AM
> then, sort the drawing of the particles from back to front, and remember to disable GL_ALPHA_TEST and enable GL_DEPTH_TEST.
Also you have to disable writing into the depth buffer:
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.