Well, you need a fair amount of code to use it -- some way to render the map, some way to generate the map, etc.
How I am using it is more or less like this (mostly pseudocode)
When I go to render it, I am actually only letting this shadowmap contribute 10% of the overall light, because it's a binary value -- either it's shadowed or it's not. So I blend in two other light levels. One is purely based on the elevation of the tile. The other is based on the gap between the highest and lowest corners of the tile.
Here it is with only the gap between highest and lowest -- basically, this is relief lighting. I am just using SetColor here to darken the quad.

Then if you add in the output of IntersectMap, you can see it does self-shadowing.

I am doing soft shadowing by overlaying four shadow blends onto each tile, one from each corner of the tile. Same idea as vertex colors, but DrawTextPoly doesn't have those. :) I query the light levels of the neighboring tiles, and pick a light level for that corner. Then I set the alpha for that blend, and repeat for each of the four corners. As you can see, my shadow blend tiles are not perfect. That's actually been the hardest part of this! You can see a sort of "grid effect" on the big shadowed hillside.

The last touch is a little trick that helps pop hills off of backgrounds with similar light levels -- an up to 10% penalty on light level based on elevation. This way ridges pop off, though the price is a slight darkening of the overall scene.

I call UpdateLights() whenever the sun moves, which I currently have on some hotkeys...
I am probably going to rework this so that instead of just drawing a black shadow texture with alpha, I'll draw a white one, and SetColor it to the right light level. Then I can add in a vertex color map into the mix without incurring any additional draw calls.
|