Add blurring of lightmap (and refactoring)
This commit is contained in:
+39
-8
@@ -61,13 +61,14 @@ createLightMap
|
||||
-> (Float,Float) -- View from position
|
||||
-> GLmatrix GLfloat
|
||||
-> IO ()
|
||||
createLightMap pdata resDiv wallPoints lightPoints
|
||||
(viewFromx,viewFromy) pmat = do
|
||||
createLightMap pdata resDiv wallPoints lightPoints (viewFromx,viewFromy) pmat = do
|
||||
|
||||
(vppos,vpsize) <- get viewport
|
||||
-- set the viewport size to that of the render buffer
|
||||
viewport $= (vppos, divideSize resDiv vpsize)
|
||||
|
||||
bindFramebuffer Framebuffer $= _spareFBO pdata
|
||||
|
||||
-- store wall and light positions into buffer
|
||||
nWallLights <- F.foldM (pokeShader $ _lightingWallShader pdata) wallPoints
|
||||
bindShaderBuffers [_lightingWallShader pdata] [nWallLights]
|
||||
@@ -84,7 +85,6 @@ createLightMap pdata resDiv wallPoints lightPoints
|
||||
depthFunc $= Just Less
|
||||
-- draw walls from your point of view in order to set z buffer
|
||||
colorMask $= Color4 Disabled Disabled Disabled Disabled
|
||||
-- let (tx,ty) = (tranx,trany) -.- (viewFromx,viewFromy)
|
||||
currentProgram $= Just (_shaderProgram $ _lightingOccludeShader pdata)
|
||||
uniform (head $ fromJust $ _shaderCustomUnis $ _lightingOccludeShader pdata)
|
||||
$= Vector2 viewFromx viewFromy
|
||||
@@ -136,20 +136,51 @@ createLightMap pdata resDiv wallPoints lightPoints
|
||||
cullFace $= Nothing
|
||||
stencilTest $= Disabled
|
||||
blend $= Disabled
|
||||
|
||||
-- set the viewport size to that of the window
|
||||
viewport $= (vppos, vpsize)
|
||||
bindFramebuffer Framebuffer $= defaultFramebufferObject
|
||||
bindFramebuffer Framebuffer $= fst (_fbo2 pdata)
|
||||
colorMask $= Color4 Disabled Disabled Disabled Enabled
|
||||
bindShaderBuffers [_fullscreenShader pdata] [4]
|
||||
bindShaderBuffers [_boxBlurShader pdata] [4]
|
||||
textureBinding Texture2D $= Just (_fboTexture pdata)
|
||||
-- by upscaling the shadowmap texture and using Linear' magnification
|
||||
-- interpolation, we get a poor mans blur
|
||||
textureBinding Texture2D $= Just (_fboTexture pdata)
|
||||
textureFilter Texture2D $= ((Linear',Just Linear') , Linear')
|
||||
-- not sure about the perforamnce implications ^^^
|
||||
generateMipmap' Texture2D
|
||||
drawShader (_fullscreenShader pdata) 4
|
||||
-- not sure about the performance implications ^^^
|
||||
drawShader (_boxBlurShader pdata) 4
|
||||
|
||||
bindFramebuffer Framebuffer $= fst (_fbo3 pdata)
|
||||
textureBinding Texture2D $= Just (snd $ _fbo2 pdata)
|
||||
textureFilter Texture2D $= ((Linear',Just Linear') , Linear')
|
||||
generateMipmap' Texture2D
|
||||
drawShader (_boxBlurShader pdata) 4
|
||||
|
||||
replicateM_ 2 $ pingPongBlur pdata
|
||||
|
||||
bindFramebuffer Framebuffer $= defaultFramebufferObject
|
||||
textureBinding Texture2D $= Just (snd $ _fbo3 pdata)
|
||||
textureFilter Texture2D $= ((Linear',Just Linear') , Linear')
|
||||
generateMipmap' Texture2D
|
||||
drawShader (_boxBlurShader pdata) 4
|
||||
|
||||
colorMask $= Color4 Enabled Enabled Enabled Enabled
|
||||
blend $= Enabled
|
||||
|
||||
pingPongBlur :: RenderData -> IO ()
|
||||
pingPongBlur pdata = do
|
||||
bindFramebuffer Framebuffer $= fst (_fbo2 pdata)
|
||||
textureBinding Texture2D $= Just (snd $ _fbo3 pdata)
|
||||
textureFilter Texture2D $= ((Linear',Just Linear') , Linear')
|
||||
generateMipmap' Texture2D
|
||||
drawShader (_boxBlurShader pdata) 4
|
||||
|
||||
bindFramebuffer Framebuffer $= fst (_fbo3 pdata)
|
||||
textureBinding Texture2D $= Just (snd $ _fbo2 pdata)
|
||||
textureFilter Texture2D $= ((Linear',Just Linear') , Linear')
|
||||
generateMipmap' Texture2D
|
||||
drawShader (_boxBlurShader pdata) 4
|
||||
|
||||
renderBackground
|
||||
:: RenderData
|
||||
-> Float -- Rotation
|
||||
|
||||
Reference in New Issue
Block a user