Code archives/3D Graphics - Misc/New Terrain LightMapper
This code has been declared by its author to be Public Domain code.
Download source code
| New and Improved and does exactly what it says on the tin. Download the files from here as there are some includes. http://www.morphlings.com/tim/terrainmapper.zip |
; ******************************* Terrain Shadow Lab ****************************** Include "Level_Shadow.bb" Global gWidth = 640 Global gHeight = 480 Global InMap$ = "levelterrain123.bmp" ; Your Height Map Global OutMap$ = "shadowmap.bmp" ; The Output File Global Sun.Vector = Vector(1,2,-1) ; Position of the Sun IN VECTORS! Global InImage Global OutImage Graphics gWidth,gHeight,32,2 InImage = LoadImage(InMap$) MapSize = ImageWidth(InImage) LEV_SHAD_Initialise(InImage,MapSize) ; Put all map info into an array CalcNormalMap(MapSize) ; calculate Map Normals for precise lighting Start = MilliSecs() OutImage = LEV_SHAD_RenderLMAP(Sun,MapSize) ; Render LightMap According to Sun Position Timenow = MilliSecs() - Start SaveImage (OutImage,Outmap$) SetBuffer BackBuffer() DrawImage InImage,0,0 DrawImage OutImage,MapSize,0 Text 0,Mapsize+10,"Time : " + Timenow Flip WaitKey() |