Node Material: Dissolve Effect

@gbz, the name emissive texture on the node is simply for ease is grabbing the node and assigning the texture. There is no difference here from any other texture. The reason that the emissive texture is the one that is passed to the glow layer is because of the glow mask portion of the shader above:

You can see here that when I set glow mask to 1.0, you only see the emissive texture:

Setting it back to 0.0 you will see a mix of the base color and emissive textures so you get a tint of the emissive color in the base color:

This is the important part because in this code:

// enable glow mask to render only emissive into glow layer, and then disable glow mask
    gl.onBeforeRenderMeshToEffect.add(() => {
        glowMask.value = 1.0;
    });

We are saying that before you apply the glow layer, set the glow mask value to 1.0. That will show only the emissive texture on the mesh and the glow effect will render. Then once that pass is done, you get this code:

        gl.onAfterRenderMeshToEffect.add(() => {
        glowMask.value = 0.0;
    });

Which says that after you are done with rendering the glow layer (which is rendered first and then added to the normal scene render) you return the glow mask value to 0 and render out the mesh with it’s normal texture.

This code is called first and is used to make sure that the mesh uses it’s own material for the glow layer or the onBeforeRenderMeshToEffect and onAfterRenderMeshToEffect will have no effect on the scene:

// set up material to use glow layer
gl.referenceMeshToUseItsOwnMaterial(lightMesh);

So basically, if you tell the glow layer to allow a mesh to reference it’s own material for glow, it will just use that material and the glow will be wrong. Using the trick above with onBeforeRenderMeshToEffect and onAfterRenderMeshToEffect will allow you to isolate the fragment output to only the emissive texture to pass to the glow layer. Hope this makes sense.

1 Like