Textures rendered black

I think there might be a problem with loading textures. Take a look at this:

Two screenshots from my game. On the left, the texture beneath the ball is called test2.png. On the right, the texture is called grid_normal.png. Apart from that, it is the exact same texture (and game code) on both sides - I just made a copy of grid_normal.png in Windows-Explorer and renamed it to test2.png.

This is my material code in case it matters:
[java]mat = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);
mat.setTexture(“ColorMap”, assetManager.loadTexture(“Textures/grid_normal.png”));
mat.getAdditionalRenderState().setBlendMode(BlendMode.Modulate);[/java]

Between the two screenshots, the only thing in code I changed is replacing “grid_normal” here with “test2”.
I’m using the latest jME code, compiled from SVN.

EDIT: if I don’t set the blend mode, both textures render properly, so it actually might be related to that somehow?

Reduce it to a simple test case and I bet you find your problem.

Thanks for reminding me, that’s really what I should have done in the first place :slight_smile:
Adding geo.setQueueBucket(RenderQueue.Bucket.Translucent); fixes it. Without that, the texture apparently sometimes gets blended with the viewport background. Still kinda curious why it only does that with some textures, but not with others - but anyhow, problem fixed I guess.

@Sebioff said: Thanks for reminding me, that's really what I should have done in the first place :) Adding geo.setQueueBucket(RenderQueue.Bucket.Translucent); fixes it. Without that, the texture apparently sometimes gets blended with the viewport background. Still kinda curious why it only does that with some textures, but not with others - but anyhow, problem fixed I guess.

It should never get blended with the viewport background in this way… unless you have a quad back there or something that is sorting ahead of it.

Thus I recommended the simple test case. If you post it then we can show you what might be wrong.

…wait a second… is the ball in front a quad with a texture on it?

If so then this is classic transparency z sorting problem. About 1 in 5 questions on the forum is ultimately about this issue.

@pspeed said: It should never get blended with the viewport background in this way… unless you have a quad back there or something that is sorting ahead of it.
Yeah...I think that's precisely it. I thought placing my textured quad slightly in front of my model would be enough to sort it right, but I just read your explanations in an older thread that this is not neccesarily true. Actually, I had the bucket code in before but removed it when it seemed to work without it :roll: As you can tell, I'm not extremely experienced with 3d stuff/jME yet, so thanks for bearing with me! It must be annoying to hear about the same problems over and over again (although I'm trying my best to not ask stuff that has been asked before).

If you are referring to the translucent bucket then it is not really a solution since that just forces that object to be rendered after everything else. It “fixes” the sorting problem by removing sorting.

Alpha threshold, etc. are more likely proper solutions in the long run.