Slight cleanup

This commit is contained in:
2021-09-03 10:58:06 +01:00
parent 1bbeb926a5
commit 083000c103
9 changed files with 30 additions and 21 deletions
+19 -8
View File
@@ -45,7 +45,8 @@ doDrawing pdata w = do
let rot = _cameraRot w
camzoom = _cameraZoom w
trans = _cameraCenter w
wins = V2 (getWindowX w) (getWindowY w)
wins@(V2 winx winy) = V2 (getWindowX w) (getWindowY w)
resFact = w ^. config . resolution_factor
(wallPointsCol,windowPoints) = wallsAndWindows w
lightPoints = lightsForGloom w
viewFroms@(V2 vfx vfy) = _cameraViewFrom w
@@ -70,8 +71,9 @@ doDrawing pdata w = do
]
-- set the coordinate uniform ready for drawing elements using world coordinates
bufferUBO $ perspectiveMatrixb rot camzoom trans wins viewFroms
viewport $= (Position 0 0
, divideSize (w ^. config . shadow_resolution) $ Size (round $ fstV2 wins) (round $ sndV2 wins))
setViewportSize (round winx `div` resFact) (round winy `div` resFact)
-- viewport $= (Position 0 0
-- , divideSize (w ^. config . resolution_factor) $ Size (round $ fstV2 wins) (round $ sndV2 wins))
bindFramebuffer Framebuffer $= fst (_fboBase pdata)
clearColor $= Color4 0 0 0 0
clear [ColorBuffer,DepthBuffer]
@@ -117,8 +119,9 @@ doDrawing pdata w = do
renderLayer 1 shadV layerCounts
--depthMask $= Enabled
--setup downscale viewport for blurring bloom
viewport $= (Position 0 0
, divideSize (2 * (w ^. config . shadow_resolution)) $ Size (round $ fstV2 wins) (round $ sndV2 wins))
setViewportSize (round winx `div` (2*resFact)) (round winy `div` (2*resFact))
-- viewport $= (Position 0 0
-- , divideSize (2 * (w ^. config . resolution_factor)) $ Size (round $ fstV2 wins) (round $ sndV2 wins))
bindFramebuffer Framebuffer $= fst (_fboHalf1 pdata)
depthFunc $= Just Always
textureBinding Texture2D $= Just (snd $ _fboBloom pdata)
@@ -126,8 +129,9 @@ doDrawing pdata w = do
drawShader (_bloomBlurShader pdata) 4
replicateM_ 5 $ pingPongBetween (_fboHalf1 pdata) (_fboHalf2 pdata) (_bloomBlurShader pdata)
blend $= Enabled
viewport $= (Position 0 0
, divideSize (w ^. config . shadow_resolution) $ Size (round $ fstV2 wins) (round $ sndV2 wins))
setViewportSize (round winx `div` resFact) (round winy `div` resFact)
-- viewport $= (Position 0 0
-- , divideSize (w ^. config . resolution_factor) $ Size (round $ fstV2 wins) (round $ sndV2 wins))
--draw clouds
bindFramebuffer Framebuffer $= fst (_fboCloud pdata)
depthFunc $= Just Lequal
@@ -185,7 +189,8 @@ doDrawing pdata w = do
textureBinding Texture2D $= Just (fst $ snd $ _fboCloud pdata)
drawShader (_fullscreenShader pdata) 4
--set viewport for radial distortion
viewport $= (Position 0 0, Size (round $ fstV2 wins) (round $ sndV2 wins))
setViewportSize (round winx) (round winy)
--viewport $= (Position 0 0, Size (round $ fstV2 wins) (round $ sndV2 wins))
depthFunc $= Just Always
blendFunc $= (One,Zero)
-- perform any radial distortion
@@ -228,6 +233,12 @@ bufferUBO :: [Float] -> IO ()
bufferUBO mat = withArray mat $ \ptr ->
bufferSubData UniformBuffer WriteToBuffer 0 64 ptr
setViewportSize :: Int -> Int -> IO ()
setViewportSize x y = viewport $=
( Position 0 0
, Size (fromIntegral x) (fromIntegral y)
)
renderBlankWalls
:: RenderData
-> Int -- ^ number of walls