Fade batched entities

Hi there!

Is it basically possible to fade out / in batched entities? I have an 3d object with a bunch of similar child entities, which sharing the same materials.

i used:

// update code called every frame
GameController.prototype.update = function(dt) {
    
    if(this.canFade)
    {
        this.children.forEach(function(child) {
            // acess the material of the render component
            var material1 = child.render.meshInstances[0].material;
            var material2 = child.render.meshInstances[1].material;
            // adjust opacity
            if(fadeOut && material1.opacity >= 0 || !fadeOut && material1.opacity <= 1)
            {
                adjustOpacity(material1, fadeValue);
                adjustOpacity(material2, fadeValue);

                // avoid update from executing if not necessary
                if(fadeOut && material1.opacity <= 0.001 || !fadeOut && material1.opacity >= 0.999)
                {
                    this.canFade = false; 
                }
            }
        }, this);
    }
};

function adjustOpacity(material, increment) {
    material.setParameter('material_opacity', material.opacity += increment);
    material.update();
}

this works if the entities are not batched but if theyre batched within a group it doesnt work. Im not sure about how to handle batched groups but i thought it may increase the perfermance if i group those meshes together. (its around 65 child entities, so i think i would decrease the drawcalls if theyre batched)

Thanks in advance for each input!

The entities you need to fade should not be in the batch groups … that way they would be independent (unless they share materials - they would need independent materials too)

Ah okay - so its basically not possible :slight_smile:

thought you can fade the shared material of the batched entities - so it would be adjusted for all together. but then i wount batch those entities

thanks for your input!