Texture Opacity

Started by Hsaka, April 15, 2009, 08:08:57 AM

Previous topic - Next topic

Hsaka

Hi. I have a tile map made by blitting a set of textures onto the screen. I'm trying to place a textured plane onto the map. The texture image is a png file with an alpha channel:
http://img12.imageshack.us/my.php?image=build1.png



I use this to create the texture:
game.getTextureManager().addTexture("build1", new Texture("res/build1.png",true));

I'd like the opaque areas of the texture to remain opaque on the textured plane. However, this is what I get:
http://img12.imageshack.us/my.php?image=83972871.png

plane.setTransparency(-1);

http://img22.imageshack.us/my.php?image=76106834.png

plane.setTransparency(0);

http://img11.imageshack.us/my.php?image=43452437.png

plane.setTransparency(0);
plane.setTransparencyMode(Object3D.TRANSPARENCY_MODE_ADD);


Any help will be appreciated.

EgonOlsen

Looks to me as if some light source, ambient light or additional color lights up the plane...

EgonOlsen

#2
..or maybe RGB-Scaling is active? Why is the building a plane at all? Why don't you blit it like the rest of the map?

fireside

I've found something like this with my game, which is in software mode.  The billboard trees look pretty opaque unless I put a creature behind them and then I can see translucency in the texture.
click here->Fireside 7 Games<-

EgonOlsen

Oh, i thought the problem was that everything is so bright...i should have read your post better. Just use a higher transparency setting like 10 or 15 and the opaque parts should be opaque.

Hsaka

Thanks for the quick answers guys.

As it turns out, I was drawing in the wrong order. I had something like this:

buffer.clear(java.awt.Color.BLACK);               
world.renderScene(buffer);               
world.draw(buffer);               
buffer.update();
...
currentMap.render(buffer);


Now I've changed it to this:

buffer.clear(java.awt.Color.BLACK);               
world.renderScene(buffer);   
currentMap.render(buffer);           
world.draw(buffer);               
buffer.update();
...


Is there any problem if I do this? Then reason I ask is because my map will now not show for a short while (I suspect until all the Object3Ds in the world are displayed), and this:
"renderScene: When using the OpenGL renderer, this method has to be called at least once before blitting into the OpenGL FrameBuffer will work correctly. If you are not abusing jPCT as a pure 2D blitting engine, then this shouldn't be a problem anyway."

QuoteWhy is the building a plane at all? Why don't you blit it like the rest of the map?
I'm building a 2D RTS, and I'd like the buildings to be built anywhere on the map, and I think I'm pretty close to abusing jPCT as a blitting engine  ;D

EgonOlsen

Order is fine. Blitting in OpenGL-mode may not work until one render pass has been completed. You may try to place some renderScene()/draw()-call before your actual game loop just to warm up things. That may help with the map. I'm a bit confused about your former order and the actual outcome. I would have expected something else, but as long as it works now, all is fine i guess.

Hsaka

Thanks Egon.

In the former order, the map was blitted with transparency, so that was why I could still see the planes through the map even though the map was being blitted on top of the planes.