Working shadows on clouds
This commit is contained in:
@@ -33,6 +33,7 @@ data RenderData = RenderData
|
|||||||
, _fboFourth1 :: (FramebufferObject, TextureObject)
|
, _fboFourth1 :: (FramebufferObject, TextureObject)
|
||||||
, _fboFourth2 :: (FramebufferObject, TextureObject)
|
, _fboFourth2 :: (FramebufferObject, TextureObject)
|
||||||
, _fboBase :: (FramebufferObject, (TextureObject, TextureObject))
|
, _fboBase :: (FramebufferObject, (TextureObject, TextureObject))
|
||||||
|
, _fboCloud :: (FramebufferObject, (TextureObject, TextureObject))
|
||||||
, _fboBloom :: (FramebufferObject, TextureObject)
|
, _fboBloom :: (FramebufferObject, TextureObject)
|
||||||
, _fboColor :: (FramebufferObject, TextureObject)
|
, _fboColor :: (FramebufferObject, TextureObject)
|
||||||
, _fboPos :: (FramebufferObject, TextureObject)
|
, _fboPos :: (FramebufferObject, TextureObject)
|
||||||
|
|||||||
+37
-30
@@ -101,6 +101,7 @@ doDrawing pdata w = do
|
|||||||
renderLayer 3 shadV layerCounts
|
renderLayer 3 shadV layerCounts
|
||||||
depthMask $= Enabled
|
depthMask $= Enabled
|
||||||
renderLayer 1 shadV layerCounts
|
renderLayer 1 shadV layerCounts
|
||||||
|
|
||||||
--setup downscale viewport for blurring bloom
|
--setup downscale viewport for blurring bloom
|
||||||
viewport $= (Position 0 0
|
viewport $= (Position 0 0
|
||||||
, divideSize (2 * (w ^. config . shadow_resolution)) $ Size (round $ fstV2 wins) (round $ sndV2 wins))
|
, 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
|
viewport $= (Position 0 0
|
||||||
, divideSize (w ^. config . shadow_resolution) $ Size (round $ fstV2 wins) (round $ sndV2 wins))
|
, divideSize (w ^. config . shadow_resolution) $ Size (round $ fstV2 wins) (round $ sndV2 wins))
|
||||||
|
|
||||||
|
--draw lightmap for base buffer
|
||||||
bindFramebuffer Framebuffer $= fst (_fboLighting pdata)
|
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
|
colorMask $= Color4 Enabled Enabled Enabled Enabled
|
||||||
clearColor $= Color4 0 0 0 0
|
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
|
depthFunc $= Just Lequal
|
||||||
depthMask $= Disabled
|
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
|
clearColor $= Color4 0.5 0.5 0.5 0
|
||||||
clear [ColorBuffer]
|
--blendFunc $= (SrcAlphaSaturate,One)
|
||||||
blendFunc $= (SrcAlpha,OneMinusSrcAlpha)
|
|
||||||
blendFuncSeparate $= ((SrcAlpha,OneMinusSrcAlpha),(One,OneMinusSrcAlpha))
|
blendFuncSeparate $= ((SrcAlpha,OneMinusSrcAlpha),(One,OneMinusSrcAlpha))
|
||||||
--blendFuncSeparate $= ((SrcAlphaSaturate,OneMinusSrcAlpha),(One,OneMinusSrcAlpha))
|
drawBuffers $= [FBOColorAttachment 0,NoBuffers]
|
||||||
|
clear [ColorBuffer]
|
||||||
renderLayer 2 shadV layerCounts
|
renderLayer 2 shadV layerCounts
|
||||||
renderWindows pdata windowPoints
|
renderWindows pdata windowPoints
|
||||||
clearColor $= Color4 0 0 0 0
|
|
||||||
|
----render transparency depths
|
||||||
depthMask $= Enabled
|
depthMask $= Enabled
|
||||||
|
blend $= Disabled
|
||||||
|
drawBuffers $= [NoBuffers,FBOColorAttachment 1]
|
||||||
|
renderLayer 2 shadV layerCounts
|
||||||
|
renderWindows pdata windowPoints
|
||||||
depthMask $= Disabled
|
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
|
depthFunc $= Just Always
|
||||||
textureBinding Texture2D $= Just (snd $ _fboLighting pdata)
|
textureBinding Texture2D $= Just (snd $ _fboLighting pdata)
|
||||||
blend $= Enabled
|
blend $= Enabled
|
||||||
@@ -147,34 +168,20 @@ doDrawing pdata w = do
|
|||||||
blendFuncSeparate $= ((Zero, OneMinusSrcColor),(Zero, One))
|
blendFuncSeparate $= ((Zero, OneMinusSrcColor),(Zero, One))
|
||||||
drawShader (_fullscreenShader pdata) 4
|
drawShader (_fullscreenShader pdata) 4
|
||||||
blendFunc $= (SrcAlpha, OneMinusSrcAlpha)
|
blendFunc $= (SrcAlpha, OneMinusSrcAlpha)
|
||||||
-- renderLayer 4 shadV layerCounts
|
|
||||||
-- renderLayer 5 shadV layerCounts
|
|
||||||
|
|
||||||
--blend $= Disabled
|
|
||||||
depthMask $= Disabled
|
depthMask $= Disabled
|
||||||
depthFunc $= Just Always
|
depthFunc $= Just Always
|
||||||
|
|
||||||
|
--Draw blurred bloom onto base buffer
|
||||||
bindFramebuffer Framebuffer $= fst (_fboBase pdata)
|
bindFramebuffer Framebuffer $= fst (_fboBase pdata)
|
||||||
--drawShader (_fullscreenShader pdata) 4
|
|
||||||
--textureBinding Texture2D $= Just (snd3 $ _fbo2 pdata)
|
|
||||||
textureBinding Texture2D $= Just (snd $ _fboLighting pdata)
|
|
||||||
blend $= Enabled
|
blend $= Enabled
|
||||||
--blendFunc $= (Zero, OneMinusSrcAlpha)
|
|
||||||
blendFunc $= (Zero, OneMinusSrcColor)
|
|
||||||
drawShader (_fullscreenShader pdata) 4
|
|
||||||
blendFunc $= (SrcAlpha, OneMinusSrcAlpha)
|
|
||||||
|
|
||||||
--drawShader (_colorBlurShader pdata) 4
|
|
||||||
blendFunc $= (SrcAlpha, One)
|
blendFunc $= (SrcAlpha, One)
|
||||||
textureBinding Texture2D $= Just (snd $ _fboFourth1 pdata)
|
textureBinding Texture2D $= Just (snd $ _fboFourth1 pdata)
|
||||||
drawShader (_fullscreenShader pdata) 4
|
drawShader (_fullscreenShader pdata) 4
|
||||||
blendFunc $= (SrcAlpha, OneMinusSrcAlpha)
|
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
|
drawShader (_fullscreenShader pdata) 4
|
||||||
--renderLayer 2 shadV layerCounts
|
|
||||||
depthFunc $= Just Lequal
|
depthFunc $= Just Lequal
|
||||||
|
|
||||||
viewport $= (Position 0 0, Size (round $ fstV2 wins) (round $ sndV2 wins))
|
viewport $= (Position 0 0, Size (round $ fstV2 wins) (round $ sndV2 wins))
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ sizeFBOs
|
|||||||
-> IO RenderData
|
-> IO RenderData
|
||||||
sizeFBOs xsize ysize xfull yfull rdata = do
|
sizeFBOs xsize ysize xfull yfull rdata = do
|
||||||
resizeRBO (_rboBaseBloom rdata) xsize ysize
|
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))
|
>>= flip (foldM (updateFBOTO xsize ysize minMagFilter GL_RGBA8))
|
||||||
[fboColor,fboLighting,fboLightingHigh]
|
[fboColor,fboLighting,fboLightingHigh]
|
||||||
rdata'' <- foldM (updateFBOTO xsize ysize linMinMagFilter GL_RGBA16F) rdata'
|
rdata'' <- foldM (updateFBOTO xsize ysize linMinMagFilter GL_RGBA16F) rdata'
|
||||||
|
|||||||
@@ -107,6 +107,7 @@ preloadRender = do
|
|||||||
renderbufferStorage Renderbuffer Depth24Stencil8 (RenderbufferSize 800 600)
|
renderbufferStorage Renderbuffer Depth24Stencil8 (RenderbufferSize 800 600)
|
||||||
|
|
||||||
fboBaseName <- setupFramebuffer2GivenStencil rboBaseBloomName
|
fboBaseName <- setupFramebuffer2GivenStencil rboBaseBloomName
|
||||||
|
fboCloudName <- setupFramebuffer2GivenStencil rboBaseBloomName
|
||||||
fboBloomName <- setupFramebufferGivenStencil rboBaseBloomName
|
fboBloomName <- setupFramebufferGivenStencil rboBaseBloomName
|
||||||
fboColorName <- setupFramebufferGivenStencil rboBaseBloomName
|
fboColorName <- setupFramebufferGivenStencil rboBaseBloomName
|
||||||
fboPosName <- setupFramebufferGivenStencil rboBaseBloomName
|
fboPosName <- setupFramebufferGivenStencil rboBaseBloomName
|
||||||
@@ -157,6 +158,7 @@ preloadRender = do
|
|||||||
, _fboLightingHigh = fboLightingHighName
|
, _fboLightingHigh = fboLightingHighName
|
||||||
--, _rboLighting = rboLightingName
|
--, _rboLighting = rboLightingName
|
||||||
, _fboBase = fboBaseName
|
, _fboBase = fboBaseName
|
||||||
|
, _fboCloud = fboCloudName
|
||||||
, _fboBloom = fboBloomName
|
, _fboBloom = fboBloomName
|
||||||
, _fboColor = fboColorName
|
, _fboColor = fboColorName
|
||||||
, _fboPos = fboPosName
|
, _fboPos = fboPosName
|
||||||
|
|||||||
+3
-2
@@ -37,8 +37,9 @@ createLightMap
|
|||||||
-> Int -- ^ number of walls
|
-> Int -- ^ number of walls
|
||||||
-> Int -- ^ number of silhoutte lines to draw
|
-> Int -- ^ number of silhoutte lines to draw
|
||||||
-> Int -- ^ number of "caps" to attempt to draw
|
-> Int -- ^ number of "caps" to attempt to draw
|
||||||
|
-> TextureObject -- ^ the texture object giving positions
|
||||||
-> IO ()
|
-> 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 assume that the renderbuffer's depth has been correctly set elsewhere
|
||||||
-- we will not be changing that here
|
-- we will not be changing that here
|
||||||
depthMask $= Disabled
|
depthMask $= Disabled
|
||||||
@@ -79,7 +80,7 @@ createLightMap pdata lightPoints nWalls nSils nCaps = do
|
|||||||
--draw lightmap itself
|
--draw lightmap itself
|
||||||
depthFunc $= Just Always
|
depthFunc $= Just Always
|
||||||
cullFace $= Nothing
|
cullFace $= Nothing
|
||||||
bindTO $ snd $ snd $ _fboBase pdata
|
bindTO toPos
|
||||||
colorMask $= Color4 Enabled Enabled Enabled Enabled
|
colorMask $= Color4 Enabled Enabled Enabled Enabled
|
||||||
stencilOp $= (OpKeep,OpKeep,OpKeep)
|
stencilOp $= (OpKeep,OpKeep,OpKeep)
|
||||||
stencilFunc $= (Equal, 0, 255)
|
stencilFunc $= (Equal, 0, 255)
|
||||||
|
|||||||
Reference in New Issue
Block a user