In terms of adding more blur the deeper an object is, I can think of three ways:
-
More blur the farther the object is from the camera (just using scene depth), this is the least accurate for what you want, but very easy
-
More blur the farther the object is below the surface of the water, using Z position. This is pretty close to what you want. However, it’s not entirely accurate because viewing an object from directly above will have the same amount of blur as viewing it from an large angle, and even though there’s more water between the camera and the object when viewed at an angle, the blur would be the same.
-
More blur based on the amount of water that the light must pass through. Hardest and highest cost in the shader, because you would need to calculate the distance to the surface of the water and to the surface of your object at each pixel. Off the top of my head, you could use the custom depth buffer and place the water and object in different channels for this, but there may be a more efficient way of doing this.
Here’s an excellent article from the esteemed Tom Looman on custom depth buffers: http://www.tomlooman.com/the-many-uses-of-custom-depth-in-unreal-4/