May I ask how to do multi pass? Do you have an example

May I ask how to do multi pass? Do you have an example

It’s not directly supported … even though most likely can be done by using Layers. What are you trying to do?


I need to create this effect, which requires 2 passes,

First pass. depthWrite = false; depthFunc=FUNC_GREATER, rendering occluded parts

Second pass. depthWrite = true; depthFunc=FUNC_LESSEQUAL, rendering normal parts

Something like this could work:

  • find a mesh instance of that mesh. It has pointer to material, mesh, skinInstance, and a node.
  • you need to create a duplicate material, with your different depth settings.
  • you need to create a new mesh instance, using this duplicate material, mesh, the same node, and the same skin instance (if the mesh is skinned)
  • then you need a layer, that renders after your original layer, and using Layer.addMeshInstances to add your new mesh instance to it.

In this case, I need to control two identical instances to do the same animation. If there are 10 characters in my scene, there should be problems in performance.

As long as you use the same skinInstance on the meshInstance, it’d use already evaluated skin matrices for it, without extra cost.

thanks, i’ll try

we have some internal code which does something similar … perhaps based it on this:


        const newMeshInstances = model.entity.findComponents('render').map((component: RenderComponent) => {
            return => {
                if (meshInstance?.material?.blendType === BLEND_NONE) {
                    return null;

                const accumMaterial = meshInstance.material as StandardMaterial;
                accumMaterial.blendState = accumBlend;
                accumMaterial.chunks = {
                    outputAlphaPS: accumPS

                // copy the material so we can customize the alpha blending
                const revealageMaterial = new StandardMaterial();
                revealageMaterial.blendState = revealageBlend;
                revealageMaterial.chunks = {
                    outputAlphaPS: revealagePS

                // construct a new mesh instance
                return new MeshInstance(meshInstance.mesh, revealageMaterial, meshInstance.node);
            }).filter(a => a);


but additionally, you need something along:

cloneMeshInstance.skinInstance = meshInstance.skinInstance;

and in addition to blendState, assign custom DepthState as well.

1 Like