PDA

View Full Version : How to disable transparent textures for an object?



mobilevisuals
06-30-2011, 07:48 AM
One object should be displayed in front of 2 objects with transparent textures. The object in front should not be transparent, but I can not disable transparent textures for that object. I try with

gl.glColor4f(0.7f, 0.7f, 0.7f, 1f); and

gl.glDisable(GL10.GL_BLEND);

This has however no effect and the object in front is still
transparent. What should I do to disable transparent textures for this object? I am developing for Android.

BionicBytes
06-30-2011, 09:09 AM
The only way to get transparency is via blend operations.
The effect could be similarly achieved via the use of shaders - eg refraction shader which then 'blends' the off-screen refraction texture with the objects texture - but you would surely know if you were doing this kind of thing.

Looks like there is more to your code than perhaps you realise and blending is still being enabled some where along the rendering pipeline.

mobilevisuals
07-04-2011, 07:19 AM
I have gone through the code, and I found that the reason for the problem is that objects get blended together, even if one opaque object is in front of a transparent one. This picture shows how it looks like:

http://www.mobile-visuals.com/transCP.png

The sphere on the picture is behind the morphing object, so they shouldn't be blended together. I don't know why this happens, because I have enabled DEPTH_TEST with

gl.glClearDepthf(1.0f);
gl.glEnable(GL10.GL_DEPTH_TEST);
gl.glDepthFunc(GL10.GL_LEQUAL);

Do you know what I can try to get this to work?
This is the other method calls, which could have an effect on the transparency:

gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
gl.glEnable(GL10.GL_TEXTURE_2D); gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY );
GLU.gluPerspective(gl, 45.0f, (float) width / (float) height, 0.1f,39000.0f);
gl.glEnable(GL10.GL_BLEND); gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE);
glSurfaceView.setEGLConfigChooser(8, 8, 8, 8, 0, 0); glSurfaceView.getHolder().setFormat(PixelFormat.RG BA_8888);