I added a global alpha factor to the unshaded material by just adding this line
(the rest of the code and material definition is just the same as the original)
but when I send values interpolated from 1.0 to 0.0 to the material, the object completely disapears below 0.5f instead of continuing the gradiant…
1.0 → 0.5 object disapears slowly
0.49 → 0.0 object invisible
the material is setup like that
material.getAdditionalRenderState().setAlphaFallOff(0.0f); // also tried different values
material.getAdditionalRenderState().setAlphaTest(true);
material.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha);
I tried to set it to different values, even commented out the threshold code
this dont make any sense to me
I though there was something wrong with the single Float parameter
so I even tried with Vector2F, still the same
I could post a project file, but it’s basicaly about adding that 1 line of code to the Unshaded material
and sending the value to the material
I just made a test project and it works, I dont get it
[edit : I noticed the problem occurs when there is another transparent object in the scene, when the other alpha object appears in the frustum, the first alpha object disapear but the two objects are quiet far appart…]
setAlphaFallOff(0.1f); changed to setAlphaFallOff(0.5f);
but why does one object fallof must be at least the other one fallof ??? it should be independent
they are both in transparent bucket… also if the alpha of the fading object goes wide range 0->1, its fallof should be 0
Box b = new Box(1, 1, 1);
Geometry geom = new Geometry("Box", b);
mat = new Material(assetManager, "MatDefs/Unshaded.j3md");
mat.setColor("Color", ColorRGBA.Blue);
geom.setMaterial(mat);
rootNode.attachChild(geom);
geom.setQueueBucket(RenderQueue.Bucket.Transparent);
mat.getAdditionalRenderState().setAlphaFallOff(0.5f);
mat.getAdditionalRenderState().setAlphaTest(true);
mat.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha);
geom.setLocalTranslation(-133.64247f, 3.129125f, 63.389854f);
//-----------------------------------------------------------------
Spatial model = assetManager.loadModel("Models/test.j3o");
Spatial test = FindNode((Node)model,"Test",false);
Spatial clonedInstance = test.clone();
Geometry geo=getGeometry(clonedInstance);
Material mat2=geo.getMaterial();
Material unshadedMat = new Material(assetManager, "MatDefs/Unshaded.j3md");
unshadedMat.setTexture("ColorMap",mat2.getTextureParam("DiffuseMap").getTextureValue());
unshadedMat.setFloat("GlobalAlpha", 1.0f);
clonedInstance.setQueueBucket(RenderQueue.Bucket.Transparent);
unshadedMat.getAdditionalRenderState().setAlphaFallOff(0.5f);
unshadedMat.getAdditionalRenderState().setAlphaTest(true);
unshadedMat.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha);
geo.setMaterial(unshadedMat);
rootNode.attachChild(clonedInstance);
clonedInstance.setLocalTranslation(-90.64992f, 2.9433272f, 75.212364f);
//------------
cam.setLocation(new Vector3f(-133.64247f, 3.129125f, 63.389854f+35));
That’s how it worked before there was an alpha discard threshold. But both are basically doing the same thing.
Since opengl 3 it’s deprecated so you’d better use the latter.
No. I don’t have time to run your code… maybe you could post a video showing the issue.
But if the problem happens when one object is in front of the other then they might be sorting incorrectly… especially if alpha test or alpha discard threshold is changing what you see. If a transparent object is drawn then any non-discared pixels will fill the z-buffer hiding anything drawn later behind them… even if the pixel was transparent.
will take more time for me to figure how to make and upload a video and you to watch it
feel free to do it when you got time, it’s all ready made, with correct camera position
meanwhile I removed the lines of code, and it is working fine so I am not in a hurry
both objects are aside of each other , if you turn the camera to see only the blue box, the problem disapears and comes back as soon as the other object gets back in the fov
I tried to open and launch the project… but it wasn’t downloaded. So you missed a step. Besides, I already have 25 projects open in the IDE… I can’t really add another one for someone who can’t bother to show us a video.
The point of having people post code is so that we can eyeball it because 99% of the time we can spot the problem there. The only thing I can see glancing at your code that you do differently than I do is cloning the material… perhaps there is some state leakage between the clones. Otherwise, I have lots of transparent objects in my scene and never see this issue.
My time is more precious than your issue to me… so if I can’t solve it from the forum then I’ll defer to someone else. Between two kids, a wife with brain cancer, a full time+ job, and my own projects, several open source projects, and JME… I don’t really have time to download everyone’s projects to try them out. After all, I have my own bugs to solve, too.
so you can understand I dont have time to waste hours to figure out the right encoding to avoid a 500mb file for a 2 sec video, I really have to go forward with my game, cos it 's the only source of revenue I could have so far
and It gives me a MOUNTAIN of work
If i fail this, I’ll be homeless if I cant find money cos nobody wants to hire me after 25 years of experience
like you I got issues, no job, no girl, no kids, no future, no f… perspectives on sight, but that stupid game I try to make
I’ll try to make a vid but I checked the link and it’s working fine
[edit :made the video, I’ll try to convert it to swf lower size… hang on]