Remove instancing shaders
This commit is contained in:
@@ -16,11 +16,6 @@ data RenderData = RenderData
|
||||
, _lightingCapShader :: Shader
|
||||
, _lightingTextureShader :: Shader
|
||||
, _alphaDivideShader :: Shader
|
||||
, _shadowEdgeShader :: Shader
|
||||
, _shadowCapShader :: Shader
|
||||
, _shadowWallShader :: Shader
|
||||
, _shadowLightShader :: Shader
|
||||
, _shadowCombineShader :: Shader
|
||||
, _windowShader :: Shader
|
||||
, _fullscreenShader :: Shader
|
||||
, _bloomBlurShader :: Shader
|
||||
|
||||
@@ -96,11 +96,9 @@ data ResFactor = DoubleRes | FullRes | HalfRes | QuarterRes | EighthRes | Sixtee
|
||||
|
||||
data ShadowRendering
|
||||
= GeoObjShads
|
||||
| InstancingShads
|
||||
| NoObjShads
|
||||
| NoShadows
|
||||
| NoLighting
|
||||
| ComputeShader
|
||||
deriving (Show, Eq, Ord, Enum, Bounded)
|
||||
|
||||
data RoomClipping = NoRoomClipBoundaries | AllRoomClipBoundaries | IntersectingRoomClipBoundaries
|
||||
|
||||
@@ -95,21 +95,6 @@ preloadRender = do
|
||||
makeShaderUsingVAO "lighting/cap" [vert, geom] pmTriangles shPosVAO
|
||||
lightingLineShadowShad <-
|
||||
makeShaderUsingVAO "lighting/lineShadow" [vert, geom] pmLinesAdjacency shedgevao
|
||||
shadowedgeshader <-
|
||||
makeShaderUsingVAO "shadow/edge" [vert, geom] pmLinesAdjacency shedgevao
|
||||
shadowcapshader <-
|
||||
makeShaderUsingVAO "shadow/cap" [vert, geom] pmTriangles shPosVAO
|
||||
shadowwallshader <-
|
||||
makeShaderUsingVBO "shadow/wallShadow" [vert, geom] (toFloatVAs [4]) pmPoints wallvbo
|
||||
shadowlightshader <-
|
||||
makeStaticShader
|
||||
"shadow/light"
|
||||
[vert, geom, frag]
|
||||
[VertexAttribute 1 GL_BYTE GL_FALSE 0]
|
||||
([1] :: [GLbyte])
|
||||
pmPoints
|
||||
shadowcombineshader <- makeShaderUsingVAO "shadow/combine" [vert, geom, frag] pmPoints
|
||||
(shadowlightshader ^. shaderVAO)
|
||||
|
||||
putStrLn "Setup 2D shaders"
|
||||
bslist <- makeShaderVBO "dualTwoD/basic" [vert, frag] (toFloatVAs [3, 4]) pmTriangles
|
||||
@@ -193,11 +178,6 @@ preloadRender = do
|
||||
, _lightingCapShader = lightingCapShad
|
||||
, _lightingLineShadowShader = lightingLineShadowShad
|
||||
, _lightingWallShadShader = lightingWallShadShad
|
||||
, _shadowEdgeShader = shadowedgeshader
|
||||
, _shadowCapShader = shadowcapshader
|
||||
, _shadowWallShader = shadowwallshader
|
||||
, _shadowLightShader = shadowlightshader
|
||||
, _shadowCombineShader = shadowcombineshader
|
||||
, _windowShader = windowshader
|
||||
, _fullscreenShader = fsShad
|
||||
, _alphaDivideShader = alphadivideshader
|
||||
|
||||
-133
@@ -6,14 +6,12 @@ module Render (
|
||||
) where
|
||||
|
||||
import Control.Lens
|
||||
import Control.Monad
|
||||
import Control.Monad.Primitive
|
||||
import Data.Preload.Render
|
||||
import qualified Data.Vector.Fusion.Stream.Monadic as VFSM
|
||||
import qualified Data.Vector.Mutable as MV
|
||||
import qualified Data.Vector.Unboxed.Mutable as UMV
|
||||
import Dodge.Data.Config
|
||||
import Dodge.WindowSize
|
||||
import Foreign hiding (rotate)
|
||||
import Geometry.Data
|
||||
import Graphics.GL.Core45
|
||||
@@ -41,7 +39,6 @@ createLightMap ::
|
||||
RenderData ->
|
||||
IO ()
|
||||
createLightMap cfig = case shadrendertype of
|
||||
InstancingShads -> instanceLightMap cfig
|
||||
NoShadows -> const . const . const renderLightingNoShadows
|
||||
NoLighting -> const . const . const . const . const . const renderFlatLighting
|
||||
_ -> renderShadows shadrendertype
|
||||
@@ -219,136 +216,6 @@ renderShadows shadrendertype nWalls nSils nCaps positiontexture normaltexture li
|
||||
glDisable GL_STENCIL_TEST
|
||||
glColorMask GL_TRUE GL_TRUE GL_TRUE GL_TRUE
|
||||
|
||||
lightsToArray :: [(Point3, Float, Point3)] -> [Float]
|
||||
lightsToArray xs =
|
||||
concat (take 20 $ map t xs ++ repeat [0, 0, 0, 0])
|
||||
++ concat (take 20 $ map s xs ++ repeat [0, 0, 0, 0])
|
||||
where
|
||||
t (V3 a b c, _, _) = [a, b, c, 1]
|
||||
s (_, d, V3 e f g) = [e, f, g, d]
|
||||
|
||||
instanceLightMap ::
|
||||
Configuration ->
|
||||
-- | number of walls
|
||||
GLsizei ->
|
||||
-- | number of silhoutte lines to draw
|
||||
Int ->
|
||||
-- | number of "caps" to attempt to draw
|
||||
Int ->
|
||||
-- | the texture object giving positions
|
||||
TO ->
|
||||
TO ->
|
||||
[(Point3, Float, Point3)] -> -- Lights
|
||||
RenderData ->
|
||||
IO ()
|
||||
instanceLightMap cfig nWalls nSils nCaps toPos tanormals lightPoints pdata = do
|
||||
let lcapShad = _shadowCapShader pdata
|
||||
(xsize, ysize) = getWindowSize _graphics_world_resolution cfig
|
||||
withArray (lightsToArray lightPoints) $ \ptr ->
|
||||
glNamedBufferSubData (pdata ^. lightsUBO) 0 620 ptr
|
||||
forM_ [0 .. 19] $ \i ->
|
||||
glCopyImageSubData
|
||||
(pdata ^. rboBaseBloom)
|
||||
GL_RENDERBUFFER
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
(pdata ^. fboShadow . _2 . _2 . unTO)
|
||||
GL_TEXTURE_2D_ARRAY
|
||||
0
|
||||
0
|
||||
0
|
||||
i
|
||||
xsize
|
||||
ysize
|
||||
1
|
||||
glBindFramebuffer GL_FRAMEBUFFER $ pdata ^. fboShadow . _1 . unFBO
|
||||
glDepthMask GL_FALSE
|
||||
withArray [0, 0, 0, 0] $ \ptr ->
|
||||
glClearNamedFramebufferfv
|
||||
(pdata ^. fboShadow . _1 . unFBO)
|
||||
GL_COLOR
|
||||
0
|
||||
ptr
|
||||
with 0 $ \ptr ->
|
||||
glClearNamedFramebufferiv
|
||||
(pdata ^. fboShadow . _1 . unFBO)
|
||||
GL_STENCIL
|
||||
0
|
||||
ptr
|
||||
-- stencil out the shadows from each light's point of view
|
||||
-- setup stencil
|
||||
glEnable GL_STENCIL_TEST
|
||||
glStencilOpSeparate GL_FRONT GL_KEEP GL_KEEP GL_INCR_WRAP
|
||||
glStencilOpSeparate GL_BACK GL_KEEP GL_KEEP GL_DECR_WRAP
|
||||
glDepthFunc GL_LESS
|
||||
glColorMask GL_FALSE GL_FALSE GL_FALSE GL_FALSE
|
||||
glDisable GL_BLEND
|
||||
glDisable GL_CULL_FACE
|
||||
glStencilFunc GL_ALWAYS 0 255
|
||||
--draw wall shadows
|
||||
glUseProgram $ pdata ^. shadowWallShader . shaderUINT
|
||||
glBindVertexArray $ pdata ^. shadowWallShader . shaderVAO . vaoName
|
||||
glDrawArrays
|
||||
(_unPrimitiveMode $ pdata ^. shadowWallShader . shaderPrimitive)
|
||||
0
|
||||
nWalls
|
||||
--draw silhouette shadows
|
||||
glUseProgram $ pdata ^. shadowEdgeShader . shaderUINT
|
||||
glBindVertexArray $ pdata ^. shadowEdgeShader . shaderVAO . vaoName
|
||||
glDrawElements
|
||||
(_unPrimitiveMode $ pdata ^. shadowEdgeShader . shaderPrimitive)
|
||||
(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)
|
||||
glBindVertexArray $ lcapShad ^. shaderVAO . vaoName
|
||||
glDrawElements
|
||||
(_unPrimitiveMode $ _shaderPrimitive lcapShad)
|
||||
(fromIntegral nCaps)
|
||||
GL_UNSIGNED_SHORT
|
||||
nullPtr
|
||||
--draw lightmap itself
|
||||
glDepthFunc GL_ALWAYS
|
||||
glColorMask GL_TRUE GL_TRUE GL_TRUE GL_TRUE
|
||||
glStencilFunc GL_EQUAL 0 255
|
||||
glUseProgram (pdata ^. shadowLightShader . shaderUINT)
|
||||
-- bind world position texture
|
||||
glBindTextureUnit 0 (toPos ^. unTO)
|
||||
glBindTextureUnit 1 (tanormals ^. unTO)
|
||||
glDrawArrays
|
||||
(_unPrimitiveMode $ pdata ^. shadowLightShader . shaderPrimitive)
|
||||
0
|
||||
1
|
||||
glDisable GL_CULL_FACE
|
||||
glDisable GL_STENCIL_TEST
|
||||
--draw to the lighting framebuffer here
|
||||
glBindFramebuffer GL_FRAMEBUFFER (_unFBO (fst (_fboLighting pdata)))
|
||||
withArray [1, 1, 1, 1] $ \ptr ->
|
||||
glClearNamedFramebufferfv
|
||||
(pdata ^. fboLighting . _1 . unFBO)
|
||||
GL_COLOR
|
||||
0
|
||||
ptr
|
||||
glBindTextureUnit 0 (pdata ^. fboShadow . _2 . _1 . unTO)
|
||||
glEnable GL_BLEND
|
||||
glBlendFunc GL_ZERO GL_ONE_MINUS_SRC_COLOR
|
||||
glUseProgram (pdata ^. shadowCombineShader . shaderUINT)
|
||||
glDrawArrays
|
||||
GL_POINTS
|
||||
0
|
||||
1
|
||||
withArray [GL_COLOR_ATTACHMENT0, GL_DEPTH_STENCIL_ATTACHMENT] $ \ptr ->
|
||||
glInvalidateNamedFramebufferData
|
||||
(pdata ^. fboShadow . _1 . unFBO)
|
||||
2
|
||||
ptr
|
||||
|
||||
-- assumes that vertices have already been sent to the shader
|
||||
pingPongBetween ::
|
||||
(FBO, TO) ->
|
||||
|
||||
Reference in New Issue
Block a user