Transparent Materials and Background in Scene

Hey Guys,

I am pretty new at all this and I have two question bothering me.
About my Project: It may sounds silly, but I am realizing a 2D Game in JME. I managed that with disabling the FlyCam and setting the z-Values of my Shapes to 0.

It worked just fine until now, but I have one question and one problem right now.

Problem:

I have two Geometrys which Materials are PNG-Textures. Both Materials are declared like this, just with two different PNGs

obstacle = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
	obstacle.setTexture("ColorMap", app.getAssetManager().loadTexture("Obstacle-01.png"));

After that, I set the Translation of the two Geos like this

obstacleGeo.setLocalTranslation(6 , 1.75f, -2);
groundGeo.setLocalTranslation(6, 1.75f, -3);

The obstacleGeo lays on the groundGeo, like it was planed. The Texture of the obstacleGeo is transparent at some points (why I used PNGs), but at the Transparent parts of the obstacleGeo I don’t see the underlaying groundGeo, I am just seeing black (like the Background).

Soo, where is my mistake? Does JME not accept transparent Textures? Do I have to declare the Material in a special way so it becomes transparent?

My second question is a bit easier I guess: How can I set the Visual Background. It is black all the time, and I thought about setting a Geo with the screen Size in a node behind all nodes with a PNG-Texture, but I guess there is a more elegant way to do that.

I am sorry that I post two questions at once, but I thought maybe the transparent problem is somehow related to the background question.

Thank you guys for the help, cheers!

Did you also do:

obstacle.getAdditionalRenderState().setBlendMode(BlendMode.Alpha); // activate transparency
obstacleGeo.setQueueBucket(Bucket.Transparent);
1 Like

Awesome! Worked! :slight_smile:
Do you know any Tutorial or something which explains the BlendModes and what a QueueBucket is?

Is there a chance that you know any solution to my background problem?

Yes, the wiki!

And are you using the guinode instead of the rootNode?

Your Solution for the Background is probably the best and easiest approach. 3d uses skyboxes etc but that will be wrong for 2d

No, I am using everything at rootNode. Whats the benefit of using GUI Node?

So I guess I was on the right path all along! Thank you!

One last question here: How can I get the Translation of the actual View? As I said, flyCam is disabled, and depending on the z-value object can be completely in the view or be cut out, filling the whole screen. How can I fit them in properly?

guiNode is 2D. Things are already setup for transparency (ie: no special bucket). Sorting is done strictly on Z order instead of “nearest point on bounding shape”, etc.

For 2D, the gui node is probably a better choice overall… or at least the gui bucket.

Edit:

Also, the gui node is not perspective… so you don’t have this issue.