Cleanup
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -2,5 +2,5 @@
|
|||||||
out vec4 fColor;
|
out vec4 fColor;
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
fColor = vec4 (0,0,0,0);
|
fColor = vec4 (0,0,0,1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ layout (location=2) out vec4 fNorm;
|
|||||||
in vec2 tPos;
|
in vec2 tPos;
|
||||||
in vec3 gTexCoords;
|
in vec3 gTexCoords;
|
||||||
in vec4 gPos;
|
in vec4 gPos;
|
||||||
in vec4 gNorm;
|
|
||||||
in vec4 gColor;
|
in vec4 gColor;
|
||||||
in float gAng;
|
in float gAng;
|
||||||
layout (binding=40) uniform sampler2DArray diffuseSampler;
|
layout (binding=40) uniform sampler2DArray diffuseSampler;
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ in vec2 vTexAng[];
|
|||||||
out float gAng;
|
out float gAng;
|
||||||
out vec2 tPos;
|
out vec2 tPos;
|
||||||
out vec4 gPos;
|
out vec4 gPos;
|
||||||
out vec4 gNorm;
|
|
||||||
out vec3 gTexCoords;
|
out vec3 gTexCoords;
|
||||||
// consider using isLHS to check if the wall is facing the center
|
// consider using isLHS to check if the wall is facing the center
|
||||||
float isLHS (vec2 startV, vec2 testV)
|
float isLHS (vec2 startV, vec2 testV)
|
||||||
@@ -25,19 +24,15 @@ void main()
|
|||||||
float tcoordx = dist / 50;
|
float tcoordx = dist / 50;
|
||||||
vec4 norm = vec4( d.y, -d.x, 0, 0);
|
vec4 norm = vec4( d.y, -d.x, 0, 0);
|
||||||
gPos = p1; tPos = vec2 ( 1,-1) ; gl_Position = vec4(theMat * p1);
|
gPos = p1; tPos = vec2 ( 1,-1) ; gl_Position = vec4(theMat * p1);
|
||||||
gNorm = gPos - norm;
|
|
||||||
gTexCoords = vec3 (0,0,tcoordz);
|
gTexCoords = vec3 (0,0,tcoordz);
|
||||||
EmitVertex();
|
EmitVertex();
|
||||||
gPos = p3; tPos = vec2 ( 1, 1) ; gl_Position = vec4(theMat * p3);
|
gPos = p3; tPos = vec2 ( 1, 1) ; gl_Position = vec4(theMat * p3);
|
||||||
gNorm = gPos - norm;
|
|
||||||
gTexCoords = vec3 (0,2,tcoordz);
|
gTexCoords = vec3 (0,2,tcoordz);
|
||||||
EmitVertex();
|
EmitVertex();
|
||||||
gPos = p2; tPos = vec2 (-1,-1) ; gl_Position = vec4(theMat * p2);
|
gPos = p2; tPos = vec2 (-1,-1) ; gl_Position = vec4(theMat * p2);
|
||||||
gNorm = gPos - norm;
|
|
||||||
gTexCoords = vec3 (tcoordx,0,tcoordz);
|
gTexCoords = vec3 (tcoordx,0,tcoordz);
|
||||||
EmitVertex();
|
EmitVertex();
|
||||||
gPos = p4; tPos = vec2 (-1, 1) ; gl_Position = vec4(theMat * p4);
|
gPos = p4; tPos = vec2 (-1, 1) ; gl_Position = vec4(theMat * p4);
|
||||||
gNorm = gPos - norm;
|
|
||||||
gTexCoords = vec3 (tcoordx,2,tcoordz);
|
gTexCoords = vec3 (tcoordx,2,tcoordz);
|
||||||
EmitVertex();
|
EmitVertex();
|
||||||
EndPrimitive();
|
EndPrimitive();
|
||||||
|
|||||||
@@ -42,6 +42,8 @@ data RenderData = RenderData
|
|||||||
, _vboShapes :: VBO
|
, _vboShapes :: VBO
|
||||||
, _floorVBO :: VBO
|
, _floorVBO :: VBO
|
||||||
, _floorShader :: Shader
|
, _floorShader :: Shader
|
||||||
|
, _chasmVBO :: VBO
|
||||||
|
, _chasmShader :: Shader
|
||||||
, _wallVBO :: VBO
|
, _wallVBO :: VBO
|
||||||
, _wallShader :: Shader
|
, _wallShader :: Shader
|
||||||
, _cloudVBO :: VBO
|
, _cloudVBO :: VBO
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ data CWorld = CWorld
|
|||||||
, _pathGraph :: Gr Point2 PathEdge
|
, _pathGraph :: Gr Point2 PathEdge
|
||||||
, _numberFloorVerxs :: Int
|
, _numberFloorVerxs :: Int
|
||||||
, _chasms :: [[Point2]]
|
, _chasms :: [[Point2]]
|
||||||
|
, _numberChasmVerxs :: Int
|
||||||
}
|
}
|
||||||
|
|
||||||
data CWGen = CWGen
|
data CWGen = CWGen
|
||||||
|
|||||||
@@ -92,6 +92,7 @@ defaultCWorld =
|
|||||||
, _cwTiles = mempty
|
, _cwTiles = mempty
|
||||||
, _numberFloorVerxs = 0
|
, _numberFloorVerxs = 0
|
||||||
, _chasms = mempty
|
, _chasms = mempty
|
||||||
|
, _numberChasmVerxs = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultLWorld :: LWorld
|
defaultLWorld :: LWorld
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ doDrawing' win pdata u = do
|
|||||||
viewFroms@(V2 vfx vfy) = w ^. wCam . camViewFrom
|
viewFroms@(V2 vfx vfy) = w ^. wCam . camViewFrom
|
||||||
shadV = _pictureShaders pdata
|
shadV = _pictureShaders pdata
|
||||||
nFls = w ^. cWorld . numberFloorVerxs
|
nFls = w ^. cWorld . numberFloorVerxs
|
||||||
|
nchs = w ^. cWorld . numberChasmVerxs
|
||||||
-- bind as much data into vbos as feasible at this point
|
-- bind as much data into vbos as feasible at this point
|
||||||
-- count mutable vectors setup
|
-- count mutable vectors setup
|
||||||
pokeCounts <- UMV.replicate (numLayers * numShads) 0
|
pokeCounts <- UMV.replicate (numLayers * numShads) 0
|
||||||
@@ -181,6 +182,13 @@ doDrawing' win pdata u = do
|
|||||||
(fromIntegral nIndices)
|
(fromIntegral nIndices)
|
||||||
GL_UNSIGNED_SHORT
|
GL_UNSIGNED_SHORT
|
||||||
nullPtr
|
nullPtr
|
||||||
|
-- draw chasm shader blocking floor
|
||||||
|
glUseProgram (pdata ^. chasmShader . shaderUINT)
|
||||||
|
glBindVertexArray $ pdata ^. chasmShader . shaderVAO . vaoName
|
||||||
|
glDrawArrays
|
||||||
|
(_unPrimitiveMode $ pdata ^. chasmShader . shaderPrimitive)
|
||||||
|
0
|
||||||
|
(fromIntegral nchs)
|
||||||
--draw floor onto base buffer
|
--draw floor onto base buffer
|
||||||
glUseProgram (pdata ^. floorShader . shaderUINT)
|
glUseProgram (pdata ^. floorShader . shaderUINT)
|
||||||
glBindVertexArray $ pdata ^. floorShader . shaderVAO . vaoName
|
glBindVertexArray $ pdata ^. floorShader . shaderVAO . vaoName
|
||||||
|
|||||||
@@ -31,15 +31,15 @@ worldSPic cfig u =
|
|||||||
<> foldup floorItemSPic (filtOn _flItPos (_unNIntMap . _floorItems))
|
<> foldup floorItemSPic (filtOn _flItPos (_unNIntMap . _floorItems))
|
||||||
<> foldup btSPic (filtOn _btPos _buttons)
|
<> foldup btSPic (filtOn _btPos _buttons)
|
||||||
<> foldup (mcSPic (u ^. uvWorld . cWorld . lWorld)) (filtOn _mcPos _machines)
|
<> foldup (mcSPic (u ^. uvWorld . cWorld . lWorld)) (filtOn _mcPos _machines)
|
||||||
<> foldMap' drawChasm (u ^. uvWorld . cWorld . chasms)
|
-- <> foldMap' drawChasm (u ^. uvWorld . cWorld . chasms)
|
||||||
where
|
where
|
||||||
w = _uvWorld u
|
w = _uvWorld u
|
||||||
foldup = foldMap'
|
foldup = foldMap'
|
||||||
filtOn f g = IM.filter (pointIsClose . f) (g (_lWorld (_cWorld w)))
|
filtOn f g = IM.filter (pointIsClose . f) (g (_lWorld (_cWorld w)))
|
||||||
pointIsClose = cullPoint cfig w
|
pointIsClose = cullPoint cfig w
|
||||||
|
|
||||||
drawChasm :: [Point2] -> SPic
|
--drawChasm :: [Point2] -> SPic
|
||||||
drawChasm = noShape . color green . setDepth 2 . polygon
|
--drawChasm = noShape . color green . setDepth 2 . polygon
|
||||||
|
|
||||||
drawPulseBall :: PulseBall -> SPic
|
drawPulseBall :: PulseBall -> SPic
|
||||||
drawPulseBall pb =
|
drawPulseBall pb =
|
||||||
|
|||||||
@@ -19,4 +19,10 @@ postWorldLoad rdata cw = do
|
|||||||
0
|
0
|
||||||
(cw ^. cwTiles)
|
(cw ^. cwTiles)
|
||||||
bufferPokedVBO (rdata ^. floorVBO) nfloorvxs
|
bufferPokedVBO (rdata ^. floorVBO) nfloorvxs
|
||||||
|
nchasmvxs <- foldM (pokeChasm (rdata ^. chasmVBO . vboPtr))
|
||||||
|
0
|
||||||
|
(cw ^. chasms)
|
||||||
|
bufferPokedVBO (rdata ^. chasmVBO) nchasmvxs
|
||||||
return $ cw & numberFloorVerxs .~ nfloorvxs
|
return $ cw & numberFloorVerxs .~ nfloorvxs
|
||||||
|
& numberChasmVerxs .~ nchasmvxs
|
||||||
|
|
||||||
|
|||||||
@@ -114,6 +114,11 @@ preloadRender = do
|
|||||||
initTexture2DArraySquare 40 3 GL_LINEAR_MIPMAP_LINEAR GL_LINEAR "data/normalMaps/diffuseArray.png"
|
initTexture2DArraySquare 40 3 GL_LINEAR_MIPMAP_LINEAR GL_LINEAR "data/normalMaps/diffuseArray.png"
|
||||||
initTexture2DArraySquare 41 3 GL_LINEAR_MIPMAP_LINEAR GL_LINEAR "data/normalMaps/normalArray.png"
|
initTexture2DArraySquare 41 3 GL_LINEAR_MIPMAP_LINEAR GL_LINEAR "data/normalMaps/normalArray.png"
|
||||||
|
|
||||||
|
putStrLn "Setup chasm VBO, shader"
|
||||||
|
let chasmverxstrd = 3
|
||||||
|
chasmvbo <- setupVBOStatic (floatSize * chasmverxstrd)
|
||||||
|
chasmshader <- makeShaderUsingVBO "positional/blank" [vert, frag] (toFloatVAs [3]) pmTriangles chasmvbo
|
||||||
|
|
||||||
putStrLn "Setup cloud VBO, shader"
|
putStrLn "Setup cloud VBO, shader"
|
||||||
let cloudverxsizes = [4, 4, 4, 4]
|
let cloudverxsizes = [4, 4, 4, 4]
|
||||||
cloudvbo <- setupVBO (floatSize * sum cloudverxsizes)
|
cloudvbo <- setupVBO (floatSize * sum cloudverxsizes)
|
||||||
@@ -179,6 +184,8 @@ preloadRender = do
|
|||||||
, _vboShapes = shVBO
|
, _vboShapes = shVBO
|
||||||
, _floorVBO = floorvbo
|
, _floorVBO = floorvbo
|
||||||
, _floorShader = floorshader
|
, _floorShader = floorshader
|
||||||
|
, _chasmVBO = chasmvbo
|
||||||
|
, _chasmShader = chasmshader
|
||||||
, _wallVBO = wallvbo
|
, _wallVBO = wallvbo
|
||||||
, _wallShader = wallshader
|
, _wallShader = wallshader
|
||||||
, _cloudVBO = cloudvbo
|
, _cloudVBO = cloudvbo
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ setupStaticVBOVAO vas vdata = withArrayLen vdata $ \i ptr -> do
|
|||||||
setupVBOStatic :: Int -> IO VBO
|
setupVBOStatic :: Int -> IO VBO
|
||||||
setupVBOStatic vertexsize = do
|
setupVBOStatic vertexsize = do
|
||||||
vboname <- mglCreate glCreateBuffers
|
vboname <- mglCreate glCreateBuffers
|
||||||
thePtr <- mallocArray (vertexsize * numDrawableVertices)
|
thePtr <- mallocBytes (vertexsize * numDrawableVertices)
|
||||||
-- Allocate space
|
-- Allocate space
|
||||||
glNamedBufferData
|
glNamedBufferData
|
||||||
vboname
|
vboname
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
module Shader.Poke.Floor (
|
module Shader.Poke.Floor (
|
||||||
pokeTile,
|
pokeTile,
|
||||||
|
pokeChasm,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Control.Monad
|
import Control.Monad
|
||||||
@@ -19,3 +20,12 @@ pokeTileVerx tangent tilez ptr i (V2 x y, V2 s t) = do
|
|||||||
let a = argV tangent
|
let a = argV tangent
|
||||||
zipWithM_ (\off -> pokeElemOff ptr (i * 8 + off)) [0 ..] [x, y, 1, 1, s, t, tilez, a]
|
zipWithM_ (\off -> pokeElemOff ptr (i * 8 + off)) [0 ..] [x, y, 1, 1, s, t, tilez, a]
|
||||||
return $ i + 1
|
return $ i + 1
|
||||||
|
|
||||||
|
pokeChasm :: Ptr Float -> Int -> [Point2] -> IO Int
|
||||||
|
pokeChasm ptr i ps =
|
||||||
|
foldM (pokeChasmVerx ptr) i $ polyToTris ps
|
||||||
|
|
||||||
|
pokeChasmVerx :: Ptr Float -> Int -> Point2 -> IO Int
|
||||||
|
pokeChasmVerx ptr i (V2 x y) = do
|
||||||
|
zipWithM_ (\off -> pokeElemOff ptr (i * 3 + off)) [0 ..] [x, y, 0]
|
||||||
|
return $ i + 1
|
||||||
|
|||||||
Reference in New Issue
Block a user