HelloMaterial Leak-through fails

I have been working my way through the tutorials and got to HelloMaterial. I’m using the May 26 nightly build of jME3. It all works beautifully, except that the cube with base color “leaking” through leaks wrong. The screen shot on the tutorial wiki page shows a white cube with a magenta monkey graphic. The tutorial as posted produces a magenta cube with a gray/black monkey.

After scratching my head, spending several hours playing around with variations on the code, I found the source history on code.google.com. It seems that r9192 changed line 83 from a material based on ColoredTextured.j3md to one based on Unshaded.j3md. I changed my code to use ColoredTextured.j3md and lo, I now see the white cube with the magenta monkey.

I don’t know why that line was changed (way back in Feb 2012), but I respectfully suggest it be reverted.

Thanks!

Pretty sure that ColoredTextured was deprecated and replaced with Unshaded in general.

I don’t know what settings on Unshaded are needed to produce the same results but that’s where the real issue is with that tutorial, I believe.

I think you’re correct about ColoredTextured being deprecated. That’s what the commit comment says, anyway. I’m new here, so I don’t have the historical memory.

I don’t believe, though, that the fault lies in the tutorial. For example, in the advanced documentation there is a page about How to Use Material Definitions (.j3md). Its advice is consistent with the tutorial, i.e. set the ColorMap and the Color and the leak-through will just happen. But the problem is that when Unshaded is used in that manner, the leak-through happens in the white, not the black. In other words, and this may be just me jumping to conclusions, it would appear that Unshaded is interpreting the alpha in the inverse, or at least in the inverse of what ColoredTextured does.

In any case, I’m really enjoying learning about jME3. Thanks for the extensive documentation. I’ve now made it through the entire tutorial series with only one other major problem, and the forum already had a post about it.

(deleted due to author confusion)

(deleted due to author confusion)

It could also be that the tutorials results are what was given at the time and not actually what the expected behavior is… or anyway not desirable for some other reason.

I think with Unshaded, Color will tint the non-alpha portions of the texture. It is mutiplied by the texture values.

…so, I looked at the source image and the one in question has alpha where the monkey is. I guess this used to bleed through the color but not the colors are simply multiplied together.

There is no supported shader that does the old bleed-through effect and I’m not sure it’s entirely necessary. Someone else closer to the shaders would have to say whether maybe this mode should be added. It would be a simple change.

mhh ok…it seems that coloredtextured was mixing the color with the texture in regard of the texture alpha value…
The unshaded material just multiplies the color with the texture.

I guess we’d better update the tutorial so that the screen shot is consistent with what the tutorial produce.

Guess the tutorial grew more and more outdated. This ColoredTextured used to be a feature (as described), and it changed many times (was depricated, and later possibly black and white swapped). I’ll rewrite it…

Yeah, the multiply is more useful in most cases (I use it myself in several places) but I can see use cases for the other behaviour too. The thing is the other behaviour is still possible, just not using the unshaded shader.

Really this is a case for shader nodes, when they come in fully you would be able to have a “color mix” node and use that instead of the “color multiply” node and get the old behaviour.

OK, I updated https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:beginner:hello_material and the Code Palette in the SDK (will be in next dev build) and the code in jme3test.helloworld in the engine. Please tell me if I missed something…

2 Likes

Sigh
https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:jme3_shadernodes
Shader Nodes require roughly 12876 steps to work. X-) Not suitable for a beginners’ tutorial. The old method was easier. :stuck_out_tongue:

I’ll make a video tutorial when all is done on how to do that with shader nodes in no time with the SDK, promise!
For now the main objective is release

Yeah - the thing is shader nodes all get hidden behind the material - so in fact its just the same as before - select unshaded material and all the node stuff is done behind the scenes for you.

It’s only if you care that it matters.