How to achieve the effect of mirroring only half?

Is there a way for bbl to make the mirror image only half?

threejs has a shader.beforeCompile function,and only need to modify the reflection part,such as reflectNormal,reflectColor

 material.onBeforeCompile = shader => {
                    shader.uniforms.reflectMap = this.reflector.renderTargetUniform;
                    shader.uniforms.textureMatrix = this.reflector.textureMatrixUniform;

                    shader.uniforms = Object.assign(shader.uniforms, uniforms);

                    shader.vertexShader = shader.vertexShader.replace(
                        'void main() {',
                        /* glsl */ `
                        uniform mat4 textureMatrix;

                        out vec4 vCoord;
                        out vec3 vToEye;

                        void main() {
                        `
                    );
}

I know SSR can do it, but it’s too expensive。Is there any other way to do it by using bbl?

1 Like

This may help:

(see other posts after this one, the PG has been updated several times)

[EDIT] Note that you can also try the Mirror texture, which could be faster than SSR, depending on your scene.

2 Likes

I think this might be the perfect answer to my needs

2 Likes

Sorry to bother you again. The shadow is perfect now, but I want more. For example, is there a way to achieve the effect of a blurred mirror image?

Take another look at the picture I provided above. The mirror image appears to have a fade-out effect from top to bottom。Notice the car in the mirror image

I wonder if this picture can help me explain it:

@Evgeni_Popov

It’s already what happens, the level of blackness depends on distance.

I updated the PG to make it more visible:

I set cameraBottom.beta = 1 to better see the shadow, and compensate the shift on the ground with rtt.vOffset = 0.07. I also updated cameraBottom.minZ/maxZ so that the whole shadow of the character is visible.

You can try to update the formula line 280 to change how the blackness changes with distance.

1 Like