I found an issue while debugging shadows. After deducting the green screen, I found that the shadow is not the shadow of the green screen, but a rectangle. Do I need to make any changes
const texture = new THREE.VideoTexture(this.videoElement)
texture.minFilter = THREE.LinearFilter
texture.magFilter = THREE.LinearFilter
texture.format = THREE.RGBAFormat
const tempCoverImageColor = this.tempSourceData.backgroundColor
// Chroma Key
const chromaKeyShader = {
uniforms: {
'tDiffuse': {value: texture},
'color': {value: new THREE.Color(tempCoverImageColor.r / 255.0, tempCoverImageColor.g / 255.0, tempCoverImageColor.b / 255.0)},
'range': {value: tempCoverImageColor.tolerance / 255.0},
'smoothing': {value: 0},
},
vertexShader: [
'varying vec2 vUv;',
'void main() {',
'vUv = uv;',
'gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );',
'}'
].join('\n'),
fragmentShader: [
'uniform sampler2D tDiffuse;',
'uniform vec3 color;',
'uniform float range;',
'uniform float smoothing;',
'varying vec2 vUv;',
'void main() {',
'vec4 texel = texture2D( tDiffuse, vUv );',
'if (length(texel.rgb - color.rgb) < range) {',
'discard;',
'}',
'float d = abs(length(texel.rgb - color.rgb));',
'float edge = smoothstep(range, range + smoothing, d);',
'gl_FragColor = texel * edge;',
'}'
].join('\n'),
transparent: true,
alphaTest: 1,
clipping: true
}
const chromaKeyMaterial = new THREE.ShaderMaterial(chromaKeyShader)
this.material = chromaKeyMaterial