View Full Version : Blending Problem
06-26-2011, 01:21 PM
I'm trying to use transparent textures in my application.
I've used the required procedures:
I'm using GL_RGBA texture formats, my glsl code is just a plain texture shader, and my objects are drawn in the right order. However I am still seeing two opaque objects. Have i missed anything out?
06-26-2011, 03:23 PM
So what happens if you force an alpha of 0.5 in your shader? That is, you just set the alpha component of the output color to 0.5, after you set the other three components with the value fetched from the texture.
06-27-2011, 12:25 AM
I just changed my fragment shader code to this:
gl_FragColor = texture2D(tex, gl_TexCoord.st);
gl_FragColor.a = 0.5;
And I get the same result.(Used the wrong shader :S)
I now get transparency, but my texture is 32bit and i used this code to create it:
glTexImage2D(GL_TEXTURE_2D, 0, 4, bmp->get_width(), bmp->get_height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, bmp->get_bytes());
So i should be getting alpha values from the texture shouldn't I.
06-27-2011, 12:39 AM
Then your problem has nothing to do with your texture. Blending isn't working for you for some reason. So put together a small test application that just draws two things, one on top of the other. Then get blending working so that the one on top is blended properly.
06-27-2011, 10:26 AM
Wow, I've been using my own texture file format (nothing special, just width, height, then 32bit pixel data) and I made a file converter. For some reason converting from a 32bit bitmap gives me a completely opaque texture, but converting from png gives me transparency. Anyway I have no problems with that.
EDIT: It seems I've ran into another problem. :(
All the triangles are oddly shaded. There's a picture attached. I'm almost certain that there are no problems with the normals.
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.