Try to add compute shaders
This commit is contained in:
@@ -100,6 +100,7 @@ data ShadowRendering
|
||||
| NoObjShads
|
||||
| NoShadows
|
||||
| NoLighting
|
||||
| ComputeShader
|
||||
deriving (Show, Eq, Ord, Enum, Bounded)
|
||||
|
||||
data RoomClipping = NoRoomClipBoundaries | AllRoomClipBoundaries | IntersectingRoomClipBoundaries
|
||||
|
||||
+8
-1
@@ -15,6 +15,12 @@ import Dodge.Tree
|
||||
import LensHelp
|
||||
import RandomHelp
|
||||
|
||||
startWorldTreeTest :: Annotation
|
||||
startWorldTreeTest =
|
||||
OnwardList $
|
||||
[ IntAnno $ AnTree . startRoom
|
||||
]
|
||||
|
||||
initialAnoTree :: Annotation
|
||||
initialAnoTree =
|
||||
OnwardList $
|
||||
@@ -103,4 +109,5 @@ initialAnoTree =
|
||||
|
||||
-- | A test level tree.
|
||||
initialRoomTree :: State (StdGen, Int) (MetaTree Room String)
|
||||
initialRoomTree = annoToRoomTree initialAnoTree
|
||||
--initialRoomTree = annoToRoomTree initialAnoTree
|
||||
initialRoomTree = annoToRoomTree startWorldTreeTest
|
||||
|
||||
@@ -91,7 +91,7 @@ baseBlockPane =
|
||||
--, _wlColor = greyN 0.5
|
||||
, _wlColor = dark $ dark orange
|
||||
--, _wlOpacity = Opaque 10
|
||||
, _wlOpacity = Opaque 14
|
||||
, _wlOpacity = Opaque 17
|
||||
, _wlUnshadowed = True
|
||||
, _wlFireThrough = True
|
||||
, _wlPenetrable = True
|
||||
|
||||
+100
-97
@@ -209,6 +209,9 @@ doDrawing' win pdata u = do
|
||||
pdata
|
||||
glColorMask GL_TRUE GL_TRUE GL_TRUE GL_TRUE
|
||||
--apply lightmap to base buffer
|
||||
glDisable GL_CULL_FACE
|
||||
glDepthFunc GL_ALWAYS
|
||||
glDepthMask GL_FALSE
|
||||
glBindFramebuffer GL_FRAMEBUFFER (pdata ^. fboBase . _1 . unFBO)
|
||||
glBindTextureUnit 0 (pdata ^. fboLighting . _2 . unTO)
|
||||
glEnable GL_BLEND
|
||||
@@ -244,100 +247,100 @@ doDrawing' win pdata u = do
|
||||
replicateM_ 2 $ pingPongBetween (_fboHalf1 pdata) (_fboHalf2 pdata) (_bloomBlurShader pdata)
|
||||
glEnable GL_BLEND
|
||||
setViewport _graphics_world_resolution cfig
|
||||
--draw clouds onto cloud buffer
|
||||
glBindFramebuffer GL_FRAMEBUFFER (_unFBO (fst (_fboCloud pdata)))
|
||||
glDepthFunc GL_LEQUAL
|
||||
glDepthMask GL_FALSE
|
||||
--blendFunc $= (SrcAlphaSaturate,One)
|
||||
--blendColor $= Color4 0.5 0.5 0.5 0.5
|
||||
--blendFuncSeparate $= ((SrcAlphaSaturate,One) , (One,OneMinusSrcAlpha))
|
||||
--blendFuncSeparate $= ((SrcAlpha, OneMinusSrcAlpha), (One, OneMinusSrcAlpha))
|
||||
--glBlendFuncSeparate GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA GL_ONE GL_ONE_MINUS_SRC_ALPHA
|
||||
glBlendFuncSeparate GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA GL_ONE_MINUS_DST_ALPHA GL_ONE
|
||||
--glBlendFuncSeparate GL_SRC_ALPHA_SATURATE GL_ONE_MINUS_SRC_ALPHA GL_ONE GL_ONE_MINUS_SRC_ALPHA
|
||||
--glBlendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
|
||||
withArray [GL_COLOR_ATTACHMENT0, GL_NONE] $ \ptr -> glDrawBuffers 2 ptr
|
||||
withArray [0.5, 0.5, 0.5, 0] $ \ptr ->
|
||||
glClearNamedFramebufferfv
|
||||
(pdata ^. fboCloud . _1 . unFBO)
|
||||
GL_COLOR
|
||||
0
|
||||
ptr
|
||||
-- renderLayer MidLayer shadV layerCounts
|
||||
glUseProgram (pdata ^. cloudShader . shaderUINT)
|
||||
glBindVertexArray $ pdata ^. cloudShader . shaderVAO . vaoName
|
||||
glDrawElements
|
||||
(pdata ^. cloudShader . shaderPrimitive . unPrimitiveMode)
|
||||
(fromIntegral nCloudIs)
|
||||
GL_UNSIGNED_SHORT
|
||||
nullPtr
|
||||
drawShader (_windowShader pdata) nWins
|
||||
when (_graphics_cloud_shadows cfig) $ do
|
||||
----render transparency depths
|
||||
glDepthMask GL_TRUE
|
||||
glDepthFunc GL_ALWAYS
|
||||
glDisable GL_BLEND
|
||||
withArray [GL_NONE, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2] $ \ptr -> glDrawBuffers 3 ptr
|
||||
withArray [0, 0, 0, 0] $ \ptr ->
|
||||
glClearNamedFramebufferfv
|
||||
(pdata ^. fboCloud . _1 . unFBO)
|
||||
GL_COLOR
|
||||
1
|
||||
ptr
|
||||
withArray [0, 0, 0, 0] $ \ptr ->
|
||||
glClearNamedFramebufferfv
|
||||
(pdata ^. fboCloud . _1 . unFBO)
|
||||
GL_COLOR
|
||||
2
|
||||
ptr
|
||||
glEnable GL_BLEND
|
||||
-- we sum the positions weighted by alpha, and sum the alpha
|
||||
glBlendFuncSeparatei 1 GL_SRC_ALPHA GL_ONE GL_ONE GL_ONE
|
||||
-- and sum the normals weighted by alpha
|
||||
glBlendFunci 2 GL_SRC_ALPHA GL_ONE
|
||||
glUseProgram (pdata ^. cloudShader . shaderUINT)
|
||||
glBindVertexArray $ pdata ^. cloudShader . shaderVAO . vaoName
|
||||
glDepthMask GL_TRUE
|
||||
glDrawElements
|
||||
(pdata ^. cloudShader . shaderPrimitive . unPrimitiveMode)
|
||||
(fromIntegral nCloudIs)
|
||||
GL_UNSIGNED_SHORT
|
||||
nullPtr
|
||||
drawShader (_windowShader pdata) nWins
|
||||
glBindFramebuffer GL_FRAMEBUFFER (pdata ^. fboPos . _1 . unFBO)
|
||||
withArray [0, 0, 0, 0] $ \ptr ->
|
||||
glClearNamedFramebufferfv
|
||||
(pdata ^. fboPos . _1 . unFBO)
|
||||
GL_COLOR
|
||||
0
|
||||
ptr
|
||||
glBindTextureUnit 0 (pdata ^. fboCloud . _2 . _2 . unTO)
|
||||
glDepthMask GL_FALSE
|
||||
drawShader (pdata ^. alphaDivideShader) 4
|
||||
----draw lightmap for cloud buffer
|
||||
glDepthFunc GL_LESS
|
||||
glEnable GL_BLEND
|
||||
glBindFramebuffer GL_FRAMEBUFFER (_unFBO (fst (_fboLighting pdata)))
|
||||
createLightMap
|
||||
cfig
|
||||
(fromIntegral trueNWalls)
|
||||
nSilIndices
|
||||
nIndices
|
||||
(pdata ^. fboPos . _2)
|
||||
(pdata ^. fboCloud . _2 . _3)
|
||||
lightPoints
|
||||
pdata
|
||||
glInvalidateBufferData (pdata ^. vboShapes . vboName)
|
||||
--apply lightmap to cloud buffer
|
||||
glBindFramebuffer GL_FRAMEBUFFER (_unFBO (fst (_fboCloud pdata)))
|
||||
glDepthMask GL_FALSE
|
||||
withArray [GL_COLOR_ATTACHMENT0, GL_NONE] $ \ptr -> glDrawBuffers 2 ptr
|
||||
glDepthFunc GL_ALWAYS
|
||||
glBindTextureUnit 0 (_unTO . snd $ _fboLighting pdata)
|
||||
glEnable GL_BLEND
|
||||
glBlendFuncSeparate GL_ZERO GL_ONE_MINUS_SRC_COLOR GL_ZERO GL_ONE
|
||||
drawShader (_fullscreenShader pdata) 4
|
||||
glBlendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
|
||||
-- --draw clouds onto cloud buffer
|
||||
-- glBindFramebuffer GL_FRAMEBUFFER (_unFBO (fst (_fboCloud pdata)))
|
||||
-- glDepthFunc GL_LEQUAL
|
||||
-- glDepthMask GL_FALSE
|
||||
-- --blendFunc $= (SrcAlphaSaturate,One)
|
||||
-- --blendColor $= Color4 0.5 0.5 0.5 0.5
|
||||
-- --blendFuncSeparate $= ((SrcAlphaSaturate,One) , (One,OneMinusSrcAlpha))
|
||||
-- --blendFuncSeparate $= ((SrcAlpha, OneMinusSrcAlpha), (One, OneMinusSrcAlpha))
|
||||
-- --glBlendFuncSeparate GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA GL_ONE GL_ONE_MINUS_SRC_ALPHA
|
||||
-- glBlendFuncSeparate GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA GL_ONE_MINUS_DST_ALPHA GL_ONE
|
||||
-- --glBlendFuncSeparate GL_SRC_ALPHA_SATURATE GL_ONE_MINUS_SRC_ALPHA GL_ONE GL_ONE_MINUS_SRC_ALPHA
|
||||
-- --glBlendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
|
||||
-- withArray [GL_COLOR_ATTACHMENT0, GL_NONE] $ \ptr -> glDrawBuffers 2 ptr
|
||||
-- withArray [0.5, 0.5, 0.5, 0] $ \ptr ->
|
||||
-- glClearNamedFramebufferfv
|
||||
-- (pdata ^. fboCloud . _1 . unFBO)
|
||||
-- GL_COLOR
|
||||
-- 0
|
||||
-- ptr
|
||||
-- -- renderLayer MidLayer shadV layerCounts
|
||||
-- glUseProgram (pdata ^. cloudShader . shaderUINT)
|
||||
-- glBindVertexArray $ pdata ^. cloudShader . shaderVAO . vaoName
|
||||
-- glDrawElements
|
||||
-- (pdata ^. cloudShader . shaderPrimitive . unPrimitiveMode)
|
||||
-- (fromIntegral nCloudIs)
|
||||
-- GL_UNSIGNED_SHORT
|
||||
-- nullPtr
|
||||
-- drawShader (_windowShader pdata) nWins
|
||||
-- when (_graphics_cloud_shadows cfig) $ do
|
||||
-- ----render transparency depths
|
||||
-- glDepthMask GL_TRUE
|
||||
-- glDepthFunc GL_ALWAYS
|
||||
-- glDisable GL_BLEND
|
||||
-- withArray [GL_NONE, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2] $ \ptr -> glDrawBuffers 3 ptr
|
||||
-- withArray [0, 0, 0, 0] $ \ptr ->
|
||||
-- glClearNamedFramebufferfv
|
||||
-- (pdata ^. fboCloud . _1 . unFBO)
|
||||
-- GL_COLOR
|
||||
-- 1
|
||||
-- ptr
|
||||
-- withArray [0, 0, 0, 0] $ \ptr ->
|
||||
-- glClearNamedFramebufferfv
|
||||
-- (pdata ^. fboCloud . _1 . unFBO)
|
||||
-- GL_COLOR
|
||||
-- 2
|
||||
-- ptr
|
||||
-- glEnable GL_BLEND
|
||||
-- -- we sum the positions weighted by alpha, and sum the alpha
|
||||
-- glBlendFuncSeparatei 1 GL_SRC_ALPHA GL_ONE GL_ONE GL_ONE
|
||||
-- -- and sum the normals weighted by alpha
|
||||
-- glBlendFunci 2 GL_SRC_ALPHA GL_ONE
|
||||
-- glUseProgram (pdata ^. cloudShader . shaderUINT)
|
||||
-- glBindVertexArray $ pdata ^. cloudShader . shaderVAO . vaoName
|
||||
-- glDepthMask GL_TRUE
|
||||
-- glDrawElements
|
||||
-- (pdata ^. cloudShader . shaderPrimitive . unPrimitiveMode)
|
||||
-- (fromIntegral nCloudIs)
|
||||
-- GL_UNSIGNED_SHORT
|
||||
-- nullPtr
|
||||
-- drawShader (_windowShader pdata) nWins
|
||||
-- glBindFramebuffer GL_FRAMEBUFFER (pdata ^. fboPos . _1 . unFBO)
|
||||
-- withArray [0, 0, 0, 0] $ \ptr ->
|
||||
-- glClearNamedFramebufferfv
|
||||
-- (pdata ^. fboPos . _1 . unFBO)
|
||||
-- GL_COLOR
|
||||
-- 0
|
||||
-- ptr
|
||||
-- glBindTextureUnit 0 (pdata ^. fboCloud . _2 . _2 . unTO)
|
||||
-- glDepthMask GL_FALSE
|
||||
-- drawShader (pdata ^. alphaDivideShader) 4
|
||||
-- ----draw lightmap for cloud buffer
|
||||
-- glDepthFunc GL_LESS
|
||||
-- glEnable GL_BLEND
|
||||
-- glBindFramebuffer GL_FRAMEBUFFER (_unFBO (fst (_fboLighting pdata)))
|
||||
-- createLightMap
|
||||
-- cfig
|
||||
-- (fromIntegral trueNWalls)
|
||||
-- nSilIndices
|
||||
-- nIndices
|
||||
-- (pdata ^. fboPos . _2)
|
||||
-- (pdata ^. fboCloud . _2 . _3)
|
||||
-- lightPoints
|
||||
-- pdata
|
||||
-- glInvalidateBufferData (pdata ^. vboShapes . vboName)
|
||||
-- --apply lightmap to cloud buffer
|
||||
-- glBindFramebuffer GL_FRAMEBUFFER (_unFBO (fst (_fboCloud pdata)))
|
||||
-- glDepthMask GL_FALSE
|
||||
-- withArray [GL_COLOR_ATTACHMENT0, GL_NONE] $ \ptr -> glDrawBuffers 2 ptr
|
||||
-- glDepthFunc GL_ALWAYS
|
||||
-- glBindTextureUnit 0 (_unTO . snd $ _fboLighting pdata)
|
||||
-- glEnable GL_BLEND
|
||||
-- glBlendFuncSeparate GL_ZERO GL_ONE_MINUS_SRC_COLOR GL_ZERO GL_ONE
|
||||
-- drawShader (_fullscreenShader pdata) 4
|
||||
-- glBlendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
|
||||
-- bind base buffer for drawing bloom then clouds
|
||||
glBindFramebuffer GL_FRAMEBUFFER (_unFBO (fst (_fboBase pdata)))
|
||||
--Draw blurred bloom onto base buffer
|
||||
@@ -346,9 +349,9 @@ doDrawing' win pdata u = do
|
||||
glBindTextureUnit 0 (_unTO . snd $ _fboHalf1 pdata)
|
||||
drawShader (_fullscreenShader pdata) 4
|
||||
glBlendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
|
||||
--draw shadowed clouds onto base buffer
|
||||
glBindTextureUnit 0 (pdata ^. fboCloud . _2 . _1 . unTO)
|
||||
drawShader (_fullscreenShader pdata) 4
|
||||
-- --draw shadowed clouds onto base buffer
|
||||
-- glBindTextureUnit 0 (pdata ^. fboCloud . _2 . _1 . unTO)
|
||||
-- drawShader (_fullscreenShader pdata) 4
|
||||
--set viewport for radial distortion
|
||||
--setViewportSize (round winx) (round winy)
|
||||
setViewport (const FullRes) cfig
|
||||
|
||||
@@ -19,6 +19,7 @@ import Dodge.Data.Universe
|
||||
testStringInit :: Universe -> [String]
|
||||
testStringInit u = [show $ u ^. uvWorld . input . smoothScrollAmount
|
||||
, show $ getSmoothScrollValue (u ^. uvWorld . input)
|
||||
, show (u ^. uvConfig . windowX) ++ " " ++ show (u ^. uvConfig . windowY)
|
||||
]
|
||||
-- [show $ length $ lightsToRender (u ^. uvConfig) (u ^. uvWorld . wCam)
|
||||
-- (u ^. uvWorld . cWorld . lWorld)
|
||||
|
||||
Reference in New Issue
Block a user