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