[Solved] Problem creating transparent spatials

Well, after reading this

I’ve tried implementing transparency for some of my spatials in my demo code… but with

no success so far.

I’ve set the colors of the material state with an alpha value of 0.5f… set the render state

of the spatial to the material state and the alpha state… but still no transparency.

Maybe this is because I derived my main class from “BaseGame” and I’m missing something

in the render/update or initialization routines?

EDIT: Oh man…

Just realized that you HAVE to set a TextureState with an “alpha texture”… Sorry.

So MaterialState + AlphaState is not enough…

EDIT2: Removed “[solved]” from subject… still some issues…

TestRenderQueue uses just alpha and material to do transparent cubes, so it may just be your settings.

renanse said:

TestRenderQueue uses just alpha and material to do transparent cubes, so it may just be your settings.

Hmmm, maybe...

Texture-wise I realized here that i just have some kind of on/off transparency.. it looks like
something is either total transparent or fully opaque... nothing in between..
even if my texture (png file) has semi-transparent regions..
But this may be a PNG problem.. (?)

can you post your code for setting up the alphastate etc?

Yup, will do that later (I'm at work at the moment…) :slight_smile:

Well, here comes the code…

                // Point to the Player texture that has a built-in alpha channel.
      URL squareTextureLoc = Player.class.getClassLoader().getResource("as_ex_lightning.png");
      // Get my TextureState
      TextureState ts1=display.getRenderer().createTextureState();
      // Get my Texture
      Texture t1=TextureManager.loadTexture(squareTextureLoc,Texture.MM_LINEAR,Texture.FM_LINEAR, 20f, true);
      // Set a wrap for my texture so it repeats
      // Set the texture to the TextureState
           // Create an alpha state for the square.
      AlphaState as = display.getRenderer().createAlphaState();
      // Blend between the source and destination functions.
      // Set the source function setting.
      // Set the destination function setting.
      // Enable the test.

I'm creating a kind of pong game, and the walls DO react
to a png transparency mask (?).. but the player (a capsule spatial) only if the transparency
is either at 100 percent or 0....

See here for a screenshot
with a transparency texture for the player, texture state and alpha state has been set.

Is the ball supposed to be in front of that black box then?

I guess you mean the capsule (which is the "racket") at the front?

The ball should be BEHIND that capsule, but i thought it should shine through…

(if the texture has full transparency, it works… but not with a transparency between

0 and 100 percent.)

I will make additional screenshots, they should be clearer…

Actually, I seem to be having a similar problem myself, though transparency in .png files shows up no problem.  What I can't do is get the texture transparency (for a Quad subclass) to fade gradually from opaque to invisible.  Also, alpha testing is off.

//AlphaState AS;
AS = display.getRenderer().createAlphaState();

Seems to be appropriate, right?
oliver1974 said:
(Hmm, I think i will rip the sourcecode for a smaller example which can be posted here..)

That would be great... you'll get less shot in the dark type answers. :P

Okay, the solution is…

player.setRenderQueueMode (Renderer.QUEUE_TRANSPARENT);

…damned. So easy.