Important Renderer.QUEUE_TRANSPARENT issue ? [VIDEO]

Hello,



I’ve tried some Renderer.QUEUE_TRANSPARENT rendering with JME and I’ve found something that looks like a problem:



I’ve constructed a little scene with two spheres, one has a transparent texture on it. The second is solid.

Blendstates, zbuffers have been setup and culling is disabled.

The two spheres are sligtly overlapping.



Flying around the first sphere I’m able to see the second one, but it desappears in some cases.

See the video here:



http://www.classx.it/public/tmp/jme_issue_transp.avi



For me this is an unexpected behavior. Is it my fault ?

Ahem… please moderators don’t keep ignoring my posts  :cry:



This issue may be related to this : http://www.jmonkeyengine.com/forum/index.php?topic=12409.msg91980#msg91980

I can confirm that problem, happens also to me now…

Although, if I set that not transparent object (in this example, smaller sphere) uses Opaque queue, everything looks fine, except when I updateRenderState(), things start messing up again (inner part of the object gets unusual color and cannot be seen good anymore…).

Has anyone played with this and maybe got some clue of what could be the problem here?

Did you put both spheres in the transparent queue ?



Post the small example so other can easily reproduce it.

Hi,



the project was built with the SceneWorker. As far as I remember the spheres were both in the transparent queue. Maybe InShadow has some code for our tests. If not, I'll try to replicate it by myself.

Hi!

My code is highly integrated in my project, so I can't really post this here, but will make some example and post it later…

Ok, here is the code. I make some Text3D and surround it with transparent sphere. If I set that whole rootNode or at least node that has both those children attached to use transparent queue, this glitch occurs (when moving camera). If I set manually for each object which render queue to use, it is working fine.

import java.awt.Font;

import com.jme.app.SimpleGame;
import com.jme.light.DirectionalLight;
import com.jme.math.Vector3f;
import com.jme.renderer.ColorRGBA;
import com.jme.renderer.Renderer;
import com.jme.scene.shape.Sphere;
import com.jme.scene.state.BlendState;
import com.jme.scene.state.CullState;
import com.jme.scene.state.LightState;
import com.jme.scene.state.MaterialState;
import com.jme.scene.state.ZBufferState;
import com.jme.scene.state.MaterialState.ColorMaterial;
import com.jme.system.DisplaySystem;
import com.jmex.font3d.Font3D;
import com.jmex.font3d.Text3D;
import com.jmex.font3d.effects.Font3DBorder;
import com.jmex.font3d.effects.Font3DGradient;

public final class TransparentQueueTest extends SimpleGame {
   public static void main(String[] args) {
      TransparentQueueTest app = new TransparentQueueTest();
      app.setConfigShowMode(ConfigShowMode.AlwaysShow);
      app.start();
   }

   @Override
   protected void simpleInitGame() {
      display.setTitle("Transparent Queue Test");
      
      setRenderStates();
      
      MaterialState ms = DisplaySystem.getDisplaySystem().getRenderer().createMaterialState();
      ms.setColorMaterial(ColorMaterial.AmbientAndDiffuse);
      ms.setEnabled(true);
      
      Font3D myfont = new Font3D(new Font("SansSerif", Font.PLAIN, 2), 0.001f, true, true, true);
      Font3DGradient fontGradient = new Font3DGradient(Vector3f.UNIT_Y, ColorRGBA.green.clone(), ColorRGBA.green.clone());
      fontGradient.applyEffect(myfont);
      Font3DBorder fontBorder = new Font3DBorder(0.01f, ColorRGBA.white.clone(), ColorRGBA.blue.clone(), myfont);
      fontBorder.applyEffect(myfont);
      Text3D mytext = myfont.createText("S", 1, 0);
      float tf = -5f * mytext.getWidth();
      mytext.setLocalTranslation(new Vector3f(tf, tf, 0));
      mytext.setLocalScale(new Vector3f(10, 10, 2.5f));
      rootNode.attachChild(mytext);
      mytext.setRenderState(ms);
      //mytext.setRenderQueueMode(Renderer.QUEUE_OPAQUE);
      
      Sphere sphere = new Sphere("Spawn Sphere", 40, 40, 6.8f);
      ColorRGBA sphereColor = ColorRGBA.white.clone();
      sphereColor.a = 0.25f;
      sphere.setDefaultColor(sphereColor);
      rootNode.attachChild(sphere);
      sphere.setRenderState(ms);
      //sphere.setRenderQueueMode(Renderer.QUEUE_TRANSPARENT);
   }
   
   private void setRenderStates()
   {
      DirectionalLight dr = new DirectionalLight();
      dr.setEnabled(true);
      dr.setAmbient(new ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f));
      dr.setDiffuse(new ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f));
      dr.setSpecular(new ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f));
      dr.setDirection(new Vector3f(-1, -1, 1));
      
      LightState lightState = DisplaySystem.getDisplaySystem().getRenderer().createLightState();
      lightState.setEnabled(true);
      lightState.attach(dr);
      rootNode.setRenderState(lightState);
      
      BlendState blendState = DisplaySystem.getDisplaySystem().getRenderer().createBlendState();
      blendState.setBlendEnabled(true);
      blendState.setSourceFunction(BlendState.SourceFunction.SourceAlpha);
      blendState.setDestinationFunction(BlendState.DestinationFunction.OneMinusSourceAlpha);
      blendState.setTestEnabled(true);
      blendState.setTestFunction(BlendState.TestFunction.GreaterThan);
      blendState.setEnabled(true);
      rootNode.setRenderState(blendState);
      
      CullState cs = DisplaySystem.getDisplaySystem().getRenderer().createCullState();
      cs.setCullFace(CullState.Face.Back);
      cs.setEnabled(true);
      rootNode.setRenderState(cs);
      
        ZBufferState buf = DisplaySystem.getDisplaySystem().getRenderer().createZBufferState();
        buf.setEnabled(true);
        buf.setFunction(ZBufferState.TestFunction.LessThanOrEqualTo);
        rootNode.setRenderState(buf);
      
      rootNode.setRenderQueueMode(Renderer.QUEUE_TRANSPARENT);
   }
}