Improve normal maps on ground and walls

This commit is contained in:
2023-03-19 23:52:19 +00:00
parent e90989ee2d
commit 33f31aa385
24 changed files with 112 additions and 178 deletions
+21 -31
View File
@@ -53,7 +53,7 @@ doDrawing' win pdata u = do
trans = w ^. cWorld . camPos . camCenter
wins@(V2 winx winy) = V2 (_windowX cfig) (_windowY cfig)
resFact = resFactorNum $ cfig ^. graphics_resolution_factor
(wallPointsCol, windowPoints, wallSPics) = wallsToDraw w
(wallPointsCol, windowPoints, wallSPics, wallsToPoke) = wallsToDraw w
lightPoints = lightsToRender cfig (w ^. cWorld . camPos) (w ^. cWorld . lWorld)
viewFroms@(V2 vfx vfy) = w ^. cWorld . camPos . camViewFrom
shadV = _pictureShaders pdata
@@ -63,7 +63,7 @@ doDrawing' win pdata u = do
layerCounts <- UMV.replicate (numLayers * 6) 0
-- attempt to poke in parallel
let (ws, wp) = wallSPics <> worldSPic cfig w
((nWalls, nWins), (nShapeVs, nIndices, nSilIndices)) <-
((nWalls, nWins,trueNWalls), (nShapeVs, nIndices, nSilIndices)) <-
MP.bindM3
(\_ a b -> return (a, b))
( pokeLayVerxs
@@ -74,8 +74,10 @@ doDrawing' win pdata u = do
( pokeWallsWindows
( pdata ^. vboWalls . vboPtr)
( pdata ^. vboWindows . vboPtr)
( pdata ^. wallVBO . vboPtr)
wallPointsCol
windowPoints
wallsToPoke
)
( pokeShape
(_vboPtr $ _vboShapes pdata)
@@ -90,6 +92,7 @@ doDrawing' win pdata u = do
unzip
[ (pdata ^. vboWalls, nWalls)
, (pdata ^. vboWindows, nWins)
, (pdata ^. wallVBO, trueNWalls)
]
bufferPokedVBO (_vboShapes pdata) nShapeVs
glNamedBufferSubData
@@ -139,9 +142,22 @@ doDrawing' win pdata u = do
2
ptr
--draw walls onto base buffer
if cfig ^. graphics_wall_textured
then renderTextureWalls pdata nWalls
else renderBlankWalls pdata nWalls
glDisable GL_BLEND
glBindTextureUnit 1 (pdata ^. toNormalMaps . unTO)
glBindTextureUnit 2 (pdata ^. toDiffuse . unTO)
-- maybe cull faces? maybe do this before?
--glEnable GL_CULL_FACE
--glCullFace GL_BACK
glUseProgram (pdata ^. wallShader . shadName)
glBindVertexArray $ pdata ^. wallShader . shadVAO . vaoName
glDrawArrays
(marshalEPrimitiveMode $ pdata ^. wallShader . shadPrim')
0
(fromIntegral trueNWalls)
--glDisable GL_CULL_FACE
-- if cfig ^. graphics_wall_textured
-- then renderTextureWalls pdata nWalls
-- else renderBlankWalls pdata nWalls
--draw object pictures onto base buffer
renderLayer BottomLayer shadV layerCounts
--draw object shapes onto base buffer
@@ -157,7 +173,6 @@ doDrawing' win pdata u = do
nullPtr
glDisable GL_CULL_FACE
--draw floor onto base buffer
glDisable GL_BLEND
glUseProgram (pdata ^. floorShader . shadName)
glBindVertexArray $ pdata ^. floorShader . shadVAO . vaoName
glBindTextureUnit 1 (pdata ^. toNormalMaps . unTO)
@@ -336,31 +351,6 @@ setViewportSize :: Int -> Int -> IO ()
setViewportSize x y =
glViewport 0 0 (fromIntegral x) (fromIntegral y)
renderBlankWalls ::
RenderData ->
-- | number of walls
Int ->
IO ()
renderBlankWalls pdata nWalls = do
glEnable GL_CULL_FACE
glCullFace GL_BACK
--cullFace $= Just Back
drawShader (_wallBlankShader pdata) nWalls
glDisable GL_CULL_FACE
--cullFace $= Nothing
renderTextureWalls ::
RenderData ->
-- | number of walls
Int ->
IO ()
renderTextureWalls pdata nWalls = do
--cullFace $= Just Back
glEnable GL_CULL_FACE
glCullFace GL_BACK
drawShader (_wallTextureShader pdata) nWalls
glDisable GL_CULL_FACE
--cullFace $= Nothing