Original Post
Comments for the article 'Slope Lighting' Terrain
Dim sh As Integer 'Current Shadow Height
Dim x as Integer, y as Integer 'Looping Variables
Const MAP_RES as Integer = 128
Const SunHeight as Integer = 1 'Sun Slope Value, in this case, slope of 1, 45 degrees
For y = 0 To MAP_RES
sh = 0
For x = 0 To MAP_RES 'Flip this around to cast from the right, or switch order of For loops to cast from north or south
If sh < Heightmap(x, y) Then 'Terrain higher than current shadow height
Shadowmap(x, y) = 1 'Fullbright
sh = Heightmap(x, y) 'Cast shadow from current terrain height
Else
Shadowmap(x, y) = 0 'Shadowed
End If
sh = sh - SunHeight
Next x
Next y


This topic has been locked by a moderator. New replies are not allowed.
With your permission, GameDev.net uses analytics cookies to understand how people use the platform. You can accept analytics or continue with necessary cookies only. Learn more