From 33ebc1556da1a8cccf83fd8323e89ec2a9fb5ca3 Mon Sep 17 00:00:00 2001 From: jgk Date: Sat, 27 Feb 2021 02:27:43 +0100 Subject: [PATCH] Reduce number of wall points sent for shadows --- src/Dodge/Rendering.hs | 18 +++++++++++++++--- src/Picture/Render.hs | 12 ++++++++---- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/Dodge/Rendering.hs b/src/Dodge/Rendering.hs index 2eb29047b..4d3bb5b40 100644 --- a/src/Dodge/Rendering.hs +++ b/src/Dodge/Rendering.hs @@ -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) diff --git a/src/Picture/Render.hs b/src/Picture/Render.hs index bd2883b3d..c862d8403 100644 --- a/src/Picture/Render.hs +++ b/src/Picture/Render.hs @@ -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