Blend and Z-buffer

HI all! u have a particule effect with all the blending option working fine, but… when an object is behind or front of the particle system i have a problem with the z-sort and a saw the object in front of the particle, when the object it's behind… any clue on how to solve that? thanks in advance!!

juglarx said:

HI all! u have a particule effect with all the blending option working fine, but... when an object is behind or front of the particle system i have a problem with the z-sort and a saw the object in front of the particle, when the object it's behind... any clue on how to solve that? thanks in advance!!


Post a snapshot of the problem and the code that sets up your ZBufferState on the root/scene node.

Declaration



 BlendState as1 = display.getRenderer().createBlendState();
        as1.setBlendEnabled(true);
        as1.setSourceFunction(BlendState.SourceFunction.SourceAlpha);
        as1.setDestinationFunction(BlendState.DestinationFunction.One);
        as1.setTestEnabled(true);
        as1.setTestFunction(BlendState.TestFunction.GreaterThanOrEqualTo);
        as1.setEnabled(true);
        as1.setEnabled(true);
       
        TextureState tsParticle = display.getRenderer().createTextureState();
        tsParticle.setTexture(
            TextureManager.loadTexture(
            TestParticleSystem.class.getClassLoader().getResource(
            "data/textures/flaresmall.jpg"),
            Texture.MinificationFilter.Trilinear,
            Texture.MagnificationFilter.Bilinear));
        tsParticle.setEnabled(true);

pMesh = ParticleFactory.buildParticles("particles", 100);
       
        pMesh.setEmissionDirection(new Vector3f(390,40,30));
        pMesh.setInitialVelocity(.019f);
        pMesh.setStartSize(2.5f);
        pMesh.setEndSize(.5f);
        pMesh.setMinimumLifeTime(1200f);
        pMesh.setMaximumLifeTime(1400f);
        pMesh.setStartColor(new ColorRGBA(1, 0, 0, 1));
        pMesh.setEndColor(new ColorRGBA(0, 1, 0, 0));
        pMesh.setMaximumAngle(360f * FastMath.DEG_TO_RAD);
        pMesh.getParticleController().setControlFlow(false);
        pMesh.setParticlesInWorldCoords(true);
        pMesh.warmUp(60);
       
      ZBufferState zstate = display.getRenderer().createZBufferState();
      zstate.setEnabled(false);
      zstate.setWritable(false);
      
      pMesh.setRenderState(zstate);
      pMesh.setModelBound(new BoundingSphere());
      pMesh.updateModelBound();
        pMesh.setRenderState(tsParticle); // textura loaded
        pMesh.setRenderState(as1);



after that i add to the root (  sceneUniverse is a Node Class ) all object are attached to sceneUniverse



sceneUniverse.attachChild(pMesh);



On the render section



 display.getRenderer().clearBuffers();

            sceneUniverse.updateRenderState();   // sceneUniverse is the root
           display.getRenderer().draw(sceneUniverse);



Hi,



Are you sure that you want to have zstate disabled?

Change  zstate.setEnabled(false); -> zstate.setEnabled(true); and perhaps it'll solve your problem. At least it worked for me.


Try using this as well:



zbuffer.setFunction( ZBufferState.TestFunction.LessThanOrEqualTo );



and set the render state of the root scene node:



rootNode.setRenderState(zbuffer);

dosen't work



zstate.setEnabled(true);  // same error :frowning:







zbuffer.setFunction( ZBufferState.TestFunction.LessThanOrEqualTo ); // same error :frowning:



maybe is the bouding sphere of the particles?? any clue is that is posible and how to solve that ?

Are you getting an actual error or are you just not seeing the proper z-depth on the particles?



If an error, copy it here.



If its just a z-depth issue, did you attach the z-buffer to the scene's root node?  If its just attached to the particle node then it won't propigate into world-space and produce the expected z-ordering.

Hi! it's just not seeing the proper z-depth on the particles. it work fine with the others object it's just with one with  this not proper set z-buffer all z-buffer are applied to the scene root and not to the object itself



here is an attach jpg, the sun if over the particle (wrong) and the earth is fine. the particle need to be over the sun



any clue of what could happend?

thanks!

What geometry did you attach your particles to?  It's hard to tell from the pic you posted. 



When troubleshooting problems like this, it is sometimes easier to see what is going on if you


  1. increase your particle flow so that what you are seeing is not so dispersed


  2. make the geometry that your particles are attached to visible if you are culling it


  3. make the geometry that your particles are attached to invisible if you are not culling it


  4. make the geometry that your particles are attached to a different material/color that has a higher contrast with the particles so that you can more easily see what is going on.



    Of course, you could post your ~entire~ scene code so that the devil in the details can be spotted by me (or someone else) reading/tracking this thread.