Work on distortion shaders
This commit is contained in:
@@ -28,7 +28,6 @@ data RenderData = RenderData
|
||||
, _silhouetteEBO :: UintBO
|
||||
, _pictureShaders :: MV.MVector (PrimState IO) (Shader,VBO)
|
||||
, _fbo2 :: (FBO, TO)
|
||||
, _fbo3 :: (FBO, TO)
|
||||
, _fboHalf1 :: (FBO, TO)
|
||||
, _fboHalf2 :: (FBO, TO)
|
||||
, _fboBase :: (FBO, (TO, TO, TO))
|
||||
|
||||
+14
-15
@@ -330,6 +330,7 @@ doDrawing' win pdata u = do
|
||||
glBlendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
|
||||
|
||||
-- bind base buffer for drawing clouds and bloom
|
||||
--
|
||||
glBindFramebuffer GL_FRAMEBUFFER (pdata ^. fboBase . _1 . unFBO)
|
||||
|
||||
glBlendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
|
||||
@@ -358,26 +359,24 @@ doDrawing' win pdata u = do
|
||||
setViewport (const FullRes) cfig
|
||||
glDepthFunc GL_ALWAYS
|
||||
glBlendFunc GL_ONE GL_ZERO
|
||||
-- perform any radial distortion
|
||||
-- perform distortions
|
||||
-- this is hideous
|
||||
case (getDistortions cfig w, cfig ^. gr_distortions) of
|
||||
(rds, x) | null rds || not x -> do
|
||||
case getDistortions cfig w of
|
||||
[] -> do
|
||||
glBindTextureUnit 0 $ pdata ^. fboBase . _2 . _1 . unTO
|
||||
glBindFramebuffer GL_FRAMEBUFFER 0
|
||||
glUseProgram (pdata ^. fullscreenShader)
|
||||
glDrawArrays GL_TRIANGLES 0 6
|
||||
(rds, _) -> do
|
||||
let bindDrawDist :: Distortion -> IO ()
|
||||
bindDrawDist (RadialDistortion (V2 a b) (V2 c d) (V2 e f) g) = do
|
||||
pokeArray (shadVBOptr $ _barrelShader pdata) [a, b, c, d, e, f, g]
|
||||
bufferPokedVBO (snd $ _barrelShader pdata) 1
|
||||
drawShader (fst $ _barrelShader pdata) 1
|
||||
fboList =
|
||||
take (length rds - 1) (concat (repeat [fst $ _fbo2 pdata, fst $ _fbo3 pdata]))
|
||||
++ [FBO 0]
|
||||
toList = (pdata ^. fboBase . _2 . _1) : concat (repeat [snd $ _fbo2 pdata, snd $ _fbo3 pdata])
|
||||
bindings = zipWith (>>) (map bindFBO fboList) (map (glBindTextureUnit 1 . _unTO) toList)
|
||||
zipWithM_ (>>) bindings $ map bindDrawDist rds
|
||||
(RadialDistortion (V2 a b) (V2 c d) (V2 e f) g:_) -> do
|
||||
glBindFramebuffer GL_FRAMEBUFFER (pdata ^. fbo2 . _1 . unFBO)
|
||||
pokeArray (shadVBOptr $ _barrelShader pdata) [a, b, c, d, e, f, g]
|
||||
bufferPokedVBO (snd $ _barrelShader pdata) 1
|
||||
glBindTextureUnit 1 $ pdata ^. fboBase . _2 . _1 . unTO
|
||||
drawShader (fst $ _barrelShader pdata) 1
|
||||
glBindTextureUnit 0 $ pdata ^. fbo2 . _2 . unTO
|
||||
glBindFramebuffer GL_FRAMEBUFFER 0
|
||||
glUseProgram (pdata ^. fullscreenShader)
|
||||
glDrawArrays GL_TRIANGLES 0 6
|
||||
glBlendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
|
||||
-- draw the overlay
|
||||
--glBindFramebuffer GL_FRAMEBUFFER (pdata ^. fboOverlay ._1 . unFBO)
|
||||
|
||||
@@ -61,7 +61,7 @@ sizeFBOs cfig rdata =
|
||||
GL_LINEAR_MIPMAP_LINEAR
|
||||
GL_LINEAR
|
||||
GL_RGBA8
|
||||
[fbo2, fbo3]
|
||||
[fbo2]
|
||||
>>= foldUpdateFBOTO
|
||||
_gr_downsize_res
|
||||
GL_LINEAR_MIPMAP_LINEAR
|
||||
|
||||
@@ -157,7 +157,6 @@ preloadRender = do
|
||||
fboLightingName <- setupFramebufferGivenStencil rboBaseBloomName
|
||||
|
||||
framebuf2 <- newTextureFramebuffer
|
||||
framebuf3 <- newTextureFramebuffer
|
||||
|
||||
fboHalf1Name <- newTextureFramebuffer
|
||||
fboHalf2Name <- newTextureFramebuffer
|
||||
@@ -186,7 +185,6 @@ preloadRender = do
|
||||
, _bloomBlurShader = bloomBlurShad
|
||||
, _barrelShader = barrelShad
|
||||
, _fbo2 = framebuf2
|
||||
, _fbo3 = framebuf3
|
||||
, _fboHalf1 = fboHalf1Name
|
||||
, _fboHalf2 = fboHalf2Name
|
||||
, _fboLighting = fboLightingName
|
||||
|
||||
Reference in New Issue
Block a user