Right now I am trying to implement simple dynamic reflection on a plane shader material. The better approach that I have done is the image right below. Applying this to the sphere looks good moving the camera, but when I use it on a plane it just looks worst and very pixeled, and when I move the camera it just looks anti-realistic. By the way, I am using THREE.WebGLCubeRenderTarget and the THREE.CubeCamera.
Maybe someone could recommend me a lecture or article about plane reflections.
Fragment shader:
void main() {
vec3 fNormal = normalize(vWorldNormal);
vec3 viewDirection = normalize(cameraPosition - vPosition);
vec3 reflectedVector = reflect(-viewDirection, fNormal);
vec3 tex = textureCube( uCubeTexture, reflectedVector ).rgb;
gl_FragColor = vec4(vec3(tex), 1.);
}
Vertex shader:
void main()
{
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
vWorldNormal = mat3( modelMatrix ) * normal;
vUv = uv;
vPosition = position;
}
The render target and cube camera that I use on the plane’s reflections:
this.cubeRendererPlane = new THREE.WebGLCubeRenderTarget(256, {
format: THREE.RGBAFormat,
generateMipmaps: true,
minFilter: THREE.LinearMipMapLinearFilter,
encoding: THREE.sRGBEncoding,
});
this.cameraCubePlane = new THREE.CubeCamera(0.1, 10, this.cubeRendererPlane);
this.cameraCubePlane.position.set(0, 0, 0);