night creature, that solution worked great, so light should be from 0 to 1... and saturate clams values from 0 to 1... and if a number tend to go way below 0 is hard to get them up to do something ... got it now.
the other question I have is, how come some areas are hard to be differentiated, I know I still need shadows but seems like something is still missing here.
look at center of the following image, you can hardly tell there are cubes here.
[attachment=7992:shaded test3.png]
Ok, so you are reading that book.Yaay.
I'd suggest attenuation, but directional lights don't have that, being just a direction and not a position. It's useful to know, though, so I'll go ahead and explain it.
Attenuation, in this context, is the reduction in light levels from being farther from the light. It is calculated as:
Attenuation = 1.0 / ( ( Constant ) + ( Linear * Distance ) + ( Quadratic * Distance * Distance ) )
You then multiply this by your light colour. If you don't saturate attenuation, but do saturate the final light colour, near areas saturate to white. You may or may not want this automatic effect.
Now, to explain it, including the probably-obvious stuff, just to be thorough:
Constant provides a flat reduction (or increase, for less than 1.0) in light.
Linear divides your light by some multiple of distance. It provides a steady and quite useful reduction in light.
Quadratic is physically realistic; it mirrors the formula for energy "loss" over distance. It reduces your light by the square of the distance, multiplied by some value.
Distance is the distance to a vertex (for vertex lighting; much less accurate, but much faster) or a pixel (for pixel lighting; much more accurate, but much slower).
Put them all together and you have a complete equation for attenuation.
Now, what you're missing right now is probably fog. Simple fog works like this:
Position := CameraPosition
Attenuation := Attenuation formula
Colour := A float4 Colour.
Range := Anything beyond this doesn't need to be drawn.
On := a true/false switch.
Position is the center of your fog fading; this should be your camera position for most instances.
You then use that as follows:
Distance := Pixel/Vertex position - Fog.Position
Interpolation := Attenuation (we're going to use this to fade from easily visible to fogged).
Output.Colour := Saturate( (Colour you calculated * Interpolation ) + ( Fog.Colour * ( 1.0 - Interpolation ) ) )
This is an alpha interpolation for fog; as distance increases, attenuation will also (provided you set either Linear or Quadratic to a positive number) decrease.
Since interpolation is equal to attenuation, as distance increases, the final colour will be closer to your fog colour.