Add dependencies, play around with clouds/transparency layer
This commit is contained in:
@@ -0,0 +1,16 @@
|
|||||||
|
#version 430 core
|
||||||
|
uniform vec3 lightPos;
|
||||||
|
uniform vec4 lumRad;
|
||||||
|
uniform sampler2D screenTexture;
|
||||||
|
in vec2 vTexPos;
|
||||||
|
out vec4 fColor;
|
||||||
|
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 c = pow (1 - min(1, dot(dField,dField)) , 2) * lumRad.rgb ;
|
||||||
|
fColor = vec4(c,0);
|
||||||
|
//fColor = vec4(lumRad.rgb,0);
|
||||||
|
//fColor = vec4(1,1,1,0);
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
#version 430 core
|
||||||
|
layout (location = 0) in vec2 pos;
|
||||||
|
layout (location = 1) in vec2 texPos;
|
||||||
|
out vec2 vTexPos;
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_Position = vec4(pos,0,1);
|
||||||
|
vTexPos = texPos;
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
#version 430 core
|
||||||
|
in vec3 vTexPos;
|
||||||
|
in vec3 vPos;
|
||||||
|
layout (location=0) out vec4 fCol;
|
||||||
|
layout (location=1) out vec4 fPos;
|
||||||
|
uniform sampler2DArray tilesetSampler;
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
fCol = texture(tilesetSampler, vTexPos);
|
||||||
|
fPos = vec4(vPos,1);
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
#version 430 core
|
||||||
|
layout (location = 0) in vec3 pos;
|
||||||
|
layout (location = 1) in vec3 texPos;
|
||||||
|
layout (std140, binding = 0) uniform TheMat { mat4 theMat; } ;
|
||||||
|
out vec3 vTexPos;
|
||||||
|
out vec3 vPos;
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_Position = theMat * vec4(pos,1.0) ;
|
||||||
|
vTexPos = texPos;
|
||||||
|
vPos = pos;
|
||||||
|
}
|
||||||
@@ -13,8 +13,8 @@ import Control.Monad.Primitive
|
|||||||
|
|
||||||
data RenderData = RenderData
|
data RenderData = RenderData
|
||||||
{ _lightingOccludeShader :: FullShader
|
{ _lightingOccludeShader :: FullShader
|
||||||
, _lightingWallShader :: FullShader
|
--, _lightingWallShader :: FullShader
|
||||||
, _lightingSurfaceShader :: FullShader
|
--, _lightingSurfaceShader :: FullShader
|
||||||
, _lightingLineShadowShader :: FullShader
|
, _lightingLineShadowShader :: FullShader
|
||||||
, _lightingCapShader :: FullShader
|
, _lightingCapShader :: FullShader
|
||||||
, _wallBlankShader :: FullShader
|
, _wallBlankShader :: FullShader
|
||||||
@@ -22,8 +22,7 @@ data RenderData = RenderData
|
|||||||
, _textureArrayShader :: FullShader
|
, _textureArrayShader :: FullShader
|
||||||
, _fullscreenShader :: FullShader
|
, _fullscreenShader :: FullShader
|
||||||
, _fullLightingShader :: FullShader
|
, _fullLightingShader :: FullShader
|
||||||
, _fullscreenAlphaHalveShader :: FullShader
|
--, _fullscreenAlphaHalveShader :: FullShader
|
||||||
--, _boxBlurShader :: FullShader
|
|
||||||
, _bloomBlurShader :: FullShader
|
, _bloomBlurShader :: FullShader
|
||||||
, _colorBlurShader :: FullShader
|
, _colorBlurShader :: FullShader
|
||||||
, _barrelShader :: FullShader
|
, _barrelShader :: FullShader
|
||||||
@@ -40,7 +39,6 @@ data RenderData = RenderData
|
|||||||
, _rboBaseBloom :: RenderbufferObject
|
, _rboBaseBloom :: RenderbufferObject
|
||||||
, _fboLighting :: (FramebufferObject, TextureObject)
|
, _fboLighting :: (FramebufferObject, TextureObject)
|
||||||
, _fboLightingHigh :: (FramebufferObject, TextureObject)
|
, _fboLightingHigh :: (FramebufferObject, TextureObject)
|
||||||
--, _rboLighting :: RenderbufferObject
|
|
||||||
, _matUBO :: BufferObject
|
, _matUBO :: BufferObject
|
||||||
}
|
}
|
||||||
makeLenses ''RenderData
|
makeLenses ''RenderData
|
||||||
|
|||||||
+18
-23
@@ -57,18 +57,14 @@ doDrawing pdata w = do
|
|||||||
$
|
$
|
||||||
--youSil w ++
|
--youSil w ++
|
||||||
_foregroundEdgeVerx w
|
_foregroundEdgeVerx w
|
||||||
-- poke foreground geometry and floor
|
-- poke foreground geometry for caps
|
||||||
let addC (V2 xx yy) = V3 xx yy 0
|
nCaps <- pokePoint3s (shadVBOptr $ _lightingCapShader pdata)
|
||||||
nsurfVs <- pokePoint3s (shadVBOptr $ _lightingSurfaceShader pdata)
|
$ concatMap polyToGeoRender (foregroundPics w)
|
||||||
$
|
|
||||||
--youBox w ++
|
|
||||||
concatMap polyToGeoRender (foregroundPics w)
|
|
||||||
++ polyToTris (map addC $ screenPolygon w)
|
|
||||||
-- bind wall points, silhouette data, surface geometry
|
-- bind wall points, silhouette data, surface geometry
|
||||||
uncurry bindShaderBuffers $ unzip
|
uncurry bindShaderBuffers $ unzip
|
||||||
[ ( _wallTextureShader pdata, nWalls)
|
[ ( _wallTextureShader pdata, nWalls)
|
||||||
, (_lightingLineShadowShader pdata, nSils)
|
, (_lightingLineShadowShader pdata, nSils)
|
||||||
, (_lightingSurfaceShader pdata, nsurfVs)
|
, (_lightingCapShader pdata, nCaps)
|
||||||
]
|
]
|
||||||
-- set the coordinate uniform ready for drawing elements using world coordinates
|
-- set the coordinate uniform ready for drawing elements using world coordinates
|
||||||
bufferUBO $ perspectiveMatrixb rot camzoom trans wins viewFroms
|
bufferUBO $ perspectiveMatrixb rot camzoom trans wins viewFroms
|
||||||
@@ -79,15 +75,9 @@ doDrawing pdata w = do
|
|||||||
clear [ColorBuffer,DepthBuffer]
|
clear [ColorBuffer,DepthBuffer]
|
||||||
depthFunc $= Just Less
|
depthFunc $= Just Less
|
||||||
-- draw wall occlusions from the camera's point of view
|
-- draw wall occlusions from the camera's point of view
|
||||||
currentProgram $= Just (_shaderProgram $ _lightingSurfaceShader pdata)
|
|
||||||
uniform (head $ _shaderCustomUnis $ _lightingSurfaceShader pdata)
|
|
||||||
$= viewFrom3d
|
|
||||||
currentProgram $= Just (_shaderProgram $ _lightingOccludeShader pdata)
|
currentProgram $= Just (_shaderProgram $ _lightingOccludeShader pdata)
|
||||||
uniform (head $ _shaderCustomUnis $ _lightingOccludeShader pdata)
|
uniform (head $ _shaderCustomUnis $ _lightingOccludeShader pdata)
|
||||||
$= viewFrom3d
|
$= viewFrom3d
|
||||||
currentProgram $= Just (_shaderProgram $ _lightingWallShader pdata)
|
|
||||||
uniform (head $ _shaderCustomUnis $ _lightingWallShader pdata)
|
|
||||||
$= viewFrom3d
|
|
||||||
drawShader (_lightingOccludeShader pdata) nWalls
|
drawShader (_lightingOccludeShader pdata) nWalls
|
||||||
--draw walls onto base buffer
|
--draw walls onto base buffer
|
||||||
if w ^. config . wall_textured
|
if w ^. config . wall_textured
|
||||||
@@ -124,23 +114,29 @@ 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))
|
||||||
|
|
||||||
--
|
|
||||||
-- depthMask $= Enabled
|
|
||||||
-- this is not ideal if the original is not divisible by 2
|
|
||||||
|
|
||||||
bindFramebuffer Framebuffer $= fst (_fboLighting pdata)
|
bindFramebuffer Framebuffer $= fst (_fboLighting pdata)
|
||||||
createLightMap pdata lightPoints nWalls nSils
|
createLightMap pdata lightPoints nWalls nSils nCaps
|
||||||
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)
|
bindFramebuffer Framebuffer $= fst (_fboColor pdata)
|
||||||
clearColor $= Color4 0 0 0 0
|
|
||||||
clear [ColorBuffer]
|
|
||||||
depthFunc $= Just Lequal
|
depthFunc $= Just Lequal
|
||||||
depthMask $= Disabled
|
depthMask $= Disabled
|
||||||
blendFuncSeparate $= ((SrcAlpha,OneMinusSrcAlpha),(SrcAlpha,One))
|
--blendFuncSeparate $= ((OneMinusDstAlpha,OneMinusSrcAlpha),(One,OneMinusSrcAlpha))
|
||||||
|
--blendFunc $= (One,OneMinusSrcAlpha)
|
||||||
--blendFunc $= (SrcAlpha,One)
|
--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)
|
||||||
|
blendFuncSeparate $= ((SrcAlpha,OneMinusSrcAlpha),(One,OneMinusSrcAlpha))
|
||||||
|
--blendFuncSeparate $= ((SrcAlphaSaturate,OneMinusSrcAlpha),(One,OneMinusSrcAlpha))
|
||||||
renderLayer 2 shadV layerCounts
|
renderLayer 2 shadV layerCounts
|
||||||
|
renderWindows pdata windowPoints
|
||||||
clearColor $= Color4 0 0 0 0
|
clearColor $= Color4 0 0 0 0
|
||||||
depthMask $= Enabled
|
depthMask $= Enabled
|
||||||
depthMask $= Disabled
|
depthMask $= Disabled
|
||||||
@@ -179,7 +175,6 @@ doDrawing pdata w = do
|
|||||||
textureBinding Texture2D $= Just (snd $ _fboColor pdata)
|
textureBinding Texture2D $= Just (snd $ _fboColor pdata)
|
||||||
drawShader (_fullscreenShader pdata) 4
|
drawShader (_fullscreenShader pdata) 4
|
||||||
--renderLayer 2 shadV layerCounts
|
--renderLayer 2 shadV layerCounts
|
||||||
renderWindows pdata windowPoints
|
|
||||||
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))
|
||||||
|
|||||||
@@ -281,7 +281,7 @@ makeGasCloud pos vel w = w
|
|||||||
theCloud = Cloud
|
theCloud = Cloud
|
||||||
{ _clPos = pos
|
{ _clPos = pos
|
||||||
, _clVel = vel
|
, _clVel = vel
|
||||||
, _clPict = \_ -> setLayer 2 . setDepth 30 $ color (withAlpha 0.1 col)
|
, _clPict = \_ -> setLayer 2 . setDepth 30 $ color (withAlpha 0.05 col)
|
||||||
$ circleSolid 20
|
$ circleSolid 20
|
||||||
, _clRad = 10
|
, _clRad = 10
|
||||||
, _clTimer = 400
|
, _clTimer = 400
|
||||||
|
|||||||
+7
-23
@@ -51,18 +51,11 @@ preloadRender = do
|
|||||||
setupVertexAttribPointer 1 4 8 4
|
setupVertexAttribPointer 1 4 8 4
|
||||||
let wpVAO = VAO {_vao = wpVAOname, _vaoVBO = wpVBO}
|
let wpVAO = VAO {_vao = wpVAOname, _vaoVBO = wpVBO}
|
||||||
wpColVAO = VAO {_vao = wpColVAOname, _vaoVBO = wpVBO}
|
wpColVAO = VAO {_vao = wpColVAOname, _vaoVBO = wpVBO}
|
||||||
|
|
||||||
-- lighting shaders
|
-- lighting shaders
|
||||||
wsShad <- makeShader "lighting/occlude" [vert,geom,frag] [4] EPoints
|
wsShad <- makeShader "lighting/occlude" [vert,geom,frag] [4] EPoints
|
||||||
>>= addUniforms ["lightPos"]
|
>>= addUniforms ["lightPos"]
|
||||||
wlLightShad
|
|
||||||
<- makeShaderUsingShaderVAO "lighting/wall" [vert,geom,frag] EPoints wsShad
|
|
||||||
>>= addUniforms ["lightPos","lumRad"]
|
|
||||||
lightingSurfaceShad
|
|
||||||
<- makeShader "lighting/surface" [vert,frag] [3] ETriangles
|
|
||||||
>>= addUniforms ["lightPos","lumRad"]
|
|
||||||
lightingCapShad
|
lightingCapShad
|
||||||
<- makeShaderUsingShaderVAO "lighting/cap" [vert,geom,frag] ETriangles lightingSurfaceShad
|
<- makeShader "lighting/cap" [vert,geom,frag] [3] ETriangles
|
||||||
>>= addUniforms ["lightPos"]
|
>>= addUniforms ["lightPos"]
|
||||||
lightingLineShadowShad
|
lightingLineShadowShad
|
||||||
<- makeShader "lighting/lineShadow" [vert,geom,frag] [3] ELinesAdjacency
|
<- makeShader "lighting/lineShadow" [vert,geom,frag] [3] ELinesAdjacency
|
||||||
@@ -77,8 +70,8 @@ preloadRender = do
|
|||||||
-- this should really be a 2d texture array
|
-- this should really be a 2d texture array
|
||||||
basicTweakZShad <- makeShader "dualTwoD/basicTweakZ" [vert,frag] [4,4] ETriangles
|
basicTweakZShad <- makeShader "dualTwoD/basicTweakZ" [vert,frag] [4,4] ETriangles
|
||||||
-- fullscreen shaders
|
-- fullscreen shaders
|
||||||
fullscreenAlphaHalveShad <- makeShaderSized "fullscreen/alphaHalve" [vert,frag] [2] 4 ETriangleStrip
|
--fullscreenAlphaHalveShad <- makeShaderSized "fullscreen/alphaHalve" [vert,frag] [2] 4 ETriangleStrip
|
||||||
pokeArray (shadVBOptr fullscreenAlphaHalveShad) $ concat cornerListNoCoord
|
--pokeArray (shadVBOptr fullscreenAlphaHalveShad) $ concat cornerListNoCoord
|
||||||
-- texture shaders, no textures attached
|
-- texture shaders, no textures attached
|
||||||
fsShad <- makeShaderSized "texture/simple" [vert,frag] [2,2] 4 ETriangleStrip
|
fsShad <- makeShaderSized "texture/simple" [vert,frag] [2,2] 4 ETriangleStrip
|
||||||
-- note we directly poke the shader vertex data here
|
-- note we directly poke the shader vertex data here
|
||||||
@@ -100,7 +93,7 @@ preloadRender = do
|
|||||||
>>= addTextureArray "data/texture/ayene_wooden_floor_transformed.png"
|
>>= addTextureArray "data/texture/ayene_wooden_floor_transformed.png"
|
||||||
-- >>= addTextureArray "data/texture/ayene_wooden_floor.png"
|
-- >>= addTextureArray "data/texture/ayene_wooden_floor.png"
|
||||||
-- bind fixed vertex data
|
-- bind fixed vertex data
|
||||||
bindShaderBuffers [fsShad,fullscreenAlphaHalveShad] [4,4]
|
bindShaderBuffers [fsShad] [4,4]
|
||||||
framebuf2 <- setupTextureFramebuffer 800 600
|
framebuf2 <- setupTextureFramebuffer 800 600
|
||||||
framebuf3 <- setupTextureFramebuffer 800 600
|
framebuf3 <- setupTextureFramebuffer 800 600
|
||||||
|
|
||||||
@@ -141,17 +134,17 @@ preloadRender = do
|
|||||||
|
|
||||||
return $ RenderData
|
return $ RenderData
|
||||||
{ _pictureShaders = shadV
|
{ _pictureShaders = shadV
|
||||||
, _lightingSurfaceShader = lightingSurfaceShad
|
--, _lightingSurfaceShader = lightingSurfaceShad
|
||||||
, _lightingCapShader = lightingCapShad
|
, _lightingCapShader = lightingCapShad
|
||||||
, _lightingLineShadowShader = lightingLineShadowShad
|
, _lightingLineShadowShader = lightingLineShadowShad
|
||||||
, _lightingOccludeShader = wsShad {_shaderVAO = wpVAO}
|
, _lightingOccludeShader = wsShad {_shaderVAO = wpVAO}
|
||||||
, _lightingWallShader = wlLightShad {_shaderVAO = wpVAO}
|
--, _lightingWallShader = wlLightShad {_shaderVAO = wpVAO}
|
||||||
, _wallBlankShader = wlBlank { _shaderVAO = wpColVAO }
|
, _wallBlankShader = wlBlank { _shaderVAO = wpColVAO }
|
||||||
, _wallTextureShader = wlTexture { _shaderVAO = wpColVAO }
|
, _wallTextureShader = wlTexture { _shaderVAO = wpColVAO }
|
||||||
, _textureArrayShader = textArrayShad
|
, _textureArrayShader = textArrayShad
|
||||||
, _fullscreenShader = fsShad
|
, _fullscreenShader = fsShad
|
||||||
, _fullLightingShader = fullLightingShad
|
, _fullLightingShader = fullLightingShad
|
||||||
, _fullscreenAlphaHalveShader = fullscreenAlphaHalveShad
|
--, _fullscreenAlphaHalveShader = fullscreenAlphaHalveShad
|
||||||
, _bloomBlurShader = bloomBlurShad
|
, _bloomBlurShader = bloomBlurShad
|
||||||
, _colorBlurShader = colorBlurShad
|
, _colorBlurShader = colorBlurShad
|
||||||
, _barrelShader = barrelShad
|
, _barrelShader = barrelShad
|
||||||
@@ -178,15 +171,6 @@ cornerList =
|
|||||||
,[-1,-1,0,0]
|
,[-1,-1,0,0]
|
||||||
,[ 1,-1,1,0]
|
,[ 1,-1,1,0]
|
||||||
]
|
]
|
||||||
cornerListNoCoord :: [[Float]]
|
|
||||||
cornerListNoCoord =
|
|
||||||
[[-1, 1]
|
|
||||||
,[ 1, 1]
|
|
||||||
,[-1,-1]
|
|
||||||
,[ 1,-1]
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
cleanUpRenderPreload :: RenderData -> IO ()
|
cleanUpRenderPreload :: RenderData -> IO ()
|
||||||
cleanUpRenderPreload pd = do
|
cleanUpRenderPreload pd = do
|
||||||
-- TODO fix this
|
-- TODO fix this
|
||||||
|
|||||||
+3
-2
@@ -36,8 +36,9 @@ createLightMap
|
|||||||
-> [(Point3,Float,Point3)] -- Lights
|
-> [(Point3,Float,Point3)] -- Lights
|
||||||
-> 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
|
||||||
-> IO ()
|
-> IO ()
|
||||||
createLightMap pdata lightPoints nWalls nSils = do
|
createLightMap pdata lightPoints nWalls nSils nCaps = 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
|
||||||
@@ -74,7 +75,7 @@ createLightMap pdata lightPoints nWalls nSils = do
|
|||||||
currentProgram $= Just (_shaderProgram $ _lightingCapShader pdata)
|
currentProgram $= Just (_shaderProgram $ _lightingCapShader pdata)
|
||||||
uniform (head $ _shaderCustomUnis $ _lightingCapShader pdata)
|
uniform (head $ _shaderCustomUnis $ _lightingCapShader pdata)
|
||||||
$= Vector3 x y z
|
$= Vector3 x y z
|
||||||
drawShader (_lightingCapShader pdata) (nSils - 6)
|
drawShader (_lightingCapShader pdata) nCaps
|
||||||
--draw lightmap itself
|
--draw lightmap itself
|
||||||
depthFunc $= Just Always
|
depthFunc $= Just Always
|
||||||
cullFace $= Nothing
|
cullFace $= Nothing
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
module Tuple
|
||||||
|
( trip1
|
||||||
|
, trip2
|
||||||
|
, trip3
|
||||||
|
)
|
||||||
|
where
|
||||||
|
|
||||||
|
trip1 :: (a,b,c) -> a
|
||||||
|
{-# INLINE trip1 #-}
|
||||||
|
trip1 (x,_,_) = x
|
||||||
|
trip2 :: (a,b,c) -> b
|
||||||
|
{-# INLINE trip2 #-}
|
||||||
|
trip2 (_,x,_) = x
|
||||||
|
trip3 :: (a,b,c) -> c
|
||||||
|
{-# INLINE trip3 #-}
|
||||||
|
trip3 (_,_,x) = x
|
||||||
Reference in New Issue
Block a user