GLSL Shader Mix Colors

Yo @Deltakosh , @sebavan … I have a really weird issue with Shader Mix Color.

I have created a shader that mixes the finalColor with a Highlight Color. Kinda like the way mesh.renderOverlay works but with instances. The main fragment simply mixes the color:

                return {
                    CUSTOM_FRAGMENT_DEFINITIONS: `
                        #ifdef INSTANCES
                            varying vec2 instanceUV6;               // Receive from vertex shader
                        #endif
                    `,
                    CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR: `
                        #ifdef INSTANCES
                            if (instanceUV6 == vec2(1.0, 1.0)) {
                                vec3 highlightColor = vec3(0.306, 0.745, 0.969);
                                finalColor.rgb = mix(finalColor.rgb, highlightColor.rgb, 0.3);
                            }
                        #endif                
                    `,                    
                };

And works great EXCEPT on some Windows machines with NVIDIA cards using CHROME or EDGE… Is looks like some sort of Z-fighting:

But it should look like this:

NOTE: This does not happen in the playground.

NOTE: I try to force depth pre pass and a seperate culling pass as well

    constructor(material) {
        super(material, "HighlightInstanceMesh", 100, { HIGHLIGHTINSTANCEMESH: false });
        // ..
        // Note: Ensures the highlight is rendered on top
        // ..
        if (material.needDepthPrePass !== true) {
            material.needDepthPrePass = true;
        }
        if (material.separateCullingPass !== true) {
            material.separateCullingPass = true;
        }
        this._enable(true);
    }

@Deltakosh … You got any theories as to why SOME windows machine with NVIDIA cards render like this…

Just a heads up that they are both away right now, so it might take some time before a response :slight_smile:

It’s probably an interpolation problem with varying variables (we already experienced this problem with Nvidia GPUs). Instead of instanceUV6 == vec2(1.0, 1.0), try something like abs(instanceUV6 - vec2(1.0, 1.0)) < vec2(0.001, 0.001) (you may have to adjust the 0.001 constant).

I already found that issue as well… And i use

if (instanceUV6.x > 0.5 && instanceUV6.y > 0.5) then MIX HIGHLIGHT COLOR

But thanks for the quick response @Evgeni_Popov