Tweak fullscreen texture shaders
This commit is contained in:
+25
-22
@@ -63,10 +63,10 @@ createLightMap
|
||||
-> IO ()
|
||||
createLightMap pdata resDiv wallPoints lightPoints (viewFromx,viewFromy) pmat = do
|
||||
|
||||
-- get viewport size so we can reset it later
|
||||
(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
|
||||
@@ -132,54 +132,57 @@ createLightMap pdata resDiv wallPoints lightPoints (viewFromx,viewFromy) pmat =
|
||||
uniform (fromJust (_shaderCustomUnis $ _lightingWallShader pdata) !! 2)
|
||||
$= Vector2 r lum
|
||||
drawShader (_lightingWallShader pdata) nWallLights
|
||||
depthMask $= Enabled
|
||||
cullFace $= Nothing
|
||||
stencilTest $= Disabled
|
||||
blend $= Disabled
|
||||
|
||||
-- set the viewport size to that of the window
|
||||
viewport $= (vppos, vpsize)
|
||||
-- always want to draw lightmap
|
||||
depthFunc $= Just Always
|
||||
-- draw the lightmap on a full size fbo
|
||||
bindFramebuffer Framebuffer $= fst (_fbo2 pdata)
|
||||
colorMask $= Color4 Disabled Disabled Disabled Enabled
|
||||
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
|
||||
-- interpolation, we get a poor mans blur, not sure about performance
|
||||
textureFilter Texture2D $= ((Linear',Just Linear') , Linear')
|
||||
generateMipmap' Texture2D
|
||||
-- not sure about the performance implications ^^^
|
||||
drawShader (_boxBlurShader pdata) 4
|
||||
|
||||
-- ping pong blur between the two buffers as many times as desired
|
||||
replicateM_ 3 $ pingPongBlur pdata
|
||||
|
||||
-- draw the lightmap to the screen
|
||||
bindFramebuffer Framebuffer $= defaultFramebufferObject
|
||||
textureBinding Texture2D $= Just (snd $ _fbo2 pdata)
|
||||
textureFilter Texture2D $= ((Linear',Just Linear') , Linear')
|
||||
generateMipmap' Texture2D
|
||||
drawShader (_boxBlurShader pdata) 4
|
||||
|
||||
colorMask $= Color4 Enabled Enabled Enabled Enabled
|
||||
depthMask $= Enabled
|
||||
blend $= Enabled
|
||||
|
||||
{- |
|
||||
Blur between two framebuffers.
|
||||
Assumes no depth testing is done (depthFunc %= Just Always).
|
||||
-}
|
||||
pingPongBlur :: RenderData -> IO ()
|
||||
pingPongBlur pdata = do
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user