In this playground, for example: https://playground.babylonjs.com/#9K3MRA#754
We have a PBR material that is rendered in multiview, but the uniform vEyePosition
used to calculate reflections is only derived from the current active camera (which in multiview rendering corresponds to the left eye). In order to get proper reflections when rendering in multiview we should have a second uniform vEyePositionR
or a matrix that compensates for the stereo offset between the left & right eyes that we’d multiply by vEyePosition
in order to create vEyePositionR
in the shader.
Lines 786 to 791 in 4bc7b80
public bindEyePosition(effect: Nullable, variableName = “vEyePosition”, isVector3 = false): Vector4 { | |
---|---|
const eyePosition = | |
this._forcedViewPosition ? this._forcedViewPosition : | |
this._mirroredCameraPosition ? this._mirroredCameraPosition : | |
this.activeCamera!.globalPosition ?? (this.activeCamera as WebVRFreeCamera).devicePosition; | |
Babylon.js/src/Shaders/ShadersInclude/reflectionFunction.fx
Line 132 in 4bc7b80
return computeCubicCoords(worldPos, worldNormal, vEyePosition.xyz, reflectionMatrix);
*Ported From GitHub