views:

236

answers:

1

I was wondering why the fog i use in opengl es on my android phone isn't transparent when i set the colors alpha to 0. I set the background to transparent and it works fine and the Color class or the toFloatBuffer() method are working fine for my meshes but when i set the fog color to transparent then this fact is ignored. here is the basic code i use for fog in the onSurfaceCreated() method of my renderer:

gl.glFogf(GL10.GL_FOG_MODE, GL10.GL_LINEAR);
gl.glFogf(GL10.GL_FOG_START, 4.0f);
gl.glFogf(GL10.GL_FOG_END, 10.0f);
gl.glFogfv(GL10.GL_FOG_COLOR, new Color(0,0,0,0).toFloatBuffer());
gl.glEnable(GL10.GL_FOG);
+1  A: 

This is the expected behavior. Fixed-function fog in OpenGL and OpenGL ES only changes the final R, G, and B components of the fragment. The A component is left untouched (i.e. the A component of GL_FOG_COLOR is unused).

Pivot
ok thanks, is there a way to use this fog effect additionally on the alpha channel? i could do it on my own by calculation the objects distance to the camera but i hoped it would be possible to use the fog effect for this.
Sponge
Not really—that's just how the behavior is defined in OpenGL ES 1.1. Are you trying to fade arbitrary content out over an arbitrary background, or is the set of cases you need to handle more limited?
Pivot
the first one, im trying to fade out content and the fog would be exactly what i need :/
Sponge