Why does this compositor effect dramatically change the colours of the render?

Hey all, I suspect this will be a simple case of missing domain knowledge on my part but I am just curious why when I take my scene which looks like this:

When applying a basic compositing pass I am writing, it ends up looking like this?

The effect of mirroring is intentional (as I am writing a specific kind of mirroring pass), but the colour change seems random?

the Fragment shader of the pass looks like this:

uniform sampler2D tDiffuse;
uniform float direction;
uniform float position;
varying vec2 vUv;

void main() {
    vec2 p = vec2(vUv.x, vUv.y);

    if(direction == 0.0) {
        if(vUv.x > position) {
            p.x = (1.0 - vUv.x);
        }
    } else {
        if(vUv.y > position) {
            p.y = (1.0 - vUv.y);
        }
    }

    vec4 color = texture2D(tDiffuse, p);

    gl_FragColor = color;
}

The above is simply paired with a ShaderPass object and applied as a compositor effect!

Any ideas? Thanks

You potentially have to add an instance of OutputPass at the end of your pass chain. This will ensure color space conversion to sRGB which is maybe missing right now.

1 Like

Ah that has had a profound effect on the entire app im building, great to know thank you!

Also just noticed it is called out in these docs here - three.js docs

Thanks @Mugen87!

1 Like