Further cleanup
This commit is contained in:
@@ -6,11 +6,7 @@ in vec2 vTexPos;
|
|||||||
out vec4 fColor;
|
out vec4 fColor;
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
//vec3 dField = ( texture(screenTexture,vTexPos).xyz - lightPos ) / lumRad.a;
|
|
||||||
//vec3 c = pow (1 - min(1, dot(dField,dField)) , 2) * lumRad.rgb ;
|
|
||||||
vec3 dField = ( texture(screenTexture,vTexPos).xyz - lightPos ) / lumRad.a;
|
vec3 dField = ( texture(screenTexture,vTexPos).xyz - lightPos ) / lumRad.a;
|
||||||
vec3 c = pow (1 - min(1, dot(dField,dField)) , 2) * lumRad.rgb ;
|
vec3 c = pow (1 - min(1, dot(dField,dField)) , 2) * lumRad.rgb ;
|
||||||
fColor = vec4(c,0);
|
fColor = vec4(c,0);
|
||||||
//fColor = vec4(lumRad.rgb,0);
|
|
||||||
//fColor = vec4(1,1,1,0);
|
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-29
@@ -93,15 +93,28 @@ doDrawing pdata w = do
|
|||||||
nTextArrayVs <- pokePoint33s (shadVBOptr $ _textureArrayShader pdata) (_floorTiles w)
|
nTextArrayVs <- pokePoint33s (shadVBOptr $ _textureArrayShader pdata) (_floorTiles w)
|
||||||
bindShaderBuffers [_textureArrayShader pdata] [nTextArrayVs]
|
bindShaderBuffers [_textureArrayShader pdata] [nTextArrayVs]
|
||||||
drawShader (_textureArrayShader pdata) nTextArrayVs
|
drawShader (_textureArrayShader pdata) nTextArrayVs
|
||||||
|
--draw lightmap for base buffer
|
||||||
|
bindFramebuffer Framebuffer $= fst (_fboLighting pdata)
|
||||||
|
createLightMap pdata lightPoints nWalls nSils nCaps (snd $ snd $ _fboBase pdata)
|
||||||
|
colorMask $= Color4 Enabled Enabled Enabled Enabled
|
||||||
|
clearColor $= Color4 0 0 0 0
|
||||||
|
--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 bloom onto bloom buffer
|
--draw bloom onto bloom buffer
|
||||||
bindFramebuffer Framebuffer $= fst (_fboBloom pdata)
|
bindFramebuffer Framebuffer $= fst (_fboBloom pdata)
|
||||||
clear [ColorBuffer]
|
clear [ColorBuffer]
|
||||||
|
depthFunc $= Just Less
|
||||||
blendFunc $= (SrcAlpha,OneMinusSrcAlpha)
|
blendFunc $= (SrcAlpha,OneMinusSrcAlpha)
|
||||||
depthMask $= Disabled
|
depthMask $= Disabled
|
||||||
renderLayer 3 shadV layerCounts
|
renderLayer 3 shadV layerCounts
|
||||||
depthMask $= Enabled
|
depthMask $= Enabled
|
||||||
renderLayer 1 shadV layerCounts
|
renderLayer 1 shadV layerCounts
|
||||||
|
--depthMask $= Enabled
|
||||||
--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,21 +127,6 @@ doDrawing pdata w = do
|
|||||||
blend $= Enabled
|
blend $= Enabled
|
||||||
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)
|
|
||||||
createLightMap pdata lightPoints nWalls nSils nCaps (snd $ snd $ _fboBase pdata)
|
|
||||||
colorMask $= Color4 Enabled Enabled Enabled Enabled
|
|
||||||
clearColor $= Color4 0 0 0 0
|
|
||||||
|
|
||||||
--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
|
--draw clouds
|
||||||
bindFramebuffer Framebuffer $= fst (_fboCloud pdata)
|
bindFramebuffer Framebuffer $= fst (_fboCloud pdata)
|
||||||
depthFunc $= Just Lequal
|
depthFunc $= Just Lequal
|
||||||
@@ -140,24 +138,19 @@ doDrawing pdata w = do
|
|||||||
clear [ColorBuffer]
|
clear [ColorBuffer]
|
||||||
renderLayer 2 shadV layerCounts
|
renderLayer 2 shadV layerCounts
|
||||||
renderWindows pdata windowPoints
|
renderWindows pdata windowPoints
|
||||||
|
|
||||||
----render transparency depths
|
----render transparency depths
|
||||||
depthMask $= Enabled
|
depthMask $= Enabled
|
||||||
blend $= Disabled
|
blend $= Disabled
|
||||||
drawBuffers $= [NoBuffers,FBOColorAttachment 1]
|
drawBuffers $= [NoBuffers,FBOColorAttachment 1]
|
||||||
clearColor $= Color4 0 0 0 0
|
|
||||||
clear [ColorBuffer]
|
|
||||||
renderLayer 2 shadV layerCounts
|
renderLayer 2 shadV layerCounts
|
||||||
renderWindows pdata windowPoints
|
renderWindows pdata windowPoints
|
||||||
depthMask $= Disabled
|
depthMask $= Disabled
|
||||||
blend $= Enabled
|
blend $= Enabled
|
||||||
|
|
||||||
----draw lightmap for cloud buffer
|
----draw lightmap for cloud buffer
|
||||||
bindFramebuffer Framebuffer $= fst (_fboLighting pdata)
|
bindFramebuffer Framebuffer $= fst (_fboLighting pdata)
|
||||||
createLightMap pdata lightPoints nWalls nSils nCaps (snd $ snd $ _fboCloud pdata)
|
createLightMap pdata lightPoints nWalls nSils nCaps (snd $ snd $ _fboCloud 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
|
||||||
|
|
||||||
--apply lightmap to cloud buffer
|
--apply lightmap to cloud buffer
|
||||||
clearColor $= Color4 0 0 0 0
|
clearColor $= Color4 0 0 0 0
|
||||||
bindFramebuffer Framebuffer $= fst (_fboCloud pdata)
|
bindFramebuffer Framebuffer $= fst (_fboCloud pdata)
|
||||||
@@ -170,10 +163,6 @@ 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)
|
||||||
|
|
||||||
depthMask $= Disabled
|
|
||||||
depthFunc $= Just Always
|
|
||||||
|
|
||||||
--Draw blurred bloom onto base buffer
|
--Draw blurred bloom onto base buffer
|
||||||
bindFramebuffer Framebuffer $= fst (_fboBase pdata)
|
bindFramebuffer Framebuffer $= fst (_fboBase pdata)
|
||||||
blend $= Enabled
|
blend $= Enabled
|
||||||
@@ -181,15 +170,13 @@ doDrawing pdata w = do
|
|||||||
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)
|
||||||
|
--draw shadowed clouds onto base buffer
|
||||||
textureBinding Texture2D $= Just (fst $ snd $ _fboCloud pdata)
|
textureBinding Texture2D $= Just (fst $ snd $ _fboCloud pdata)
|
||||||
drawShader (_fullscreenShader pdata) 4
|
drawShader (_fullscreenShader pdata) 4
|
||||||
depthFunc $= Just Lequal
|
--set viewport for radial distortion
|
||||||
|
|
||||||
viewport $= (Position 0 0, Size (round $ fstV2 wins) (round $ sndV2 wins))
|
viewport $= (Position 0 0, Size (round $ fstV2 wins) (round $ sndV2 wins))
|
||||||
depthFunc $= Just Always
|
depthFunc $= Just Always
|
||||||
blendFunc $= (One,Zero)
|
blendFunc $= (One,Zero)
|
||||||
|
|
||||||
-- perform any radial distortion
|
-- perform any radial distortion
|
||||||
case _radDistortion w of
|
case _radDistortion w of
|
||||||
[] -> do
|
[] -> do
|
||||||
|
|||||||
@@ -173,11 +173,11 @@ preloadRender = do
|
|||||||
, _fboLighting = fboLightingName
|
, _fboLighting = fboLightingName
|
||||||
, _fboLightingHigh = fboLightingHighName
|
, _fboLightingHigh = fboLightingHighName
|
||||||
--, _rboLighting = rboLightingName
|
--, _rboLighting = rboLightingName
|
||||||
, _fboBase = fboBaseName
|
, _fboBase = fboBaseName
|
||||||
, _fboCloud = fboCloudName
|
, _fboCloud = fboCloudName
|
||||||
, _fboBloom = fboBloomName
|
, _fboBloom = fboBloomName
|
||||||
, _fboColor = fboColorName
|
, _fboColor = fboColorName
|
||||||
, _fboPos = fboPosName
|
, _fboPos = fboPosName
|
||||||
, _rboBaseBloom = rboBaseBloomName
|
, _rboBaseBloom = rboBaseBloomName
|
||||||
, _matUBO = theUBO
|
, _matUBO = theUBO
|
||||||
}
|
}
|
||||||
@@ -185,8 +185,8 @@ preloadRender = do
|
|||||||
cornerList :: [[Float]]
|
cornerList :: [[Float]]
|
||||||
cornerList =
|
cornerList =
|
||||||
[[-1, 1,0,1]
|
[[-1, 1,0,1]
|
||||||
,[ 1, 1,1,1]
|
|
||||||
,[-1,-1,0,0]
|
,[-1,-1,0,0]
|
||||||
|
,[ 1, 1,1,1]
|
||||||
,[ 1,-1,1,0]
|
,[ 1,-1,1,0]
|
||||||
]
|
]
|
||||||
cleanUpRenderPreload :: RenderData -> IO ()
|
cleanUpRenderPreload :: RenderData -> IO ()
|
||||||
|
|||||||
+5
-6
@@ -47,21 +47,20 @@ createLightMap pdata lightPoints nWalls nSils nCaps toPos = do
|
|||||||
clearColor $= Color4 1 1 1 1
|
clearColor $= Color4 1 1 1 1
|
||||||
clear [ColorBuffer]
|
clear [ColorBuffer]
|
||||||
-- for each of the lights:
|
-- for each of the lights:
|
||||||
-- stencil out the walls from this light's point of view
|
-- 1. stencil out the walls from this light's point of view
|
||||||
-- draw fading lightmap circles on the floor
|
-- 2. calculate lighting based on each fragment's position
|
||||||
-- draw fading lightmaps on the walls
|
|
||||||
blendFunc $= (Zero, OneMinusSrcColor)
|
blendFunc $= (Zero, OneMinusSrcColor)
|
||||||
stencilTest $= Enabled
|
stencilTest $= Enabled
|
||||||
flip VS.mapM_ (VS.fromList lightPoints) $ \(V3 x y z,rad,V3 r g b) -> do
|
flip VS.mapM_ (VS.fromList lightPoints) $ \(V3 x y z,rad,V3 r g b) -> do
|
||||||
depthFunc $= Just Less
|
depthFunc $= Just Less
|
||||||
-- stencil out shadows
|
-- setup stencil
|
||||||
colorMask $= Color4 Disabled Disabled Disabled Disabled
|
colorMask $= Color4 Disabled Disabled Disabled Disabled
|
||||||
clear [StencilBuffer]
|
clear [StencilBuffer]
|
||||||
cullFace $= Nothing
|
cullFace $= Nothing
|
||||||
stencilOpSeparate Front $= (OpKeep,OpKeep,OpIncrWrap)
|
stencilOpSeparate Front $= (OpKeep,OpKeep,OpIncrWrap)
|
||||||
stencilOpSeparate Back $= (OpKeep,OpKeep,OpDecrWrap)
|
stencilOpSeparate Back $= (OpKeep,OpKeep,OpDecrWrap)
|
||||||
stencilFunc $= (Always, 0, 255)
|
stencilFunc $= (Always, 0, 255)
|
||||||
--draw wall whadows
|
--draw wall shadows
|
||||||
currentProgram $= Just (_shaderProgram $ _lightingOccludeShader pdata)
|
currentProgram $= Just (_shaderProgram $ _lightingOccludeShader pdata)
|
||||||
uniform (head $ _shaderCustomUnis $ _lightingOccludeShader pdata)
|
uniform (head $ _shaderCustomUnis $ _lightingOccludeShader pdata)
|
||||||
$= Vector3 x y z
|
$= Vector3 x y z
|
||||||
@@ -79,7 +78,7 @@ createLightMap pdata lightPoints nWalls nSils nCaps toPos = do
|
|||||||
drawShader (_lightingCapShader pdata) nCaps
|
drawShader (_lightingCapShader pdata) nCaps
|
||||||
--draw lightmap itself
|
--draw lightmap itself
|
||||||
depthFunc $= Just Always
|
depthFunc $= Just Always
|
||||||
cullFace $= Nothing
|
--cullFace $= Nothing
|
||||||
bindTO toPos
|
bindTO toPos
|
||||||
colorMask $= Color4 Enabled Enabled Enabled Enabled
|
colorMask $= Color4 Enabled Enabled Enabled Enabled
|
||||||
stencilOp $= (OpKeep,OpKeep,OpKeep)
|
stencilOp $= (OpKeep,OpKeep,OpKeep)
|
||||||
|
|||||||
Reference in New Issue
Block a user