Work on lightmaps, add file

This commit is contained in:
2023-03-23 23:42:09 +00:00
parent 1abfaa3cd0
commit 9a66a09f96
9 changed files with 157 additions and 183 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

+19 -5
View File
@@ -7,16 +7,30 @@ layout (std140, binding = 1) uniform LightsBlock
//uniform int lightID;
vec3 lightPos = posBool[gl_Layer].xyz;
vec4 lumRad = colRad[gl_Layer];
uniform sampler2D screenTexture;
layout (binding = 0) uniform sampler2D screenTexture;
layout (binding = 1) uniform sampler2D normals;
in vec2 gTexPos;
out vec4 fColor;
void main()
{
float rad = lumRad.a;
vec3 distVec = texture(screenTexture,gTexPos).xyz - lightPos;
float dist = dot(distVec,distVec);
if (dist > lumRad.a) {discard;}
float x = 1 - dist / lumRad.a ;
vec3 c = (x * x * x) * lumRad.rgb ;
fColor = vec4(c,0);
//fColor = vec4(0.05,0,0,0);
// float x = 1 - dist / lumRad.a ;
// vec3 c = (x * x * x) * lumRad.rgb ;
// fColor = vec4(c,0);
// //fColor = vec4(0.05,0,0,0);
vec4 normbit = texture(normals, gTexPos);
vec3 norm = normbit.xyz;
float y1 = dot(normalize(norm), normalize(distVec));
float y2 = float(y1 > 0 ? 1 : 0);
//float y3 = clamp(0.5 * (y1 + 1),0,1) ;
float y3 = clamp(2*y1 + 1,0,1) ;
//float y3 = clamp(0.5 * (y1 + 2),0,1) ;
//float y = float(normbit.w == 0 ? y3 : y2);
float y = y2;
float x = 1 - dist / rad;
vec3 c = y* (x * x * x) * lumRad.rgb;
fColor = vec4(c, 0);
}
-1
View File
@@ -46,7 +46,6 @@ data RenderData = RenderData
, _matUBO :: GLuint -- BufferObject id
, _orthonormalMatUBO :: GLuint -- BufferObject id
, _lightsUBO :: GLuint -- BufferObject id
, _vboWalls :: VBO
, _vboWindows :: VBO
, _vboShapes :: VBO
, _floorVBO :: VBO
+6 -9
View File
@@ -51,7 +51,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, wallsToPoke) = wallsToDraw w
( 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
@@ -61,7 +61,7 @@ doDrawing' win pdata u = do
layerCounts <- UMV.replicate (numLayers * 6) 0
-- attempt to poke in parallel
let (ws, wp) = wallSPics <> worldSPic cfig u
((nWalls, nWins,trueNWalls), (nShapeVs, nIndices, nSilIndices)) <-
(( nWins,trueNWalls), (nShapeVs, nIndices, nSilIndices)) <-
MP.bindM3
(\_ a b -> return (a, b))
( pokeLayVerxs
@@ -70,10 +70,8 @@ doDrawing' win pdata u = do
wp
)
( pokeWallsWindows
( pdata ^. vboWalls . vboPtr)
( pdata ^. vboWindows . vboPtr)
( pdata ^. wallVBO . vboPtr)
wallPointsCol
windowPoints
wallsToPoke
)
@@ -88,8 +86,7 @@ doDrawing' win pdata u = do
bufferShaderLayers shadV layerCounts
uncurry (zipWithM_ bufferPokedVBO) $
unzip
[ (pdata ^. vboWalls, nWalls)
, (pdata ^. vboWindows, nWins)
[ (pdata ^. vboWindows, nWins)
, (pdata ^. wallVBO, trueNWalls)
]
bufferPokedVBO (_vboShapes pdata) nShapeVs
@@ -141,7 +138,7 @@ doDrawing' win pdata u = do
glDrawArrays
(_unPrimitiveMode $ pdata ^. lightingWallShadShader . shaderPrimitive)
0
(fromIntegral nWalls)
(fromIntegral trueNWalls)
-- clear normals
withArray [0,0,0,0] $ \ptr -> glClearNamedFramebufferfv
(pdata ^. fboBase . _1 . unFBO)
@@ -189,7 +186,7 @@ doDrawing' win pdata u = do
createLightMap
cfig
(u ^. uvConfig . graphics_object_shadows)
nWalls
(fromIntegral trueNWalls)
nSilIndices
nIndices
(pdata ^. fboBase . _2 . _2)
@@ -305,7 +302,7 @@ doDrawing' win pdata u = do
createLightMap
cfig
(_graphics_object_shadows $ _uvConfig u)
nWalls
(fromIntegral trueNWalls)
nSilIndices
nIndices
(pdata ^. fboPos . _2)
+3 -4
View File
@@ -14,11 +14,10 @@ import Geometry
import ShapePicture
-- not necessary: should just poke all walls to their wanted places
wallsToDraw :: World -> ([((Point2, Point2), Point4)], [((Point2, Point2), Point4)], SPic, [Wall])
wallsToDraw :: World -> ( [((Point2, Point2), Point4)], SPic, [Wall])
wallsToDraw w = L.fold
( (,,,)
<$> L.prefilter wlOpaqueDraw (L.premap f L.list)
<*> L.prefilter wlSeeThroughDraw (L.premap f L.list)
( (,,)
<$>L.prefilter wlSeeThroughDraw (L.premap f L.list)
<*> L.premap getWallSPic L.mconcat
<*> L.prefilter wlOpaqueDraw L.list
)
+14 -51
View File
@@ -29,9 +29,6 @@ import Graphics.GL.Core45
50 charMapVert
-}
numDrawableWalls :: Int
numDrawableWalls = 5000
preloadRender :: IO RenderData
preloadRender = do
-- set up uniform buffer object
@@ -47,40 +44,6 @@ preloadRender = do
glNamedBufferData lightsubo 640 nullPtr GL_STREAM_DRAW
glBindBufferBase GL_UNIFORM_BUFFER 1 lightsubo
-- setup wall points VBO, VAOs and shaders
wpVBOname <- mglCreate glCreateBuffers
wpVBOptr <- mallocArray (8 * numDrawableWalls)
glNamedBufferData wpVBOname
( fromIntegral $ floatSize * numDrawableWalls * 8)
nullPtr
GL_STREAM_DRAW
let wpVBO = VBO{_vboName = wpVBOname, _vboPtr = wpVBOptr, _vboVertexSize = 8}
wpVAOname <- mglCreate glCreateVertexArrays
glBindVertexArray wpVAOname
glVertexArrayVertexBuffer wpVAOname 0 wpVBOname 0 (fromIntegral $ floatSize * 8)
setupVertexAttribPointer wpVAOname 0 4 0
wpColVAOname <- mglCreate glCreateVertexArrays
glBindVertexArray wpColVAOname
glVertexArrayVertexBuffer wpColVAOname 0 wpVBOname 0 (fromIntegral $ floatSize * 8)
setupVertexAttribPointer wpColVAOname 0 4 0
setupVertexAttribPointer wpColVAOname 1 4 4
let wpVAO = VAO{_vaoName = wpVAOname}
wpColVAO = VAO{_vaoName = wpColVAOname}
-- setup window points VBO, VAOs and shaders
winVBOname <- mglCreate glCreateBuffers
winVBOptr <- mallocArray (8 * numDrawableWalls)
glNamedBufferData wpVBOname
( fromIntegral $ floatSize * numDrawableWalls * 8)
nullPtr
GL_STREAM_DRAW
let winVBO = VBO{_vboName = winVBOname, _vboPtr = winVBOptr, _vboVertexSize = 8}
winColVAOname <- mglCreate glCreateVertexArrays
glBindVertexArray winColVAOname
glVertexArrayVertexBuffer winColVAOname 0 winVBOname 0 (fromIntegral $ floatSize * 8)
setupVertexAttribPointer winColVAOname 0 4 0
setupVertexAttribPointer winColVAOname 1 4 4
let winColVAO = VAO
{_vaoName = winColVAOname}
-- setup shape geometry/cap VBO and two VAOs
shVBO <- setupVBO nShapeVerxComp
shPosVAOname <- mglCreate glCreateVertexArrays
@@ -105,10 +68,12 @@ preloadRender = do
GL_STREAM_DRAW
let silEBO = EBO{_eboName = silEBOname, _eboPtr = silEBOptr}
shEdgeVAO = VAO{_vaoName = shEdgeVAOname}
-- shEdgeVAO is unecessary?
-- lighting shaders
let wallverxstrd = 8
wallvbo <- setupVBO wallverxstrd
lightingWallShadShad <-
makeShaderUsingVAO "lighting/wallShadow" [vert, geom, frag] pmPoints wpVAO
makeShaderUsingVBO "lighting/wallShadow" [vert, geom, frag] [4] pmPoints wallvbo
lightingCapShad <-
makeShaderUsingVAO "lighting/cap" [vert, geom] pmTriangles shPosVAO
lightingLineShadowShad <-
@@ -119,7 +84,7 @@ preloadRender = do
shadowcapshader <-
makeShaderUsingVAO "shadow/cap" [vert, geom] pmTriangles shPosVAO
shadowwallshader <-
makeShaderUsingVAO "shadow/wallShadow" [vert, geom] pmPoints wpVAO
makeShaderUsingVBO "shadow/wallShadow" [vert, geom] [4] pmPoints wallvbo
shadowlightshader <- makeShaderSized "shadow/light" [vert, geom, frag]
[1] 1
pmPoints
@@ -128,14 +93,14 @@ preloadRender = do
-- 2D draw shaders
bslist <- makeShaderVBO "dualTwoD/basic" [vert, frag] [3, 4] pmTriangles
bslista <- makeShaderUsingVBO "shape/basic" [vert, frag] shapeVerxSizes nShapeVerxComp pmTriangles shVBO
bslista <- makeShaderUsingVBO "shape/basic" [vert, frag] shapeVerxSizes pmTriangles shVBO
glVertexArrayElementBuffer (bslista ^. shaderVAO . vaoName) (shEBO' ^. eboName)
--glVertexArrayElementBuffer (bslista ^. shaderVAO . vaoName) shEBOname
aslist <- makeShaderVBO "dualTwoD/arc" [vert, frag] [3, 4, 3] pmTriangles
eslist <- makeShaderVBO "dualTwoD/ellipse" [vert, geom, frag] [3, 4] pmTriangles
cslist <-
makeShaderVBO "picture/charArray" [vert, frag] [3, 4, 4] pmTriangles
initTexture2DArray 50 "data/texture/charMapVert.png" 2 16 32 95 GL_NEAREST_MIPMAP_LINEAR GL_LINEAR
initTexture2DArray 50 "data/texture/charMapVertBig.png" 2 32 64 95 GL_NEAREST_MIPMAP_LINEAR GL_LINEAR
screentexturevbo <- mglCreate glCreateBuffers
withArray (concat cornerList) $ \ptr ->
@@ -154,13 +119,12 @@ preloadRender = do
makeShaderUsingVAO "lighting/texture" [vert, frag] pmTriangleStrip screentexturevao
barrelShad <- makeShaderVBO "texture/barrel" [vert, geom, frag] [2, 2, 2, 1] pmPoints
-- blank wallShader
wallBlankShad <- makeShaderUsingVAO "wall/blank" [vert, geom, frag] pmPoints wpColVAO
let wallverxstrd = 8
wallvbo <- setupVBO wallverxstrd
wallshader <- makeShaderUsingVBO "wall/basic" [vert,geom,frag] [4,4] wallverxstrd pmPoints wallvbo
winvbo <- setupVBO 8
windowshader <- makeShaderUsingVBO "wall/blank" [vert, geom, frag] [4,4] pmPoints winvbo
wallshader <- makeShaderUsingVBO "wall/basic" [vert,geom,frag] [4,4] pmPoints wallvbo
let floorverxstrd = 8
floorvbo <- setupVBOStatic floorverxstrd
floorshader <- makeShaderUsingVBO "floor/arrayPos" [vert, frag] [4,4] floorverxstrd pmTriangles floorvbo
floorshader <- makeShaderUsingVBO "floor/arrayPos" [vert, frag] [4,4] pmTriangles floorvbo
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"
@@ -218,7 +182,7 @@ preloadRender = do
, _shadowWallShader = shadowwallshader
, _shadowLightShader = shadowlightshader
, _shadowCombineShader = shadowcombineshader
, _windowShader = wallBlankShad{_shaderVAO = winColVAO}
, _windowShader = windowshader
, _fullscreenShader = fsShad
, _alphaDivideShader = alphadivideshader
, _lightingTextureShader = lightingTextureShad
@@ -241,8 +205,7 @@ preloadRender = do
, _matUBO = theUBO
, _orthonormalMatUBO = orthonormalUBO
, _lightsUBO = lightsubo
, _vboWalls = wpVBO
, _vboWindows = winVBO
, _vboWindows = winvbo
, _vboShapes = shVBO
, _floorVBO = floorvbo
, _floorShader = floorshader
+106 -103
View File
@@ -28,9 +28,8 @@ import Shader.Data
createLightMap ::
Configuration ->
ShadowRendering ->
-- | number of walls
Int ->
GLsizei ->
-- | number of silhoutte lines to draw
Int ->
-- | number of "caps" to attempt to draw
@@ -43,10 +42,10 @@ createLightMap ::
RenderData ->
IO ()
createLightMap cfig shadrendertype = case shadrendertype of
InstancingShads -> instanceLightMap cfig
NoShadows -> const . const . const renderLightingNoShadows
NoLighting -> const . const . const . const . const . const renderFlatLighting
_ -> renderShadows shadrendertype
InstancingShads -> instanceLightMap cfig
NoShadows -> const . const . const renderLightingNoShadows
NoLighting -> const . const . const . const . const . const renderFlatLighting
_ -> renderShadows shadrendertype
renderLightingNoShadows ::
TO ->
@@ -110,113 +109,117 @@ renderLightingNoShadows positiontexture normaltexture lightPoints pdata = do
renderFlatLighting :: RenderData -> IO ()
renderFlatLighting pdata = do
glBindFramebuffer GL_FRAMEBUFFER (_unFBO (fst (_fboLighting pdata)))
withArray [1, 1, 1, 1] $ \ptr ->
withArray [0, 0, 0, 1] $ \ptr ->
glClearNamedFramebufferfv
(pdata ^. fboLighting . _1 . unFBO)
GL_COLOR
0
ptr
with 1 $ \ptr ->
glClearNamedFramebufferfv
(pdata ^. fboLighting . _1 . unFBO)
GL_DEPTH
0
ptr
glDisable GL_CULL_FACE
glDepthFunc GL_ALWAYS
glDepthMask GL_FALSE
renderShadows ::
ShadowRendering ->
GLsizei ->
Int ->
Int ->
TO ->
TO ->
[(Point3, Float, Point3)] ->
RenderData ->
IO ()
renderShadows shadrendertype nWalls nSils nCaps positiontexture normaltexture lightPoints pdata = do
glBindFramebuffer GL_FRAMEBUFFER (_unFBO (fst (_fboLighting pdata)))
let llinesShad = _lightingLineShadowShader pdata
lcapShad = _lightingCapShader pdata
lwallShad = _lightingWallShadShader pdata
ltextShad = _lightingTextureShader pdata
-- we assume that the renderbuffer's depth has been correctly set elsewhere
-- we will not be changing that here
glDepthMask GL_FALSE
-- clearColor is specified differently in preloadRender
-- the colors are inverted
withArray [1, 1, 1, 1] $ \ptr ->
glClearNamedFramebufferfv
(pdata ^. fboLighting . _1 . unFBO)
GL_COLOR
0
ptr
-- for each of the lights:
-- 1. stencil out the shadows from this light's point of view
-- 2. calculate lighting based on each fragment's position
-- to consider: adding normals/a "material" for each fragment
glBlendFunc GL_ZERO GL_ONE_MINUS_SRC_COLOR
glEnable GL_STENCIL_TEST
glStencilOpSeparate GL_FRONT GL_KEEP GL_KEEP GL_INCR_WRAP
glStencilOpSeparate GL_BACK GL_KEEP GL_KEEP GL_DECR_WRAP
flip VFSM.mapM_ (VFSM.fromList lightPoints) $ \(V3 x y z, rad, V3 r g b) -> do
glDepthFunc GL_LESS
-- setup stencil
glColorMask GL_FALSE GL_FALSE GL_FALSE GL_FALSE
with 0 $ \ptr ->
glClearNamedFramebufferiv
(pdata ^. fboLighting . _1 . unFBO)
GL_STENCIL
0
ptr
glDisable GL_CULL_FACE
glStencilFunc GL_ALWAYS 0 255
--draw wall shadows
glUseProgram (_shaderUINT lwallShad)
glBindFramebuffer GL_FRAMEBUFFER (_unFBO (fst (_fboLighting pdata)))
let llinesShad = _lightingLineShadowShader pdata
lcapShad = _lightingCapShader pdata
lwallShad = _lightingWallShadShader pdata
ltextShad = _lightingTextureShader pdata
-- we assume that the renderbuffer's depth has been correctly set elsewhere
-- we will not be changing that here
glDepthMask GL_FALSE
-- clearColor is specified differently in preloadRender
-- the colors are inverted
withArray [1, 1, 1, 1] $ \ptr ->
glClearNamedFramebufferfv
(pdata ^. fboLighting . _1 . unFBO)
GL_COLOR
0
ptr
-- for each of the lights:
-- 1. stencil out the shadows from this light's point of view
-- 2. calculate lighting based on each fragment's position
-- to consider: adding normals/a "material" for each fragment
glBlendFunc GL_ZERO GL_ONE_MINUS_SRC_COLOR
glEnable GL_STENCIL_TEST
glStencilOpSeparate GL_FRONT GL_KEEP GL_KEEP GL_INCR_WRAP
glStencilOpSeparate GL_BACK GL_KEEP GL_KEEP GL_DECR_WRAP
flip VFSM.mapM_ (VFSM.fromList lightPoints) $ \(V3 x y z, rad, V3 r g b) -> do
glDepthFunc GL_LESS
-- setup stencil
glColorMask GL_FALSE GL_FALSE GL_FALSE GL_FALSE
with 0 $ \ptr ->
glClearNamedFramebufferiv
(pdata ^. fboLighting . _1 . unFBO)
GL_STENCIL
0
ptr
glDisable GL_CULL_FACE
glStencilFunc GL_ALWAYS 0 255
--draw wall shadows
glUseProgram (_shaderUINT lwallShad)
glUniform3f 0 x y z
glUniform1f 1 rad
glBindVertexArray $ lwallShad ^. shaderVAO . vaoName -- Just (_vao $ _shadVAO lwallShad)
glDrawArrays
(_unPrimitiveMode $ _shaderPrimitive lwallShad)
0
nWalls
case shadrendertype of
GeoObjShads -> do
--draw silhouette shadows
glEnable GL_DEPTH_CLAMP
glUseProgram (_shaderUINT llinesShad)
glUniform3f 0 x y z
glUniform1f 1 rad
glBindVertexArray $ lwallShad ^. shaderVAO . vaoName -- Just (_vao $ _shadVAO lwallShad)
glDrawArrays
(_unPrimitiveMode $ _shaderPrimitive lwallShad)
0
(fromIntegral nWalls)
case shadrendertype of
GeoObjShads -> do
--draw silhouette shadows
glEnable GL_DEPTH_CLAMP
glUseProgram (_shaderUINT llinesShad)
glUniform3f 0 x y z
glUniform1f 1 rad
glBindVertexArray (_vaoName $ _shaderVAO llinesShad)
glDrawElements
(_unPrimitiveMode $ _shaderPrimitive llinesShad)
(fromIntegral nSils)
GL_UNSIGNED_SHORT
nullPtr
--draw caps on the near plane as required
glEnable GL_CULL_FACE
glCullFace GL_BACK
glCullFace GL_FRONT
glUseProgram (_shaderUINT lcapShad)
glUniform3f 0 x y z
glBindVertexArray $ lcapShad ^. shaderVAO . vaoName --Just (_vao $ _shadVAO lcapShad)
glDrawElements
(_unPrimitiveMode $ _shaderPrimitive lcapShad)
(fromIntegral nCaps)
GL_UNSIGNED_SHORT
nullPtr
glDisable GL_DEPTH_CLAMP
NoObjShads -> return ()
--draw lightmap itself
glDepthFunc GL_ALWAYS
-- bind world position texture
glDisable GL_CULL_FACE
glBindTextureUnit 0 (positiontexture ^. unTO)
glBindTextureUnit 1 (normaltexture ^. unTO)
glColorMask GL_TRUE GL_TRUE GL_TRUE GL_TRUE
glStencilFunc GL_EQUAL 0 255
glUseProgram (ltextShad ^. shaderUINT) --Just (_shadProg ltextShad)
glBindVertexArray (_vaoName $ _shaderVAO llinesShad)
glDrawElements
(_unPrimitiveMode $ _shaderPrimitive llinesShad)
(fromIntegral nSils)
GL_UNSIGNED_SHORT
nullPtr
--draw caps on the near plane as required
glEnable GL_CULL_FACE
glCullFace GL_BACK
glCullFace GL_FRONT
glUseProgram (_shaderUINT lcapShad)
glUniform3f 0 x y z
glUniform4f 1 r g b rad
glBindVertexArray $ ltextShad ^. shaderVAO . vaoName -- Just (_vao $ _shadVAO ltextShad)
glDrawArrays
(_unPrimitiveMode (_shaderPrimitive ltextShad))
0
(fromIntegral (4 :: Int))
--cleanup: may not be necessary, depending on what comes after...
glDisable GL_STENCIL_TEST
glBindVertexArray $ lcapShad ^. shaderVAO . vaoName --Just (_vao $ _shadVAO lcapShad)
glDrawElements
(_unPrimitiveMode $ _shaderPrimitive lcapShad)
(fromIntegral nCaps)
GL_UNSIGNED_SHORT
nullPtr
glDisable GL_DEPTH_CLAMP
_ -> return ()
--draw lightmap itself
glDepthFunc GL_ALWAYS
-- bind world position texture
glDisable GL_CULL_FACE
glBindTextureUnit 0 (positiontexture ^. unTO)
glBindTextureUnit 1 (normaltexture ^. unTO)
glColorMask GL_TRUE GL_TRUE GL_TRUE GL_TRUE
glStencilFunc GL_EQUAL 0 255
glUseProgram (ltextShad ^. shaderUINT) --Just (_shadProg ltextShad)
glUniform3f 0 x y z
glUniform4f 1 r g b rad
glBindVertexArray $ ltextShad ^. shaderVAO . vaoName -- Just (_vao $ _shadVAO ltextShad)
glDrawArrays
(_unPrimitiveMode (_shaderPrimitive ltextShad))
0
(fromIntegral (4 :: Int))
--cleanup: may not be necessary, depending on what comes after...
glDisable GL_STENCIL_TEST
lightsToArray :: [(Point3, Float, Point3)] -> [Float]
lightsToArray xs =
@@ -228,9 +231,8 @@ lightsToArray xs =
instanceLightMap ::
Configuration ->
-- | number of walls
Int ->
GLsizei ->
-- | number of silhoutte lines to draw
Int ->
-- | number of "caps" to attempt to draw
@@ -293,7 +295,7 @@ instanceLightMap cfig nWalls nSils nCaps toPos tanormals lightPoints pdata = do
glDrawArrays
(_unPrimitiveMode $ pdata ^. shadowWallShader . shaderPrimitive)
0
(fromIntegral nWalls)
nWalls
--draw silhouette shadows
glUseProgram $ pdata ^. shadowEdgeShader . shaderUINT
glBindVertexArray $ pdata ^. shadowEdgeShader . shaderVAO . vaoName
@@ -320,6 +322,7 @@ instanceLightMap cfig nWalls nSils nCaps toPos tanormals lightPoints pdata = do
glUseProgram (pdata ^. shadowLightShader . _1 . shaderUINT)
-- bind world position texture
glBindTextureUnit 0 (toPos ^. unTO)
glBindTextureUnit 1 (tanormals ^. unTO)
glDrawArrays
(_unPrimitiveMode $ pdata ^. shadowLightShader . _1 . shaderPrimitive)
0
+6 -4
View File
@@ -80,13 +80,15 @@ makeShaderUsingVBO ::
[GLenum] ->
-- | The input vertex sizes
[Int] ->
-- | The stride
Int ->
PrimitiveMode ->
VBO ->
IO Shader
makeShaderUsingVBO s shaderlist sizes strd pm vbo = setupVAOvbo sizes strd vbo
>>= makeShaderUsingVAO s shaderlist pm
makeShaderUsingVBO s shaderlist sizes pm vbo = do
let strd = vbo ^. vboVertexSize
when (strd < sum sizes) $
error "Tried to assign vertex attributes to VBO with too small a stride."
vao <- setupVAOvbo sizes strd vbo
makeShaderUsingVAO s shaderlist pm vao
setupVBO :: Int -> IO VBO
setupVBO vertexsize = do
+3 -6
View File
@@ -47,16 +47,13 @@ pokeVerx vbos offsets Verx{_vxPos = thePos, _vxCol = theCol, _vxExt = ext, _vxSh
pokeWallsWindows ::
Ptr Float ->
Ptr Float ->
Ptr Float ->
[((Point2, Point2), Point4)] ->
[((Point2, Point2), Point4)] ->
[Wall] ->
IO (Int, Int, Int)
pokeWallsWindows wlptr wiptr truewlptr wls wis truewls = do
wlcounts1 <- VFSM.foldlM' (pokeW wlptr) 0 (VFSM.fromList wls)
IO (Int, Int)
pokeWallsWindows wiptr truewlptr wis truewls = do
wlcounts2 <- VFSM.foldlM' (pokeW wiptr) 0 (VFSM.fromList wis)
wlcounts3 <- VFSM.foldlM' (pokeWall truewlptr) 0 (VFSM.fromList truewls)
return (wlcounts1, wlcounts2, wlcounts3)
return ( wlcounts2, wlcounts3)
pokeFloors :: Ptr Float ->
[(Point3, Point3)] ->