Hello, I want to use flattenedClone() node for the trees in my landscape and reduce the draw call. If my texture uses a jpg file the result is good. If I use a PNG with transparency there is no draw call reduction. Can I use PNGs with transparency with the flattenedClone() ? Below is the structure I'm using:
for child in scene_temp.rootNode.childNodes { let newtree = tree.clone() sum_tree.addChildNode(newtree) } let sum_tree_flat = sum_tree.flattenedClone() scene.rootNode.addChildNode(sum_tree_flat)
If the tree texture contains a JPG file (diffuse) I get a draw call reduction (< 200 for my complete map) as expected (but no transparency with my leaves). If I use a PNG file, my draw calls are not reduced (> 2000) but I do have my trees with my leaves in transparency.
I've tried replacing tree.clone() with tree.flattenedClone() with no results. Thanks for your help.
Translated with DeepL.com (free version)
I succeeded by removing all the materials from my trees and adding the materials to my final flattened node :)
code :
let materiaux_init = tree_init.geometry?.materials // NEW
for child in scene_temp.rootNode.childNodes {
let newtree = tree.flattenedClone() newtree.geometry?.materials.removeAll(). // NEW sum_tree.addChildNode(newtree)
}
let sum_tree_flat = sum_tree.flattenedClone() sum_tree_flat.geometry?.materials = materials_init! // NEW
scene.rootNode.addChildNode(sum_tree_flat)
Thanks a lot!