diff --git a/src/Data/Preload/Render.hs b/src/Data/Preload/Render.hs index 06188df05..afc8be17d 100644 --- a/src/Data/Preload/Render.hs +++ b/src/Data/Preload/Render.hs @@ -33,6 +33,7 @@ data RenderData = RenderData , _fboFourth1 :: (FramebufferObject, TextureObject) , _fboFourth2 :: (FramebufferObject, TextureObject) , _fboBase :: (FramebufferObject, (TextureObject, TextureObject)) + , _fboCloud :: (FramebufferObject, (TextureObject, TextureObject)) , _fboBloom :: (FramebufferObject, TextureObject) , _fboColor :: (FramebufferObject, TextureObject) , _fboPos :: (FramebufferObject, TextureObject) diff --git a/src/Dodge/Render.hs b/src/Dodge/Render.hs index 4ff5bb3d2..3c621496c 100644 --- a/src/Dodge/Render.hs +++ b/src/Dodge/Render.hs @@ -101,6 +101,7 @@ doDrawing pdata w = do renderLayer 3 shadV layerCounts depthMask $= Enabled renderLayer 1 shadV layerCounts + --setup downscale viewport for blurring bloom viewport $= (Position 0 0 , divideSize (2 * (w ^. config . shadow_resolution)) $ Size (round $ fstV2 wins) (round $ sndV2 wins)) @@ -114,32 +115,52 @@ doDrawing pdata w = do viewport $= (Position 0 0 , divideSize (w ^. config . shadow_resolution) $ Size (round $ fstV2 wins) (round $ sndV2 wins)) + --draw lightmap for base buffer bindFramebuffer Framebuffer $= fst (_fboLighting pdata) - createLightMap pdata lightPoints nWalls nSils nCaps + createLightMap pdata lightPoints nWalls nSils nCaps (snd $ snd $ _fboBase pdata) colorMask $= Color4 Enabled Enabled Enabled Enabled clearColor $= Color4 0 0 0 0 - bindFramebuffer Framebuffer $= fst (_fboColor pdata) + --apply lightmap to base buffer + bindFramebuffer Framebuffer $= fst (_fboBase pdata) + textureBinding Texture2D $= Just (snd $ _fboLighting pdata) + blend $= Enabled + blendFunc $= (Zero, OneMinusSrcColor) + drawShader (_fullscreenShader pdata) 4 + blendFunc $= (SrcAlpha, OneMinusSrcAlpha) + + --draw clouds + bindFramebuffer Framebuffer $= fst (_fboCloud pdata) depthFunc $= Just Lequal depthMask $= Disabled - --blendFuncSeparate $= ((OneMinusDstAlpha,OneMinusSrcAlpha),(One,OneMinusSrcAlpha)) - --blendFunc $= (One,OneMinusSrcAlpha) - --blendFunc $= (SrcAlpha,One) - --blendFunc $= (SrcAlphaSaturate,One) - --blendFunc $= (SrcAlphaSaturate,OneMinusSrcAlpha) - blendColor $= Color4 1 1 1 0.80 - blendFuncSeparate $= ((SrcAlphaSaturate,One),(ConstantAlpha,ConstantAlpha)) - --blendFunc $= (SrcAlphaSaturate,SrcAlphaSaturate) clearColor $= Color4 0.5 0.5 0.5 0 - clear [ColorBuffer] - blendFunc $= (SrcAlpha,OneMinusSrcAlpha) + --blendFunc $= (SrcAlphaSaturate,One) blendFuncSeparate $= ((SrcAlpha,OneMinusSrcAlpha),(One,OneMinusSrcAlpha)) - --blendFuncSeparate $= ((SrcAlphaSaturate,OneMinusSrcAlpha),(One,OneMinusSrcAlpha)) + drawBuffers $= [FBOColorAttachment 0,NoBuffers] + clear [ColorBuffer] renderLayer 2 shadV layerCounts renderWindows pdata windowPoints - clearColor $= Color4 0 0 0 0 + + ----render transparency depths depthMask $= Enabled + blend $= Disabled + drawBuffers $= [NoBuffers,FBOColorAttachment 1] + renderLayer 2 shadV layerCounts + renderWindows pdata windowPoints depthMask $= Disabled + blend $= Enabled + + ----draw lightmap for cloud buffer + bindFramebuffer Framebuffer $= fst (_fboLighting pdata) + createLightMap pdata lightPoints nWalls nSils nCaps (snd $ snd $ _fboCloud pdata) + colorMask $= Color4 Enabled Enabled Enabled Enabled + clearColor $= Color4 0 0 0 0 + + --apply lightmap to cloud buffer + clearColor $= Color4 0 0 0 0 + bindFramebuffer Framebuffer $= fst (_fboCloud pdata) + depthMask $= Disabled + drawBuffers $= [FBOColorAttachment 0,NoBuffers] depthFunc $= Just Always textureBinding Texture2D $= Just (snd $ _fboLighting pdata) blend $= Enabled @@ -147,34 +168,20 @@ doDrawing pdata w = do blendFuncSeparate $= ((Zero, OneMinusSrcColor),(Zero, One)) drawShader (_fullscreenShader pdata) 4 blendFunc $= (SrcAlpha, OneMinusSrcAlpha) --- renderLayer 4 shadV layerCounts --- renderLayer 5 shadV layerCounts - --blend $= Disabled depthMask $= Disabled depthFunc $= Just Always + --Draw blurred bloom onto base buffer bindFramebuffer Framebuffer $= fst (_fboBase pdata) - --drawShader (_fullscreenShader pdata) 4 - --textureBinding Texture2D $= Just (snd3 $ _fbo2 pdata) - textureBinding Texture2D $= Just (snd $ _fboLighting pdata) blend $= Enabled - --blendFunc $= (Zero, OneMinusSrcAlpha) - blendFunc $= (Zero, OneMinusSrcColor) - drawShader (_fullscreenShader pdata) 4 - blendFunc $= (SrcAlpha, OneMinusSrcAlpha) - - --drawShader (_colorBlurShader pdata) 4 blendFunc $= (SrcAlpha, One) textureBinding Texture2D $= Just (snd $ _fboFourth1 pdata) drawShader (_fullscreenShader pdata) 4 blendFunc $= (SrcAlpha, OneMinusSrcAlpha) --- textureBinding Texture2D $= Just (snd $ _fboBloom pdata) --- drawShader (_fullscreenShader pdata) 4 - textureBinding Texture2D $= Just (snd $ _fboColor pdata) + textureBinding Texture2D $= Just (fst $ snd $ _fboCloud pdata) drawShader (_fullscreenShader pdata) 4 - --renderLayer 2 shadV layerCounts depthFunc $= Just Lequal viewport $= (Position 0 0, Size (round $ fstV2 wins) (round $ sndV2 wins)) diff --git a/src/Framebuffer/Update.hs b/src/Framebuffer/Update.hs index cd8fc5f83..7ef2a56dd 100644 --- a/src/Framebuffer/Update.hs +++ b/src/Framebuffer/Update.hs @@ -23,7 +23,7 @@ sizeFBOs -> IO RenderData sizeFBOs xsize ysize xfull yfull rdata = do resizeRBO (_rboBaseBloom rdata) xsize ysize - rdata' <- updateFBOTO2 xsize ysize linMinMagFilter GL_RGBA8 GL_RGBA16F rdata fboBase + rdata' <- foldM (updateFBOTO2 xsize ysize linMinMagFilter GL_RGBA8 GL_RGBA16F) rdata [fboBase,fboCloud] >>= flip (foldM (updateFBOTO xsize ysize minMagFilter GL_RGBA8)) [fboColor,fboLighting,fboLightingHigh] rdata'' <- foldM (updateFBOTO xsize ysize linMinMagFilter GL_RGBA16F) rdata' diff --git a/src/Preload/Render.hs b/src/Preload/Render.hs index fa4945db7..27c92fd12 100644 --- a/src/Preload/Render.hs +++ b/src/Preload/Render.hs @@ -107,6 +107,7 @@ preloadRender = do renderbufferStorage Renderbuffer Depth24Stencil8 (RenderbufferSize 800 600) fboBaseName <- setupFramebuffer2GivenStencil rboBaseBloomName + fboCloudName <- setupFramebuffer2GivenStencil rboBaseBloomName fboBloomName <- setupFramebufferGivenStencil rboBaseBloomName fboColorName <- setupFramebufferGivenStencil rboBaseBloomName fboPosName <- setupFramebufferGivenStencil rboBaseBloomName @@ -157,6 +158,7 @@ preloadRender = do , _fboLightingHigh = fboLightingHighName --, _rboLighting = rboLightingName , _fboBase = fboBaseName + , _fboCloud = fboCloudName , _fboBloom = fboBloomName , _fboColor = fboColorName , _fboPos = fboPosName diff --git a/src/Render.hs b/src/Render.hs index 955c42a74..052f64901 100644 --- a/src/Render.hs +++ b/src/Render.hs @@ -37,8 +37,9 @@ createLightMap -> Int -- ^ number of walls -> Int -- ^ number of silhoutte lines to draw -> Int -- ^ number of "caps" to attempt to draw + -> TextureObject -- ^ the texture object giving positions -> IO () -createLightMap pdata lightPoints nWalls nSils nCaps = do +createLightMap pdata lightPoints nWalls nSils nCaps toPos = do -- we assume that the renderbuffer's depth has been correctly set elsewhere -- we will not be changing that here depthMask $= Disabled @@ -79,7 +80,7 @@ createLightMap pdata lightPoints nWalls nSils nCaps = do --draw lightmap itself depthFunc $= Just Always cullFace $= Nothing - bindTO $ snd $ snd $ _fboBase pdata + bindTO toPos colorMask $= Color4 Enabled Enabled Enabled Enabled stencilOp $= (OpKeep,OpKeep,OpKeep) stencilFunc $= (Equal, 0, 255)