I am trying to implement refractions with PBRMaterials to refract an image of a GLB and sphere through a glass mesh.
I am able to refract perfectly fine except for when i set scene.useRightHandedSystem = true. My app requires scene.useRightHandedSystem = true. Peeking into the BJS code for reflection probes, it looks like reflection probes should be able to handle right handed system and so i suspect this may be a bug.
You can run the below PG to see that the refraction in the glass material is behaving like a reflection. Commenting out the line that toggles on right handed system will show a correct refraction.
I may have found another ābugā regarding refraction. Based on GLTF specs and mentioned elsewhere on the web, glass usually has a ior of 1.5. Iāve updated the PG for a box (our glass window) to have an ior of 1.5. You can see that the refracted image is heavily magnified even though the sides of the box is flat like a glass window.
When I recreate the scene in Blender, the glass window does not magnify at all regardless of ior value. This to me appears to be reasonable and correct output.
Is it a bug that BJS is rendering heavily magnified refraction?
This magnification is not because of the IOR but because you are using a probe, which by default is supposed to represent the geometry at infinite distance. You should use a local probe (cube map) instead, if you want a more localized render.
To convert a cube map to a local cube map, you must set the boundingBoxPosition and boundingBoxSize properties. For example: