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