Background water texture modifying foreground leaves in tree

If I plant a tree in the foreground, with a lake in the background, the transparency/texture of the lake is being apply to the leaves. The tree branches are not affected. The branches are cylinder/cones with a solid texture. The leaves are x3d nodes with random positioned leaf faces. The texture on the leaves is transparent. The leaves look under water when in front of water on the same local 100x100 tile. The leaves look correct in front of distant water tiles (why the picture below has a line in the middle of the lake above where they display correct). Perhaps this is a sorting issue since the tree is small within the 100x100 water tile (which just goes underground where there is no water). Is there a solution?

1 Like

It does seem like blending sorting issue. The water plane is probably large, and mistakenly detected as “in front of the tree”.

See Blending (Rendering Partially-Transparent Objects) | Manual | Castle Game Engine and example castle-engine/examples/viewport_and_scenes/billboards_blending_in_3d at master · castle-engine/castle-engine · GitHub .

You can set Viewport.BlendingSort to sortCustom and then assign OnCustomShapeSort ( Castle Game Engine: CastleViewport: Class TCastleViewport ). Example implementation is in TShapeSortEvent docs, Castle Game Engine: CastleShapes . In your case, you would implement the sorting routine to make sure that any shape coming from water scene – is always behind any shape coming from the tree(s) scenes. Let me know if this is unclear (or if this is clear :slight_smile: ), I can provide some better examples.

1 Like

Most of the time everything will be viewed from above where it is not an issue unless the tree is in the water. I plan to redo trees as they currently take too much memory if there are many and they grow enough.