Works flawlessly now! However, there is another issue that I’m having when using two of these refraction based materials.
The refraction is made based on a screen texture without the related object. However when using two of these, the result is a black object when looking at the other through the refraction.
It makes complete sense, since the refraction texture is made before applying the refraction to the sphere.
However, is there a way to overcome this hassle?
Hi @Evgeni_Popov Alright, this is already a big improvement.
However, there is another problem when looking at it from the opposite angle. What’s best to do here to make it work perfectly from all angles? Update the planes based on the camera position?
You could try to use two hemispheres and have a refraction texture for each but it would still fail for some angles (I have only replaced the green sphere by 2 hemispheres):
@Evgeni_Popov You have no idea how much you’re helping, thanks so much!
Making so many different refraction textures might become an performance issue sadly. So I hope I can make your second example work from any angle.
The plane update seems to work perfectly for the green sphere because it’s at the center of the orbit for the camera. But I can’t see the blue one through the green one. Probably because of the static d component values. (I’m new to the math.plane).
So I’m trying to find a way to make the d component position/distance based, Vector2.Distance or anything along those lines do not work for sure… do you have an idea?
It does not work, if you set the Z position of the green sphere far away (say 20), you will see that the small spheres are clipped too soon.
You need to recompute the d component of the plane, as you stated above. This is the distance of the plane to the origin, which can be easily computed with a dot product between a point on the plane (the center of the sphere for eg) and the normal:
@Evgeni_Popov I never knew you could measure distance using dot products. My mind is completely blown at the moment. I have yet to understand what’s going on here… A dot product on a position and a calculated normal.