To demarcate the edges of the canyons from the background, I’m trying to draw an outline (without texture). Now I wanted to soften this outline by making it slightly transparent. But that doesn’t work.
Do I have to load a small black dummy texture? Can I also use alpha without texture?
final Geometry triGeometry = new Geometry(geoName, triMesh);
final Material mat2 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); // create a simple
mat2.setColor("Color", new ColorRGBA(0.1f, 0.2f, 0, 0.1f));
mat2.getAdditionalRenderState().setBlendMode(BlendMode.Alpha); // activate transparency
it is possible for sure, i just looked at some code i had for semi-transparent color.
noticed i have:
along with queueBucket and blendMode, so probably this is missing. (tho wiki say nothing about it, maybe because its auto-setup when setting png texture?)
also im using custom shader, but its almost like unshaded one.
also setting cullHint to never, but it should not matter.
also generating tangents, but it should not matter.
also im using parallel viewport for it with clear flags: false, true, false, but it should not matter.
I’ve literally never called this method in any code that I can think of but I have transparent textures all the time.
99.9999999% of the time of “I have transparency but it’s not transparent” it’s because blend mode isn’t set to alpha. I guess some tiny fraction of those times could also be not putting the object in the transparent bucket and it sorts weird and so looks non-transparent.
Both of which seem to be done in the code snippet. Though without a single class test case illustrating the problem it’s hard to tell if it’s really the issue.
Note that the 0.1 alpha will be almost totally transparent.
My suspicion is that what you are really seeing is that your transparent stuff is rendered first and picking up the framebuffer background and filling the z-buffer thus blocking anything else from rendering there.
You could prove that by setting an alpha discard threshold to 0.2… which should make the transparent pixels < 0.2 not even write anything to the framebuffer (not what you want but would prove it’s a sorting problem). Or you could set the viewport background to blue and see if your lines turn blue instead.
Yes it does. When I make the background blue, the outlines also turn blue.
The alpha is applied to the viewport and not to the triangles behind it.
Then i happened to be lucky that my transparent water surface worked properly … without me knowing why
As long as i had to keep the order in a single mesh, i understood it.
But here I add node in node to a node. How should I keep the sequence in the scene here?
Is the order in which attachChild is called decisive?
If so, then everything is answered. I only add the water main-node after I added land main-node (that’s why water works). And this thread is just a stupid mistake.
I have already added Lemur to the project based on your recommendation from the other post and use it as a menu for the editor. So I was able to try LayerComparator.setLayer. Works suddenly.
Cool, I could use it to control other things.
As an absolute beginner it might be helpful if the problem of sorting (1. sequence of points in the mesh, 2. sequence of nodes, 3. comparator) were explicitly explained in docu “Alpha/Transparency Sorting, Your Z-buffer, and You”. So not just what is right, but also how.
Many, many thanks to Paul (pspeed) and Radek (oxplay2). As always, the answers were helpful in several directions.
Regarding “but it should not matter”:
I can’t build custom shaders or calculate tangents yet. I don’t know how using parallel viewport would help. But I already use cullHint (for switch between distant and near nodes).
Today, with the standard Unshaded.j3md and LayerComperator, it would only have to be reduced to the mathematical problem of recalculating the layer scoring after each camera movement. I guess as a complete beginner.
JME is already sorting transparent objects back to front (painter sort). No need to do additional sorting on top of that.
The issue where layer comparator comes into play is for when sorting would be ambiguous (box inside versus box outside, triangle sticking through another triangle, etc.)… and especially where that order is easily determined.
That being said, the layer can be set at any time and it will be used. The only limitation is that within a set of children, you only get ten layers.