Hi, I’m trying to create my own material that acts like a refractive surface (think frosted glass)
I’m currently taking the scene colour and feeding it some UV’s. I’m lerping between 2 UV’s, the unaltered screen position and the screen position + the red and green components from a normal map. This lerp is based on the normalized scene depth, so things close to the camera use more of the unaltered UV, and things far away are more distorted. It works surprisingly well for what I’m doing (not distorting the player’s arms when they are in front of the refractive object), however it’s not perfect.
What would be really useful to me is a function that returns 0 if it’s in front of the material, and 1 if it’s behind. Does such a thing exist / how might I be able to create it?
Thanks in advance.