Is there a way to automatically disable writing to the depth buffer if
the incoming fragment alpha is less than 1.0?
I want this to happen in 1 pass. I don't want to do:
glDepthMask(GL_TRUE)
glEnable(GL_ALPHA_TEST)
glAlphaFunc(GL_EQUAL, 1.0)
// render pass 1
glAlphaFunc(GL_LESS, 1.0)
glDepthMask(GL_FALSE)
// render pass 2
Thanks.
|
|
0
|
|
|
|
Reply
|
Bar
|
7/29/2003 11:14:29 PM |
|
Bar Code wrote:
> Is there a way to automatically disable writing to the depth buffer if
> the incoming fragment alpha is less than 1.0?
>
> I want this to happen in 1 pass. I don't want to do:
>
> glDepthMask(GL_TRUE)
> glEnable(GL_ALPHA_TEST)
> glAlphaFunc(GL_EQUAL, 1.0)
> // render pass 1
>
> glAlphaFunc(GL_LESS, 1.0)
> glDepthMask(GL_FALSE)
> // render pass 2
>
I don't think this is possible. Maybe with a fragment
program.
--
<\___/> For email, remove my socks.
/ O O \
\_____/ FTB. Why isn't there mouse-flavored cat food?
|
|
0
|
|
|
|
Reply
|
fungus
|
7/30/2003 7:42:05 AM
|
|
You need to split your geometry in 2 separate parts.
* First part contains all the opaque geometry, the one that will be
rendered using alpha testing, and will set depth buffer, for the alpha
value you wish. Frequently, this is the geometry that has no alpha
material, but you can put in it some fragments that you want ot be
alpha tested.
* Second part will contain translucent geometry, depth buffer writes
disabled. this is when you render alpha blended meshes.
This is not 2 pass rendering, this is simply rendering 2 halfs with
different settings.
SeskaPeel.
Bar Code <barcode@barcode.com> wrote in message news:<3F271615.3829C258@barcode.com>...
> Is there a way to automatically disable writing to the depth buffer if
> the incoming fragment alpha is less than 1.0?
>
> I want this to happen in 1 pass. I don't want to do:
>
> glDepthMask(GL_TRUE)
> glEnable(GL_ALPHA_TEST)
> glAlphaFunc(GL_EQUAL, 1.0)
> // render pass 1
>
> glAlphaFunc(GL_LESS, 1.0)
> glDepthMask(GL_FALSE)
> // render pass 2
>
>
> Thanks.
|
|
0
|
|
|
|
Reply
|
seskapeel
|
7/31/2003 11:22:02 AM
|
|
Thank you very much for your reply. But it would be very hard to keep track of which
objects are translucent, especially if textured objects are involved. I wish each
fragment could be blended and have z-buffer writes disabled if alpha was < 1.0.
Thanks again.
SeskaPeel wrote:
> You need to split your geometry in 2 separate parts.
>
> * First part contains all the opaque geometry, the one that will be
> rendered using alpha testing, and will set depth buffer, for the alpha
> value you wish. Frequently, this is the geometry that has no alpha
> material, but you can put in it some fragments that you want ot be
> alpha tested.
>
> * Second part will contain translucent geometry, depth buffer writes
> disabled. this is when you render alpha blended meshes.
>
> This is not 2 pass rendering, this is simply rendering 2 halfs with
> different settings.
>
> SeskaPeel.
>
> Bar Code <barcode@barcode.com> wrote in message news:<3F271615.3829C258@barcode.com>...
> > Is there a way to automatically disable writing to the depth buffer if
> > the incoming fragment alpha is less than 1.0?
> >
> > I want this to happen in 1 pass. I don't want to do:
> >
> > glDepthMask(GL_TRUE)
> > glEnable(GL_ALPHA_TEST)
> > glAlphaFunc(GL_EQUAL, 1.0)
> > // render pass 1
> >
> > glAlphaFunc(GL_LESS, 1.0)
> > glDepthMask(GL_FALSE)
> > // render pass 2
> >
> >
> > Thanks.
|
|
0
|
|
|
|
Reply
|
Bar
|
7/31/2003 10:16:02 PM
|
|
Draw in 2 passes;
pass 1; set alpha test accept only alpha = 1.0. This will update your Z
buffer and draw
the opaque bits only.
pass2: set alpha test accept alpha < 1.0, z buffer writes disabled. Just the
clear bits get
drawn.
"Bar Code" <barcode@barcode.com> wrote in message
news:3F29AB66.84E50B74@barcode.com...
> Thank you very much for your reply. But it would be very hard to keep
track of which
> objects are translucent, especially if textured objects are involved. I
wish each
> fragment could be blended and have z-buffer writes disabled if alpha was <
1.0.
>
> Thanks again.
>
>
>
> SeskaPeel wrote:
>
> > You need to split your geometry in 2 separate parts.
> >
> > * First part contains all the opaque geometry, the one that will be
> > rendered using alpha testing, and will set depth buffer, for the alpha
> > value you wish. Frequently, this is the geometry that has no alpha
> > material, but you can put in it some fragments that you want ot be
> > alpha tested.
> >
> > * Second part will contain translucent geometry, depth buffer writes
> > disabled. this is when you render alpha blended meshes.
> >
> > This is not 2 pass rendering, this is simply rendering 2 halfs with
> > different settings.
> >
> > SeskaPeel.
> >
> > Bar Code <barcode@barcode.com> wrote in message
news:<3F271615.3829C258@barcode.com>...
> > > Is there a way to automatically disable writing to the depth buffer if
> > > the incoming fragment alpha is less than 1.0?
> > >
> > > I want this to happen in 1 pass. I don't want to do:
> > >
> > > glDepthMask(GL_TRUE)
> > > glEnable(GL_ALPHA_TEST)
> > > glAlphaFunc(GL_EQUAL, 1.0)
> > > // render pass 1
> > >
> > > glAlphaFunc(GL_LESS, 1.0)
> > > glDepthMask(GL_FALSE)
> > > // render pass 2
> > >
> > >
> > > Thanks.
>
|
|
0
|
|
|
|
Reply
|
JB
|
8/1/2003 2:15:34 AM
|
|
> Thank you very much for your reply. But it would be very hard to keep track of which
> objects are translucent, especially if textured objects are involved. I wish each
> fragment could be blended and have z-buffer writes disabled if alpha was < 1.0.
>
> Thanks again.
As long as your object are not morphing from one texture to antoher,
this is not difficult. In your scene graph, preparse before first
rendering, and update a boolean in your object class that indicates if
object must be rendered alpha tested or alpha blended.
Then when rendering, parse 2 times your scene graph, first rendering
only object with the boolean set to false, and second all the objects
that have the boolean set to true. Don't forget to update OpenGL
states on blending and depth writes between those two parses (note
this is a parse, not a rendering pass, you never redner the same
geometry twice).
SeskaPeel.
|
|
0
|
|
|
|
Reply
|
seskapeel
|
8/1/2003 10:03:37 AM
|
|
"Alex Mizrahi" <pmiz@etel.dn.ua> wrote in message news:<bgejua$o0kkm$1@ID-177567.news.uni-berlin.de>...
[..]
> you're doing this to work with translucent objects? but in this case
> back-to-front soring is needed, or just render opaque objects first, and
> translucent after them. otherwise you'll get some translucent objects
> obscured by opaque even if they are farther.
> so, two traverses through scene hierarchy is much faster/easier than
> back-to-front sorting.
However even with a two pass rendering (first all opaque objects,
second all translucent ones) you've to sort all the translucent
objects in the second pass from back to front, don't you?
If so, is it ok to just sort the objects, of do you have to sort their
"surfaces" (polygons), too? I think the latter one is neccessary, but
don't know.
-ric
|
|
0
|
|
|
|
Reply
|
Rivarson
|
8/2/2003 7:48:37 AM
|
|
Hello, Richard!
You wrote on 2 Aug 2003 00:48:37 -0700:
>> you're doing this to work with translucent objects? but in this case
>> back-to-front soring is needed, or just render opaque objects first,
>> and translucent after them. otherwise you'll get some translucent
>> objects obscured by opaque even if they are farther.
>> so, two traverses through scene hierarchy is much faster/easier than
>> back-to-front sorting.
RI> However even with a two pass rendering (first all opaque objects,
RI> second all translucent ones) you've to sort all the translucent
RI> objects in the second pass from back to front, don't you?
i should do it to get real correct blending. but:
1)i can have order-independent blending mode like (GL_SRC_ALPHA, GL_ONE), or
all transparent objects of same color and alpha
2)OpenGL transparency in no way is a real-world transparency. in real world
if you'll see through 2 lightfilters you'll see darkness. in OpenGL you'll
see mixed color.
so if you dont sort you'll just have some artefacts, that will be most
likely imperceptible, and you cant tell that absence of this artefacts makes
scene more real.
but if you'll dont brake scene in two parts, there will be great artefacts -
transparent objects sometimes disappearing.
RI> If so, is it ok to just sort the objects, of do you have to sort
RI> their "surfaces" (polygons), too? I think the latter one is
RI> neccessary, but don't know.
it's neccessary if there are non-convex objects(volume-convex meant).
With best regards, Alex Mizrahi aka killer_storm.
|
|
0
|
|
|
|
Reply
|
Alex
|
8/2/2003 2:18:25 PM
|
|
Richard Ivarson wrote:
>However even with a two pass rendering (first all opaque objects,
>second all translucent ones) you've to sort all the translucent
>objects in the second pass from back to front, don't you?
>If so, is it ok to just sort the objects, of do you have to sort their
>"surfaces" (polygons), too? I think the latter one is neccessary, but
>don't know.
>
>-ric
>
>
You only need to sort translucent polygons when they share pixels. If
objects are
disjoint on the screen, it doesn't matter. This seems like a great place
for a tiling
approach.
For arbitrary geometry you need to break things down into planar polygons
(triangles being the simplest) and sort those. However, this "painters
sort"
algorithm will not produce the right result when triangles cannot be sorted
into a strict back to front ordering, which is possible with two
triangles that
intersect. In this case, you need to break up the triangles into pieces
and sort
and render the pieces.
If, however, the blending mode isn't affected by order, then you don't
need to sort.
(GL_SOURCE_ALPHA, GL_ONE) is such a blending mode. Unfortunately
that isn't the right blending mode.
Finally, if you don't care if the polygons are rendered in the wrong order,
don't bother sorting.
--
Andy V
|
|
0
|
|
|
|
Reply
|
Andy
|
8/2/2003 9:35:33 PM
|
|
If you want to write in the color buffer in both situations, you have to
do it in two passes.
In OpenGL, once the fragment "passes", it writes all the buffers where
writing is enabled, and those enables can't be activated/deactivated at
the pixel level. It's at the primitive level at best, so you have to
perform multiple passes at best.
Vincent
Bar Code wrote:
> Is there a way to automatically disable writing to the depth buffer if
> the incoming fragment alpha is less than 1.0?
>
> I want this to happen in 1 pass. I don't want to do:
>
> glDepthMask(GL_TRUE)
> glEnable(GL_ALPHA_TEST)
> glAlphaFunc(GL_EQUAL, 1.0)
> // render pass 1
>
> glAlphaFunc(GL_LESS, 1.0)
> glDepthMask(GL_FALSE)
> // render pass 2
>
> Thanks.
|
|
0
|
|
|
|
Reply
|
Vincent
|
8/5/2003 7:44:32 AM
|
|
|
9 Replies
144 Views
(page loaded in 0.141 seconds)
|