Fix wall depth rendering
This commit is contained in:
+2
-2
@@ -722,13 +722,13 @@ crInPolygon :: Creature -> [Point2] -> Bool
|
|||||||
crInPolygon cr xs = errorPointInPolygon 3 (_crPos cr) xs
|
crInPolygon cr xs = errorPointInPolygon 3 (_crPos cr) xs
|
||||||
|
|
||||||
onLayer :: Layer -> Picture -> Picture
|
onLayer :: Layer -> Picture -> Picture
|
||||||
onLayer l = setDepth (fromIntegral (levLayer l) / 100)
|
onLayer l = setDepth $ 1 - fromIntegral (levLayer l) / 100
|
||||||
|
|
||||||
--onLayer :: Layer -> Picture -> [(Picture, [Int])]
|
--onLayer :: Layer -> Picture -> [(Picture, [Int])]
|
||||||
--onLayer l p = [(p, [levLayer l])]
|
--onLayer l p = [(p, [levLayer l])]
|
||||||
|
|
||||||
onLayerL :: [Int] -> Picture -> Picture
|
onLayerL :: [Int] -> Picture -> Picture
|
||||||
onLayerL is = setDepth ((sum $ zipWith (/) (map fromIntegral is) $ map (\x->100**x) [1..]))
|
onLayerL is = setDepth (1 - (sum $ zipWith (/) (map fromIntegral is) $ map (\x->100**x) [1..]))
|
||||||
|
|
||||||
levLayer :: Layer -> Int
|
levLayer :: Layer -> Int
|
||||||
levLayer BgLayer = 20
|
levLayer BgLayer = 20
|
||||||
|
|||||||
@@ -29,9 +29,9 @@ fixedCoordPictures :: World -> Picture
|
|||||||
fixedCoordPictures w = pictures
|
fixedCoordPictures w = pictures
|
||||||
[ scaler $ hudDrawings w
|
[ scaler $ hudDrawings w
|
||||||
, scaler $ onLayer MenuLayer menuScreen
|
, scaler $ onLayer MenuLayer menuScreen
|
||||||
, setDepth 1 $ closeObjectTexts w
|
, setDepth (-1) $ closeObjectTexts w
|
||||||
]
|
]
|
||||||
where scaler = setDepth 1 . scale (2 / _windowX w) (2 / _windowY w)
|
where scaler = setDepth (-1) . scale (2 / _windowX w) (2 / _windowY w)
|
||||||
menuScreen :: Picture
|
menuScreen :: Picture
|
||||||
menuScreen = case _menuState w of
|
menuScreen = case _menuState w of
|
||||||
InGame -> blank
|
InGame -> blank
|
||||||
@@ -300,7 +300,7 @@ lineOnScreen w (p1:p2:_) = errorPointInPolygon 8 p1 sp || errorPointInPolygon 9
|
|||||||
drawWallFace :: World -> Wall -> Picture
|
drawWallFace :: World -> Wall -> Picture
|
||||||
drawWallFace w wall
|
drawWallFace w wall
|
||||||
| isRHS sightFrom x y || _wlIsSeeThrough wall = blank
|
| isRHS sightFrom x y || _wlIsSeeThrough wall = blank
|
||||||
| otherwise = setLayer 3 . setDepth 1 . polygon $ points
|
| otherwise = setLayer 3 . setDepth (-1) . polygon $ points
|
||||||
where
|
where
|
||||||
(x:y:_) = _wlLine wall
|
(x:y:_) = _wlLine wall
|
||||||
points = extendConeToScreenEdge w sightFrom (x,y)
|
points = extendConeToScreenEdge w sightFrom (x,y)
|
||||||
|
|||||||
+1
-1
@@ -132,7 +132,7 @@ translate x y pic = OverPic (translate3 x y) id 0 id pic
|
|||||||
|
|
||||||
setDepth :: Float -> Picture -> Picture
|
setDepth :: Float -> Picture -> Picture
|
||||||
{-# INLINE setDepth #-}
|
{-# INLINE setDepth #-}
|
||||||
setDepth d pic = OverPic (\(x,y,_) -> (x,y,-d)) id 0 id pic
|
setDepth d pic = OverPic (\(x,y,_) -> (x,y,d)) id 0 id pic
|
||||||
|
|
||||||
setLayer :: Int -> Picture -> Picture
|
setLayer :: Int -> Picture -> Picture
|
||||||
{-# INLINE setLayer #-}
|
{-# INLINE setLayer #-}
|
||||||
|
|||||||
@@ -53,14 +53,6 @@ renderPicture' pdata rot zoom trans@(tranx,trany) wins@(winx,winy) wallPointsCol
|
|||||||
|
|
||||||
renderWalls pdata wallPointsCol pmat
|
renderWalls pdata wallPointsCol pmat
|
||||||
|
|
||||||
renderWalls pdata windowPoints pmat
|
|
||||||
|
|
||||||
-- hack: the walls are drawn with a continuous depth from 0 to -1
|
|
||||||
-- the following call is aimed at setting the depth buffer over all the walls to
|
|
||||||
-- at most -0.9
|
|
||||||
colorMask $= (Color4 Disabled Disabled Disabled Disabled)
|
|
||||||
renderFoldable pdata $ picToLTree (Just 3) pic
|
|
||||||
colorMask $= (Color4 Enabled Enabled Enabled Enabled)
|
|
||||||
|
|
||||||
depthFunc $= Just Lequal
|
depthFunc $= Just Lequal
|
||||||
|
|
||||||
@@ -76,6 +68,8 @@ renderPicture' pdata rot zoom trans@(tranx,trany) wins@(winx,winy) wallPointsCol
|
|||||||
|
|
||||||
renderFoldable pdata $ picToLTree (Just 2) pic
|
renderFoldable pdata $ picToLTree (Just 2) pic
|
||||||
|
|
||||||
|
renderWalls pdata windowPoints pmat
|
||||||
|
|
||||||
resetShaderUniforms (map extractProgAndUnis $ _listShaders pdata)
|
resetShaderUniforms (map extractProgAndUnis $ _listShaders pdata)
|
||||||
endTicks <- SDL.ticks
|
endTicks <- SDL.ticks
|
||||||
return (ticksAfterLighting, endTicks - startTicks)
|
return (ticksAfterLighting, endTicks - startTicks)
|
||||||
|
|||||||
Reference in New Issue
Block a user