I'm trying to get a translucent emissive surface. Without blending I
can get an emissive surface OK, but with blending enabled I dont get
what I expect. I start with -
GLfloat mat_amb[] = { 0.0, 0.0, 0.0, 0.0 };
GLfloat mat_diff[] = { 0.0, 0.0, 0.0, 0.0 };
glMaterialfv(GL_FRONT, GL_AMBIENT, mat_amb);
glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diff);
GLfloat mat_specular[] = { 0.0, 0.0, 0.0, 0.0 };
GLfloat em[] = {1.0, 0.0,0.0, 1.0};
glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
glMaterialfv(GL_FRONT, GL_EMISSION, em);
to get a pure red purely emissive surface which works fine. But if I
say
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
I see nothing, while if I alter the alpha of the diffuse part :
GLfloat mat_diff[] = { 0.0, 0.0, 0.0, 1.0 };
I can see it again (I have lighting enabled but no lights switched
on).
I cant interpret this behaviour - clearly I'm missing something.
|
|
0
|
|
|
|
Reply
|
w
|
10/12/2004 9:13:36 AM |
|
Walter Milner wrote:
> I'm trying to get a translucent emissive surface. Without blending I
> can get an emissive surface OK, but with blending enabled I dont get
> what I expect. I start with -
>
> GLfloat mat_amb[] = { 0.0, 0.0, 0.0, 0.0 };
> GLfloat mat_diff[] = { 0.0, 0.0, 0.0, 0.0 };
> glMaterialfv(GL_FRONT, GL_AMBIENT, mat_amb);
> glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diff);
> GLfloat mat_specular[] = { 0.0, 0.0, 0.0, 0.0 };
> GLfloat em[] = {1.0, 0.0,0.0, 1.0};
> glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
> glMaterialfv(GL_FRONT, GL_EMISSION, em);
>
> to get a pure red purely emissive surface which works fine. But if I
> say
>
> glEnable(GL_BLEND);
> glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
>
> I see nothing, while if I alter the alpha of the diffuse part :
>
> GLfloat mat_diff[] = { 0.0, 0.0, 0.0, 1.0 };
>
> I can see it again (I have lighting enabled but no lights switched
> on).
>
> I cant interpret this behaviour - clearly I'm missing something.
The OpenGL spec says that the alpha value comes from the diffuse
material coefficient when lighting is enabled.
So -- you figured it out!
--
Andy V
|
|
0
|
|
|
|
Reply
|
Andy
|
10/12/2004 10:39:10 PM
|
|
OK - experiment confirms this, and it makes sense. But I can't find
it, either in the Red Book or in the GL Spec, under GL_BLEND or
glBlendFunc or things to do with lighting. Where is it?
BTW will this pseudo-code work..
enable depth test
clear depth buffer
draw stuff, with z-buffer algorithm making near polygons obscure far
ones
enable blending
draw stuff, things on top of each other are blended
disable blending
draw stuff, again with z-buffer algorithm making near polygons obscure
far ones
ie can I sequentially turn blending on and off?
|
|
0
|
|
|
|
Reply
|
w
|
10/13/2004 8:53:04 AM
|
|
Walter Milner wrote:
> OK - experiment confirms this, and it makes sense. But I can't find
> it, either in the Red Book or in the GL Spec, under GL_BLEND or
> glBlendFunc or things to do with lighting. Where is it?
>
> BTW will this pseudo-code work..
>
> enable depth test
> clear depth buffer
> draw stuff, with z-buffer algorithm making near polygons obscure far
> ones
> enable blending
Generally you also want to leave depth test enabled, and some would say
to disable writing to the depth buffer, using glDepthMask(GL_FALSE).
However, the usual blend (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) requires
you to render in strict back-to-front order anyhow.
> draw stuff, things on top of each other are blended
> disable blending
> draw stuff, again with z-buffer algorithm making near polygons obscure
> far ones
>
> ie can I sequentially turn blending on and off?
You can. However, if your new (opaque) geometry shows up behind a
blended (translucent) object and in front of an old opaque object:
eye -> Translucent-object -> New-Opaque -> Old-Opaque
Then you cannot get the right result -- if you don't disable depth
writing, New-Opaque will not be drawn. If you do disable depth writing,
Translucent-object will be incorrectly replaced with New-Opaque.
--
Andy V
|
|
0
|
|
|
|
Reply
|
Andy
|
10/14/2004 12:30:31 AM
|
|
|
3 Replies
205 Views
(page loaded in 4.153 seconds)
Similiar Articles: Enable/Disable Material - comp.graphics.api.openglWith lighting enabled material-colors control the color. With lighting and glcolor-material ... Blending in OpenGL - comp.graphics.api.opengl Enable/Disable Material - comp ... Blending in OpenGL - comp.graphics.api.openglHello everyone, I am trying to use blending in OpenGL. ... Rendering Shafts of Light - comp.graphics.api.opengl ... NOTE: This page contains old archived material and may ... Alpha with Textures - comp.graphics.api.openglMy blending function is (GL_ONE, GL_ONE_MINUS_SRC_ALPHA ... you should try to use multi texture : texture & light ... your own alpha textures, for creating custom material and ... Surface preset window text colour - comp.graphics.apps.lightwave ...Alpha blending with depth buffer - comp.graphics.api.opengl ... With "surface" I mean ... To change the color of 3D overlays like material and ... image in which lighter ... Sampling: What Nyquist Didn't Say, and What to Do About It - comp ...Harmonics from SCR >(or triac) based light dimmers likely get into the MHz range ... levels to reduce discontinuity, and finally a new image is constructed with blending ... [comp.publish.cdrom] CD-Recordable FAQ, Part 1/4 - comp.publish ...Archive-name: cdrom/cd-recordable/part1 Posting-Frequency: monthly Last-modified: 2008/10/09 Version: 2.71 Send corrections and updates to And... display lists - comp.graphics.api.openglThen I have all the material info > > including textures ... glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_BLEND ... I was wasting time during my lighting code. <snip ... OpenGL - Lighting - Nanyang Technological University, Singapore ...OpenGL LIghting, Materials and Blending. Last modified: August, 2009. Lighting. The color that we see in the real world is the result of the interaction between the ... OpenGL FAQ / 15 Transparency, Translucency, and Using Blending15 Transparency, Translucency, and Blending. 15.010 What is the difference between ... ambient and diffuse material colors to black, and your specular material and light ... 7/9/2012 11:25:39 AM
|