Opaque objects appearing with an alpha blending fade

Hi.

I've got a terrain, and some objects all over it.

I want my objects to appear/disappear in alpha when they are far from the camera.

I've tried many ways to do it, but it keeps to be unsuccessful.



(Rq: I use SharedNode nodes. Might be a source of trouble)





Try 1:

I add an alphastate on my node. Ok. But how to set up the value of the alpha? Tried setDefaultColor() on the Geometry node, but the alpha channel has no effect.



Try 2:

MaterialState + Alphastate => the alphastate doesn't take into account the alpha I set in setAmbient.



Try 3:

Use TextureState?



Any help would be much appreciated!



Thanks in advance.


Regarding 2: Alpha works only if you set it on the diffuse property of the material. You must also have a lightstate enabled on the node, but any lights are not necessary.

In fact, this as simple as in "Try 1". You just have to attach an alphastate to your node et change the geometry default color.

This didn't work on my project because my objects were attached to another node with its own renderer states.



If it helps, this is how I change the default color for my node.





protected void setGeometryAlpha(Spatial spatial, float alpha) {

More info:



1 - AlphaState + geometry defaultColor works if there is no lighstate.

2 - If there's a lightState, you need Alphastate + MaterialState + LightState. Set the alpha in the material setDiffuse.



(thank you Tobias)