Might it be the problem the distance between the position of the cube camera and the target? I’m setting the camera position right in the center of the model.
I think the problem could be solved if there is a way to scale down the texture set as envMap, I tried with texture.repeat() without luck.
Here some screenshots showing how the example looks with different refraction ratio
Following your example, what I’d like to achieve is to get almost invisible balls, just a bit of refraction, like the latest screenshot but without magnifying the background.
Maybe that’s the clue, the camera position should be in the center of the lens, or at its focal point.
A working example with a gui that can change the position of the camera would be good to try.
Then you’d would also need a second cubecamera for the other lens.
Glad to see you could replicate the magnified texture.
Do you think is possible in some way to scale down the envMap texture? literally make the image smaller
Did you try to put the cubeCamera at the same position as the camera you use for rendering ? You can hide the glasses and glass frames from the cubeCamera with layers, to keep only the two stems in the resulting envmap. This way I suppose the glass material with refractionRatio will show a distorted image of the glasses stems from the point of view of the camera, which is what you want to achieve.
@felixmariotto that was the trick! It started to look accurate right after keeping in sync the cube camera position with the orbit camera.
Thanks for sharing the possible solution and recommend the use of layers, I’ll try to use them as an alternative to hide and show meshes on every cubeCamera.update call.
Here how it looks after making the cubeCamera follow the camera position.
cubeCamera.position.copy(camera.position);
// consider hide meshes that shouldn't be part of the refraction
cubeCamera.update(renderer, scene);
// restore meshes visibility