Lighting for terrain


I have done height based color mapping for a terrain.When I set material property for a terrain the entire terrain is turning to the color.I calculated color in fragment shader through height based mapping.How to set material properties of the surface??By the way Im using blinn-phong model for directional lighting.

Thanks & Regards.

If I understand you correctly you are mixing Fixed Funtion stuff with shaders.

If you are doing lighting in shaders then you’ll also need to do material properties and the like in them too.

material properties

What are material properties for you?

ambient - 0.2,0.2,0.2
diffuse- 0.8,0.6,0.4

The entire mesh is turning into a single color.

If you use Blinn-Phong lighting model you should know that you need to compute normals of the terrain surface. Then will be able to shade correctly the terrain surface.