Add blurring of lightmap (and refactoring)

This commit is contained in:
2021-05-01 02:28:04 +02:00
parent 9c0e4425da
commit 7711738b3b
33 changed files with 485 additions and 249 deletions
+28 -26
View File
@@ -1,6 +1,7 @@
module Dodge.LightSources where
import Dodge.Data
import Dodge.Base
import Dodge.Picture.Layer
import Dodge.LevelGen.Data
import Geometry
import Picture
@@ -16,36 +17,37 @@ lightAt p i =
}
basicLS = PutLS ls dec
where ls = lightAt (0,0) 0
dec = onLayer PtLayer $ color white $ circleSolid 8
where
ls = lightAt (0,0) 0
dec = onLayer PtLayer $ color white $ circleSolid 8
tLightFade :: Int -> Float -> (Int -> Float) -> Point2 -> TempLightSource
tLightFade 0 rmax intensityF p =
TLS { _tlsPos = p
, _tlsRad = rmax
, _tlsIntensity = intensityF 0
, _tlsUpdate = \w _ -> (w, Nothing)
}
tLightFade i rmax intensityF p =
TLS { _tlsPos = p
, _tlsRad = rmax
, _tlsIntensity = intensityF i
, _tlsUpdate = \w _ -> (w, Just $ tLightFade (i-1) rmax intensityF p)
}
tLightFade 0 rmax intensityF p = TLS
{ _tlsPos = p
, _tlsRad = rmax
, _tlsIntensity = intensityF 0
, _tlsUpdate = \w _ -> (w, Nothing)
}
tLightFade i rmax intensityF p = TLS
{ _tlsPos = p
, _tlsRad = rmax
, _tlsIntensity = intensityF i
, _tlsUpdate = \w _ -> (w, Just $ tLightFade (i-1) rmax intensityF p)
}
tLightRad :: Int -> Float -> Float -> Point2 -> TempLightSource
tLightRad 0 rmax rmin p =
TLS { _tlsPos = p
, _tlsRad = rmax
, _tlsIntensity = 0.5
, _tlsUpdate = \w _ -> (w, Nothing)
}
tLightRad i rmax rmin p =
TLS { _tlsPos = p
, _tlsRad = rmax
, _tlsIntensity = 0.5
, _tlsUpdate = \w _ -> (w, Just $ tLightRad (i-1) rmax rmin p)
}
tLightRad 0 rmax rmin p = TLS
{ _tlsPos = p
, _tlsRad = rmax
, _tlsIntensity = 0.5
, _tlsUpdate = \w _ -> (w, Nothing)
}
tLightRad i rmax rmin p = TLS
{ _tlsPos = p
, _tlsRad = rmax
, _tlsIntensity = 0.5
, _tlsUpdate = \w _ -> (w, Just $ tLightRad (i-1) rmax rmin p)
}
tLightAt i p = tLightRad i 100 0 p