# How can I create a shader that will reproduce this lighting effect on terrain?

Notice the way in which the major light source in each image reflects off the ground, as a function of the distance between the light source and the viewer (?).

Is this a (bumped) specular map? The effect is seen all over in World of Warcraft; I specifically remember it on the snow in Dun Morogh, and on the shores of Darrowmere lake. Looking directly toward the sun is required. The effect is also commonly on the surface of water in RL and in CG. Specifically, I want to build the effect where the reflection is more intense on the ground surface closer to the light source, and falls off as it approaches the viewer.

-
phong on a bump mapped surface – ratchet freak Dec 20 '13 at 22:02

I imagine if I was going to build such a shader there are certain phenomenas that I will start with.

First the sunlight is directional, meaning it does't have position nor attenuation.

Second the diffuse component is simply calculated by taking a dot product between the sun direction and the surface normals, adding normal mapping might add to the detail.

The tricky part is modeling the sun directional specular component. So to achieve similar effect I would break it into smaller problems:

• The first is the microfacets of the surface this can be simulated using any variation of bump or normal mapping, this can be applied to both diffuse and the specular component.
• The second part is the uneven distribution of the specular lighting. This can be done using some kind of specular maps.
• Now the most tricky part is the directional specular map this can be achieved using Ward Anisotropic lighting model, which gives you two parameters to control the anisotropy of the specular reflection, namely `Ax, Ay` in the following Wards equation.

Where:

• The specular term is zero if dot(N, L) < 0 or dot(N, R) < 0.
• The vector R is the mirror reflection of the light vector off the surface.
• L is the direction from the surface point to the light.
• H is the half-angle direction.
• N is the surface normal.
• X and Y are two orthogonal vectors in the normal plane which specify the anisotropic directions, the tangent and bitangent vectors can be used as the `X,Y` vectors, especially that the tangent space is so common in computer graphics that could be calculated in any engine (usually calculated based on texture coords).

Notice in the image, how the specular lighting is directional unlike the common Phong specular light. Here is an article on the Ward model and how to achieve different effects. EDIT More information on the suitability of BRDF in terms reducing the light intensity closer to the viewer, can be found here.

Finally another (optional) two points that I guess could add to the final image,

• First I am sure using ambient occlusion will help getting more believable results.
• The second is that implementing some kind of Fresnel reflection could add a nice effect to the image, especially in water and ice scenes.
-
+1 Good answer concept3d, and I'm a bit sorry you went to all the effort to write it -- @JoshPetrie modified the title of my question from "WHAT (is this shader)" to "HOW (do I construct it)". So your efforts may be somewhat in vain, nonetheless it seems to have done good things for your rep, and it's a good resource. – Arcane Engineer Dec 20 '13 at 22:14
@NickWiggill no problem, it will remain here as a good resource :) – concept3d Dec 20 '13 at 22:24
@JoshPetrie eventhough the edit somehow invalidated my answer, the question in its current form is a bit more reasonable. – concept3d Dec 20 '13 at 22:26
I'm going to accept yours instead. The reason is that you mention BRDF and that is exactly the sort of concept I had in mind, and having read through it, I can see that this is precisely what I need. I've edited your answer with more detail on BRDF. – Arcane Engineer Dec 20 '13 at 22:40

The reflection itself is just the specular reflection that you get as an output of the functions of your specific illumination model.

There are many different illumination models of varying levels of complexity that will produce a reflection shape similar to this, but a similar look to this can already be achieved with a simple bare bones blinn-phong lighting model, which is (now) probably the most basic lighting model used by graphics engines, and most likely also used by World of Warcraft.

It will not be physically correct and completely equal to your images, but it will look very similar. Concept3D's example of the Ward model is more physically correct and works for more complex surface types (namely, materials where the microscopic bumps in their surfaces are not uniformly distributed, but have different probability distributions), but I don't know of any concrete examples of real time renderers that use it, due to poor gains in terms of quality/performance.

In practice, such types of reflections on surfaces are supplemented by additional specular/gloss and normal textures, that modify the shininess/roughness of a surface, and the direction of the normals of the surface, respectively, which are both inputs to the lighting equations of typical lighting models. This is done because in the real world, the physical properties of surface most often (except for maybe something like plastic, or a mirror) don't stay the same all over the surface, but can vary wildly from pixel to pixel.

-
Right, thanks Travis. Do you foresee there being any problems whatsoever with my using blinn+phong along with some kind of a mask texture to render pixels only where necessary on the terrain, thus creating the graininess underlying the specular reflection? – Arcane Engineer Dec 20 '13 at 21:02
If those pixels are not lit at all after being discarded due to the mask texture, it will probably look wrong/weird. The usual way is indeed a combination of a bump map and a specular map for the surface that changes some of the inputs of the lighting equation. – TravisG Dec 20 '13 at 21:56

Specular bump mapping (normal mapping) or parallax mapping.

-
Fleshing this out with evidence or references would make it a much better answer. – Byte56 Dec 20 '13 at 19:00