# Reflections based on distance from plane

Let's consider, for example, a surface like the volleyball court, we can see that legs and shoes of the players are reflected, with a blur effect, but body and stadium don't (as each object not near to the court).

I've already made a reflection effect, but it works as a specular reflection, and I need to achieve an effect like the photo above. So, I would like to make a reflection that is based on the distance between the object and the plane, in this manner a close object would reflect more than an object that is positioned far away from the plane.

What is the best way to achieve this effect? My first idea was to use the depth value (taken from the reflected camera), and use that value to blend between reflection and court. But I don't know if it's a correct way.

Edit: as rendering engine I use Ogre that already provides a reflections system: reflecting the camera through a plane (obviously I can select the models to draw from the reflected camera). After a render to texture pass I can blend the reflected texture with the original plane. So, if possible, I'm looking for a way that best suits my system.

• I would just render your standard reflection to the render target (preferably a target that is about 1/2 the width and height of the game window resolution), and then give it a blur effect. This should get you close to what you're seeing in that image. Commented Feb 28, 2012 at 0:30
• Since you already know how general reflections work, and Ogre gives you support to do that, you should be able to set a far plane close enough to limit what get rendered when you do the render pass looking from the court to the light source. Commented May 28, 2012 at 10:50

This answer doesn't really achieve what you are looking for, but is still related. If you currently have a constant reflectivity factor, consider replacing it with a one calculated using Fresnel equation. It can also be used for non-refractive materials and it achieves the effect where the surface reflects more when viewed from a lower angle. Check this paper from nVidia for more information. The paper also presents a fine and simple approximation for the function, which in GLSL is:

float fresnel(vec3 reflection, vec3 normal, float R0) {
// float const R0 =  pow(1.0 - refractionIndexRatio, 2.0) /
//                   pow(1.0 + refractionIndexRatio, 2.0);
// reflection and normal are assumed to be normalized
return R0 + (1.0 - R0) * pow(1.0 - dot(reflection, normal), 5.0);
}

// R0 = 0.02 empirically provides good results for my case.
float f = fresnel(reflectionVector, normal, 0.02);
float reflectivity = mix(alpha, 0.0, f);


Draw the court itself with no depth output, but the lines and everything else with depth turned on.

Then as a last step draw a very low resolution model mimicking each athlete, mirrored upside down. It's probably best if the low resolution model is rendered with a fake fade the further away from the feet it gets, you don't need to be accurate but just look good.

You can apply blur or leave as a sharp but ghostly render for polished floors.

• I've just updated my question with some details about the technology that I'm using. If possible I prefer to using the system already provided by Ogre (instead of have low resolution models for the reflections). Commented Feb 27, 2012 at 22:13