Render order and sorting

Hello,

i have created a square ground-map (100x100xquads(2 triangles))
[i first used a map composed of 100x100 square nodes, but the fps was really low]

so, as i go around the map, it seems the ground is rendered sometimes before, sometimes after transparent objects
depending on where i(the camera) stand
wich leads to transparent objects being rendered with nothing behind them
(as sorting is probably done considering the center point of each object)

i was wondering if there was a way to have the ground rendered first
and everything else, after

thx

You can put the transparent objects in the transparent bucket, this will render after everything in the Opaque bucket has rendered:

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:jme3_renderbuckets

<cite>@wezrule said:</cite> You can put the transparent objects in the transparent bucket, this will render after everything in the Opaque bucket has rendered:

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:jme3_renderbuckets

yes, i use transparent , but i get the same problem unless i use translucent, but it is not the result i am looking for

i don’t know what causes this

Are you sure you are using the buckets correctly?

I assure you that if the ground is in the opaque bucket and object in transparent one then ground will always be drawn first…

post code and screenshots

<cite>@nehon said:</cite> post code and screenshots

the thing is that the floor is alpha rendered too,
on some rectangular areas, there can be facilities(props/buildings),
so i needed to set the uv of floor tiles so that it was using a part of the floor texture that has 0% alpha
otherwise i had precision problems on the depth test cos facilities have a floor too
so i enabled alpha discard threshold to have either the floor rendered, either the facility floor rendered

floor :

[java]
floorMesh = CreateFloorMesh();
Material mat = main.getAssetManager().loadMaterial(“Materials/Floor.j3m”);
mat.getAdditionalRenderState().setAlphaTest(true);
mat.getAdditionalRenderState().setAlphaFallOff(0);
Geometry geo = new Geometry(“Floor”,floorMesh);
geo.setMaterial(mat);
floor.attachChild(geo);
floor.setQueueBucket(Bucket.Transparent);
[/java]

Material My Material : Common/MatDefs/Light/Lighting.j3md {
     MaterialParameters {
        DiffuseMap : Textures/floor.png
        AlphaDiscardThreshold : 0.0
        UseAlpha : true
     }
    AdditionalRenderState {
    }
}

some object that renders wrongly :

[java]
Node n=(Node) propToPlace.getChild(0);
Geometry geo=(Geometry) ((Node)n).getChild(0);
propMaterialToRestore=geo.getMaterial();

    Material propMaterial = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    propMaterial.setColor("Color",new ColorRGBA(0.8f,0.8f,1.0f,0.9f));
    propMaterial.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha);
    propToPlace.setMaterial(propMaterial);
    propToPlace.setShadowMode(ShadowMode.Off);

[/java]

i am afraid there is no solution for my problem
unless i kind of force the floor to be rendered before anything else

strangely enough, if i load a model from blender that uses alpha maps, i dont get the same issue

the main difference is that i don’t modiffy/assign a material to that prop
and also that it does uses a texture.

while the others have no texture, they are “just set to alpha” rendering

code for the plant :

[java]
propNode= (Node) main.getAssetManager().loadModel(“Models/Plant.j3o”);
gameItem.setNode(propNode);
propNode.addControl(new PlantController(main,(Plant)gameItem,CreateBoxCollisionShape(propNode)));
[/java]

[cant have the layou right after the second image, dont know why]

<cite>@zarch said:</cite> Are you sure you are using the buckets correctly?

I assure you that if the ground is in the opaque bucket and object in transparent one then ground will always be drawn first…

the floor uses bucket transparent too
i forgot to mention that sorry :stuck_out_tongue:

Change the floor and actually cut out the bits you don’t need rather than using transparency.

<cite>@zarch said:</cite> Change the floor and actually cut out the bits you don't need rather than using transparency.

well i will have to reset them once i remove a facility

if your floor is opaque with empty spaces, you don’t have to put it in the transparent bucket.just use the discard threshold and let it in the opaque bucket