Unify matrix uniform assignment, move towards uniform block

This commit is contained in:
2021-06-24 14:38:17 +02:00
parent 2625927f14
commit d534f08064
19 changed files with 70 additions and 91 deletions
+16 -14
View File
@@ -27,9 +27,8 @@ setWallDepth
:: RenderData
-> [(Point2,Point2)] -- ^ Wall points
-> (Float,Float) -- ^ View from point
-> GLmatrix GLfloat
-> IO Word32
setWallDepth pdata wallPoints (viewFromx,viewFromy) _ = do
setWallDepth pdata wallPoints (viewFromx,viewFromy) = do
startTicks <- SDL.ticks
colorMask $= Color4 Disabled Disabled Disabled Disabled
nWalls <- F.foldM (pokeShader $ _lightingOccludeShader pdata) (map Render22 wallPoints)
@@ -62,10 +61,9 @@ createLightMap
-> [(Point2,Point2)] -- Wall pairs
-> [Point4] -- Lights
-> (Float,Float) -- View from position
-> GLmatrix GLfloat -- perspective matrix
-> Picture -- foreground pictures
-> IO ()
createLightMap pdata resDiv wallPoints lightPoints (viewFromx,viewFromy) pmat _ = do
createLightMap pdata resDiv wallPoints lightPoints (viewFromx,viewFromy) _ = do
-- get viewport size so we can reset it later
(vppos,vpsize) <- get viewport
@@ -79,9 +77,9 @@ createLightMap pdata resDiv wallPoints lightPoints (viewFromx,viewFromy) pmat _
nWalls <- F.foldM (pokeShader $ _lightingOccludeShader pdata) (map Render22 wallPoints)
bindShaderBuffers [_lightingOccludeShader pdata] [nWalls]
-- set uniforms for shader that draws lights
currentProgram $= Just (_shaderProgram $ _lightingWallShader pdata)
uniform (_shaderMatrixUniform $ _lightingWallShader pdata)
$= pmat
-- currentProgram $= Just (_shaderProgram $ _lightingWallShader pdata)
-- uniform (_shaderMatrixUniform $ _lightingWallShader pdata)
-- $= pmat
-- clear buffer to full alpha and furthest depth
clearColor $= Color4 0 0 0 1
clearDepth $= 1
@@ -92,7 +90,7 @@ createLightMap pdata resDiv wallPoints lightPoints (viewFromx,viewFromy) pmat _
currentProgram $= Just (_shaderProgram $ _lightingOccludeShader pdata)
uniform (head $ _shaderCustomUnis $ _lightingOccludeShader pdata)
$= Vector2 viewFromx viewFromy
uniform (_shaderMatrixUniform $ _lightingOccludeShader pdata) $= pmat
-- uniform (_shaderMatrixUniform $ _lightingOccludeShader pdata) $= pmat
cullFace $= Just Back
drawShader (_lightingOccludeShader pdata) nWalls
@@ -215,12 +213,16 @@ setPerpMatrixUniforms
-> (Float,Float) -- ^ ViewFrom
-> IO ()
setPerpMatrixUniforms pdata rot czoom trans wins vfs = mapM_ (setPerpMatUniform rot czoom trans wins vfs)
$ ( (_lightingFloorShader pdata)
: (_backgroundShader pdata)
: (_textureShader pdata)
: (_textureArrayShader pdata)
: (_pictureShaders pdata)
)
( _lightingFloorShader pdata
: _lightingWallShader pdata
: _lightingOccludeShader pdata
: _backgroundShader pdata
: _textureShader pdata
: _textureArrayShader pdata
: _wallBlankShader pdata
: _wallTextureShader pdata
: _pictureShaders pdata
)
renderShader
:: Foldable f