Reduce number of wall points sent for shadows

This commit is contained in:
jgk
2021-02-27 02:27:43 +01:00
parent 3b4b387943
commit 33ebc1556d
2 changed files with 23 additions and 7 deletions
+15 -3
View File
@@ -559,11 +559,11 @@ displayHP n w = translate (halfWidth w-70) (halfHeight w-40) $
testPic w = blank
wallsForGloom' :: World -> [(Point2,Point2,Point2,Point2)]
wallsForGloom' w = map (wallPairToFour . _wlLine) $ filter (not . _wlIsSeeThrough)
wallsForGloom' :: World -> [(Point2,Point2)]
wallsForGloom' w = map (wallPairBack . _wlLine) $ filter (not . _wlIsSeeThrough)
$ IM.elems $ wallsNearZones (zoneOfDoubleScreen w) w
where wallPairToFour (x:y:_) = (ss x,ss y,ss $ x +.+ n,ss $ y+.+ n)
where wallPairBack (x:y:_) = (ss $ x +.+ n,ss $ y+.+ n)
where n = 15 *.* (normalizeV $ vNormal $ y -.- x)
ss' v = rotateV (0 - _cameraRot w) (v -.- _cameraPos w)
ss'' (a,b) = (a*2*zoom / _windowX w,b*2*zoom / _windowY w)
@@ -571,6 +571,18 @@ wallsForGloom' w = map (wallPairToFour . _wlLine) $ filter (not . _wlIsSeeThroug
-- the ss transformation would possibly be better done using a matrix in the
-- shader
zoom = _cameraZoom w
--wallsForGloom' :: World -> [(Point2,Point2,Point2,Point2)]
--wallsForGloom' w = map (wallPairToFour . _wlLine) $ filter (not . _wlIsSeeThrough)
-- $ IM.elems $ wallsNearZones (zoneOfDoubleScreen w) w
--
-- where wallPairToFour (x:y:_) = (ss x,ss y,ss $ x +.+ n,ss $ y+.+ n)
-- where n = 15 *.* (normalizeV $ vNormal $ y -.- x)
-- ss' v = rotateV (0 - _cameraRot w) (v -.- _cameraPos w)
-- ss'' (a,b) = (a*2*zoom / _windowX w,b*2*zoom / _windowY w)
-- ss = ss'' . ss'
---- the ss transformation would possibly be better done using a matrix in the
---- shader
-- zoom = _cameraZoom w
lightsForGloom' :: World -> [(Point4)]
lightsForGloom' w = map getLS (IM.elems $ _lightSources w) ++ map getTLS (_tempLightSources w)
+8 -4
View File
@@ -297,8 +297,10 @@ threePtrsVAO vao = case (\(_,ps,_) -> ps) $ unzip3 $ _vaoBufferTargets vao of
renderPicture' :: RenderData -> Float -> Float -> (Float,Float) -> (Float,Float) ->
[(Point2,Point2,Point2,Point2)] -> [Point4] -> Picture -> IO (Word32,Word32)
[(Point2,Point2)] -> [Point4] -> Picture -> IO (Word32,Word32)
renderPicture' pdata rot zoom (tranx,trany) (winx,winy) wallPoints lightPoints pic = do
ticksAfterL <- SDL.ticks
startWallTicks <- SDL.ticks
depthFunc $= Just Lequal
aticks <- SDL.ticks
@@ -343,7 +345,7 @@ renderPicture' pdata rot zoom (tranx,trany) (winx,winy) wallPoints lightPoints p
bindVertexArrayObject $= Just (_vao $ _wallVAO pdata)
let wallPtr = (\(_,x,_) -> x) $ head $ _vaoBufferTargets $ _wallVAO pdata
-- wallPtr2 = (\(_,x,_) -> x) $ (_vaoBufferTargets $ _wallVAO pdata) !! 1
foldWalls n ((x,y),(z,w),(a,b),(c,d)) = do
foldWalls n ((x,y),(z,w)) = do
pokeFourOff wallPtr n (x,y,z,w)
-- pokeFourOff wallPtr2 n (a,b,c,d)
return $ n+1
@@ -366,7 +368,8 @@ renderPicture' pdata rot zoom (tranx,trany) (winx,winy) wallPoints lightPoints p
bindArrayBuffers (1) $ _vaoBufferTargets $ _fadeCircVAO pdata
blendFuncSeparate $= ((Zero,Zero),(Zero, OneMinusSrcAlpha))
drawArrays Points (fromIntegral 0) (fromIntegral 1)
ticksAfterL <- SDL.ticks
-- ticksAfterL <- SDL.ticks
endWallTicks <- SDL.ticks
-- draw picture
-- set drawing for on top
blendFuncSeparate $= ((SrcAlphaSaturate, OneMinusSrcAlpha), (Zero,One))
@@ -400,7 +403,8 @@ renderPicture' pdata rot zoom (tranx,trany) (winx,winy) wallPoints lightPoints p
uniform (snd shad !! 2) $= (0::Float)
uniform (snd shad !! 3) $= Vector2 (0::Float) 0
uniform (snd shad !! 4) $= idmat
return (ticksAfterL, ticks2+ticks3+ticks4)
--return (ticksAfterL, ticks2+ticks3+ticks4, endWallTicks - startWallTicks)
return (ticksAfterL, endWallTicks - startWallTicks)
bufferOffset :: Integral a => a -> Ptr b
bufferOffset = plusPtr nullPtr . fromIntegral