Use ssbo/vertex pulling for lighting cap shader
Not yet sure whether the colour vector is correctly input into the ssbo
This commit is contained in:
+23
-11
@@ -116,16 +116,28 @@ doDrawing' win pdata u = do
|
||||
glNamedBufferSubData (pdata ^. wallSSBO) 0
|
||||
(fromIntegral $ trueNWalls * sizeOf (0::Float) * 8)
|
||||
(pdata ^. wallVBO . vboPtr)
|
||||
-- withArray
|
||||
-- [V4 0 0 0 (1:: Float)
|
||||
-- ,V4 0 0 0 0
|
||||
-- ,V4 0 0 0 0
|
||||
-- ,V4 1 1 0 1
|
||||
-- ,V4 0 0 0 0
|
||||
-- ,V4 0 0 0 0
|
||||
-- ,V4 0 1 0 1
|
||||
-- ,V4 0 0 0 0
|
||||
-- ,V4 0 0 0 0
|
||||
-- ]
|
||||
-- $ glNamedBufferSubData (pdata ^. shapeSSBO) 0
|
||||
-- (fromIntegral $ 9 * (sizeOf (0::Float)*12))
|
||||
-- withArray [0::GLuint,1,2] $
|
||||
-- glNamedBufferSubData (pdata ^. ishapeSSBO) 0
|
||||
-- (fromIntegral $ 3 * (sizeOf (0::GLuint)))
|
||||
glNamedBufferSubData (pdata ^. shapeSSBO) 0
|
||||
-- (fromIntegral $ nShapeVs * (sizeOf (0::Float)*8 + sizeOf (0::Word8)*4))
|
||||
(fromIntegral $ nShapeVs * (sizeOf (0::Float)*12))
|
||||
(pdata ^. vboShapes . vboPtr)
|
||||
withArray [0::GLuint,1,2] $
|
||||
glNamedBufferSubData (pdata ^. ishapeSSBO) 0
|
||||
(fromIntegral $ 3 * (sizeOf (0::GLuint)))
|
||||
-- glNamedBufferSubData (pdata ^. ishapeSSBO) 0
|
||||
-- (fromIntegral $ nIndices * (sizeOf (0::GLushort)))
|
||||
-- (pdata ^. shapeEBO . eboPtr)
|
||||
glNamedBufferSubData (pdata ^. ishapeSSBO) 0
|
||||
(fromIntegral $ nIndices * (sizeOf (0::GLuint)))
|
||||
(pdata ^. shapeEBO . eboPtr)
|
||||
setViewport _gr_world_res cfig
|
||||
glBindFramebuffer GL_FRAMEBUFFER (pdata ^. fboBase . _1 . unFBO)
|
||||
glDepthMask GL_TRUE
|
||||
@@ -185,7 +197,7 @@ doDrawing' win pdata u = do
|
||||
glDrawElements
|
||||
(_unPrimitiveMode $ _shaderPrimitive fs)
|
||||
(fromIntegral nIndices)
|
||||
GL_UNSIGNED_SHORT
|
||||
GL_UNSIGNED_INT
|
||||
nullPtr
|
||||
-- draw chasm shader blocking floor
|
||||
glUseProgram (pdata ^. chasmShader . shaderUINT)
|
||||
@@ -263,7 +275,7 @@ doDrawing' win pdata u = do
|
||||
glDrawElements
|
||||
(pdata ^. cloudShader . shaderPrimitive . unPrimitiveMode)
|
||||
(fromIntegral nCloudIs)
|
||||
GL_UNSIGNED_SHORT
|
||||
GL_UNSIGNED_INT
|
||||
nullPtr
|
||||
glDepthMask GL_TRUE
|
||||
|
||||
@@ -307,7 +319,7 @@ doDrawing' win pdata u = do
|
||||
glDrawElements
|
||||
(pdata ^. cloudShader . shaderPrimitive . unPrimitiveMode)
|
||||
(fromIntegral nCloudIs)
|
||||
GL_UNSIGNED_SHORT
|
||||
GL_UNSIGNED_INT
|
||||
nullPtr
|
||||
-- glEnable GL_CULL_FACE
|
||||
-- glEnable GL_DEPTH_CLAMP
|
||||
@@ -339,7 +351,7 @@ doDrawing' win pdata u = do
|
||||
glDrawElements
|
||||
(pdata ^. cloudShader . shaderPrimitive . unPrimitiveMode)
|
||||
(fromIntegral nCloudIs)
|
||||
GL_UNSIGNED_SHORT
|
||||
GL_UNSIGNED_INT
|
||||
nullPtr
|
||||
---
|
||||
-- glEnable GL_CULL_FACE
|
||||
|
||||
@@ -54,7 +54,7 @@ preloadRender = do
|
||||
glNamedBufferStorage shapessbo shapessbosize nullPtr GL_DYNAMIC_STORAGE_BIT
|
||||
glBindBufferBase GL_SHADER_STORAGE_BUFFER 3 shapessbo
|
||||
ishapessbo <- mglCreate glCreateBuffers
|
||||
let ishapessbosize = fromIntegral (sizeOf (0::GLushort) * 65536)
|
||||
let ishapessbosize = fromIntegral (sizeOf (0::GLuint) * 65536)
|
||||
glNamedBufferStorage ishapessbo ishapessbosize nullPtr GL_DYNAMIC_STORAGE_BIT
|
||||
glBindBufferBase GL_SHADER_STORAGE_BUFFER 4 ishapessbo
|
||||
|
||||
|
||||
+3
-3
@@ -190,7 +190,7 @@ renderShadows shadrendertype nWalls nSils nCaps positiontexture normaltexture li
|
||||
glDrawElements
|
||||
(_unPrimitiveMode $ _shaderPrimitive llinesShad)
|
||||
(fromIntegral nSils)
|
||||
GL_UNSIGNED_SHORT
|
||||
GL_UNSIGNED_INT
|
||||
nullPtr
|
||||
--draw caps on the near plane as required
|
||||
glEnable GL_CULL_FACE
|
||||
@@ -204,8 +204,8 @@ renderShadows shadrendertype nWalls nSils nCaps positiontexture normaltexture li
|
||||
glDrawArrays
|
||||
GL_TRIANGLES
|
||||
0
|
||||
3
|
||||
--(fromIntegral nCaps)
|
||||
--3
|
||||
(fromIntegral nCaps)
|
||||
glFrontFace(GL_CCW)
|
||||
--glDrawElements
|
||||
-- (_unPrimitiveMode $ _shaderPrimitive lcapShad)
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ bufferEBO ebo numis =
|
||||
glNamedBufferSubData
|
||||
(ebo ^. eboName)
|
||||
0
|
||||
(fromIntegral $ glushortSize * numis)
|
||||
(fromIntegral $ gluintSize * numis)
|
||||
(ebo ^. eboPtr)
|
||||
|
||||
bufferShaderLayers :: MV.MVector (PrimState IO) (Shader, VBO) -> UMV.MVector (PrimState IO) Int -> IO ()
|
||||
|
||||
@@ -191,12 +191,12 @@ setupVAOUsingVBO vas vbo = do
|
||||
|
||||
setupEBO :: VAO -> IO EBO
|
||||
setupEBO vao = do
|
||||
eboptr <- mallocArray numGLushort
|
||||
eboptr <- mallocArray 65536 -- so we can go back to glushort...
|
||||
eboname <- mglCreate glCreateBuffers
|
||||
--glNamedBufferData
|
||||
glNamedBufferStorage
|
||||
eboname
|
||||
(fromIntegral $ glushortSize * numGLushort)
|
||||
(fromIntegral $ gluintSize * 65536)
|
||||
nullPtr
|
||||
GL_DYNAMIC_STORAGE_BIT
|
||||
--GL_STREAM_DRAW
|
||||
|
||||
+1
-1
@@ -93,7 +93,7 @@ data FloatBO = FloatBO
|
||||
|
||||
data EBO = EBO
|
||||
{ _eboName :: GLuint
|
||||
, _eboPtr :: Ptr GLushort
|
||||
, _eboPtr :: Ptr GLuint
|
||||
}
|
||||
|
||||
-- | Datatype containing the reference to a texture object.
|
||||
|
||||
@@ -3,8 +3,8 @@ module Shader.Parameters
|
||||
, ubyteSize
|
||||
, numDrawableVertices
|
||||
, numSubElements
|
||||
, glushortSize
|
||||
, numGLushort
|
||||
, gluintSize
|
||||
, numGLuint
|
||||
) where
|
||||
--import Picture.Data
|
||||
import Graphics.GL.Core45
|
||||
@@ -22,13 +22,13 @@ floatSize = sizeOf (0.5 :: GLfloat)
|
||||
--intSize = sizeOf (1 :: GLuint)
|
||||
--{-# INLINE intSize #-}
|
||||
|
||||
glushortSize :: Int
|
||||
glushortSize = sizeOf (0 :: GLushort)
|
||||
{-# INLINE glushortSize #-}
|
||||
gluintSize :: Int
|
||||
gluintSize = sizeOf (0 :: GLuint)
|
||||
{-# INLINE gluintSize #-}
|
||||
|
||||
numGLushort :: Int
|
||||
numGLushort = fromIntegral (maxBound :: GLushort) + 1
|
||||
{-# INLINE numGLushort #-}
|
||||
numGLuint :: Int
|
||||
numGLuint = fromIntegral (maxBound :: GLint) + 1
|
||||
{-# INLINE numGLuint #-}
|
||||
|
||||
-- why 6?
|
||||
numDrawableVertices :: Int
|
||||
|
||||
+11
-11
@@ -111,8 +111,8 @@ pokeW ptr i' ((V2 a b, V2 c d), V4 e f g h) = do
|
||||
pokeShape ::
|
||||
(Surface -> Bool) ->
|
||||
Ptr Float ->
|
||||
Ptr GLushort ->
|
||||
Ptr GLushort ->
|
||||
Ptr GLuint ->
|
||||
Ptr GLuint ->
|
||||
(Int, Int, Int) ->
|
||||
[Surface] ->
|
||||
IO (Int, Int, Int)
|
||||
@@ -124,8 +124,8 @@ pokeShape shadowtest ptr iptr ieptr is =
|
||||
pokeShapeObj ::
|
||||
(Surface -> Bool) ->
|
||||
Ptr Float ->
|
||||
Ptr GLushort ->
|
||||
Ptr GLushort ->
|
||||
Ptr GLuint ->
|
||||
Ptr GLuint ->
|
||||
(Int, Int, Int) ->
|
||||
Surface ->
|
||||
IO (Int, Int, Int)
|
||||
@@ -142,8 +142,8 @@ pokeRoundedFaces ::
|
||||
Point4 ->
|
||||
Int ->
|
||||
Ptr Float ->
|
||||
Ptr GLushort ->
|
||||
Ptr GLushort ->
|
||||
Ptr GLuint ->
|
||||
Ptr GLuint ->
|
||||
(Int, Int, Int) ->
|
||||
[Point3] ->
|
||||
IO (Int, Int, Int)
|
||||
@@ -174,8 +174,8 @@ pokeCylinder ::
|
||||
Point4 ->
|
||||
Int ->
|
||||
Ptr Float ->
|
||||
Ptr GLushort ->
|
||||
Ptr GLushort ->
|
||||
Ptr GLuint ->
|
||||
Ptr GLuint ->
|
||||
(Int, Int, Int) ->
|
||||
[Point3] ->
|
||||
IO (Int, Int, Int)
|
||||
@@ -229,8 +229,8 @@ pokeBox ::
|
||||
Point4 ->
|
||||
Int ->
|
||||
Ptr Float ->
|
||||
Ptr GLushort ->
|
||||
Ptr GLushort ->
|
||||
Ptr GLuint ->
|
||||
Ptr GLuint ->
|
||||
(Int, Int, Int) ->
|
||||
[Point3] ->
|
||||
IO (Int, Int, Int)
|
||||
@@ -297,7 +297,7 @@ boxSurfacesIndices n =
|
||||
pokeIndex ::
|
||||
-- | base index
|
||||
Int ->
|
||||
Ptr GLushort ->
|
||||
Ptr GLuint ->
|
||||
-- | number poked
|
||||
Int ->
|
||||
-- | index offset
|
||||
|
||||
@@ -12,10 +12,10 @@ import Geometry.Data
|
||||
import Graphics.GL.Core45
|
||||
import Linear
|
||||
|
||||
pokeCloud :: Ptr Float -> Ptr GLushort -> (Int, Int) -> Cloud -> IO (Int, Int)
|
||||
pokeCloud :: Ptr Float -> Ptr GLuint -> (Int, Int) -> Cloud -> IO (Int, Int)
|
||||
pokeCloud vptr iptr (nv, ni) = pokeCloudLike vptr iptr (nv, ni) . mkCloudCloudLike
|
||||
|
||||
pokeDust :: Ptr Float -> Ptr GLushort -> (Int, Int) -> Dust -> IO (Int, Int)
|
||||
pokeDust :: Ptr Float -> Ptr GLuint -> (Int, Int) -> Dust -> IO (Int, Int)
|
||||
pokeDust vptr iptr (nv, ni) = pokeCloudLike vptr iptr (nv, ni) . mkDustCloudLike
|
||||
|
||||
mkCloudCloudLike :: Cloud -> (Point3, Point4)
|
||||
@@ -31,7 +31,7 @@ mkDustCloudLike x = (x ^. dsPos, V4 r g b a)
|
||||
a = a' * min 1 (fromIntegral (_dsTimer x) / 100)
|
||||
|
||||
pokeCloudLike ::
|
||||
Ptr Float -> Ptr GLushort -> (Int, Int) -> (Point3, Point4) -> IO (Int, Int)
|
||||
Ptr Float -> Ptr GLuint -> (Int, Int) -> (Point3, Point4) -> IO (Int, Int)
|
||||
pokeCloudLike vptr iptr (nv, ni) x = do
|
||||
UV.imapM_ (pokeCloudLikeVerx vptr x nv) $
|
||||
UV.fromList [(1, 1), (-1, 1), (-1, -1), (1, -1)]
|
||||
@@ -57,7 +57,7 @@ pokeCloudFloat :: Ptr Float -> Int -> Int -> Float -> IO ()
|
||||
{-# INLINE pokeCloudFloat #-}
|
||||
pokeCloudFloat ptr nv i = pokeElemOff ptr (nv * 12 + i)
|
||||
|
||||
pokeCloudIndex :: Ptr GLushort -> Int -> Int -> Int -> Int -> IO ()
|
||||
pokeCloudIndex :: Ptr GLuint -> Int -> Int -> Int -> Int -> IO ()
|
||||
{-# INLINE pokeCloudIndex #-}
|
||||
pokeCloudIndex ptr nv ni ioff voff = pokeElemOff ptr (ni + ioff) (fromIntegral $ nv + voff)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user