Refraction with IBL


I have implemented the ability to use equirectangular EXRs in my program by using the approach outlined in this example:

After trying to render glass material with refraction and digging deeper though the shader code of the above example it looks like it always assumes reflection mapping. I have played with the shader code to try to get it to do refraction, but all attempts have been unsuccessful so far.

Am I missing something and it’s simpler to do than I think or does it require writing an extensive amount of shader code to achieve the following result, but with equirectangular EXR:

Thank you!

Um, I don’t understand your fiddle. Why have you set the opacity value of the second material to 0?


Sorry, in my jsfiddle I simply meant to highlight just the refraction material. I forked your example and changed some parameters. My point is - can I achieve the same refraction results, but with the EXR environment map example above ( That one uses EquirectangularToCubeGenerator, then PMREMGenerator and lastly PMREMCubeUVPacker that in the end produce a CubeUVRenderTarget that when assigned as envMap to material produces same results as for CubeUVReflectionMapping. Setting mapping of texture for that CubeUVRenderTarget to CubeUVRefractionMapping makes no difference, as I think the main logic for how the environment map gets applied to the model lives in the shader codes of the above 3 classes. My experiments with changing the shader code of these 3 classes didn’t yet produce satisfactory results. And I am wondering if I am even on the right pass.