Reflection probe for refractions behaving like reflections when scene useRightHandedSystem


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.

ohhh looks like a bug to me @Evgeni_Popov can you have a look into it ? if not I will check later tonight.

You need to set the invertZ property of the refraction texture to true to make it work in rhs:

1 Like

I am wondering whether it should be manual or not ?

Yup! That did it. Thank you.

I’d be in favour of a more automatic approach as well. Can’t really see a use case for keeping it as it is now.

I agree, here’s the PR:

1 Like

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:


Thanks. This is helpful. Learning lots.