Commit before attempting to implement immutable buffer storage (openGL)
This commit is contained in:
+14
-9
@@ -4,14 +4,14 @@ module Dodge.Render (
|
||||
getWindowSize
|
||||
) where
|
||||
|
||||
--import qualified Data.Vector as V
|
||||
import qualified Data.Vector as V
|
||||
|
||||
import Dodge.Shadows
|
||||
import Dodge.WindowSize
|
||||
import Control.Lens
|
||||
import Control.Monad
|
||||
import qualified Control.Monad.Parallel as MP
|
||||
import Data.List (sortOn)
|
||||
--import Data.List (sortOn)
|
||||
import qualified Data.Map.Strict as M
|
||||
import Data.Preload.Render
|
||||
import qualified Data.Vector.Unboxed.Mutable as UMV
|
||||
@@ -85,10 +85,12 @@ doDrawing' win pdata u = do
|
||||
ws
|
||||
)
|
||||
(nCloudVs, nCloudIs) <-
|
||||
foldM
|
||||
-- Might want to sort the clouds based on z depth, not sure
|
||||
V.foldM'
|
||||
(pokeCloud (pdata ^. cloudVBO . vboPtr) (pdata ^. cloudEBO . eboPtr))
|
||||
(0, 0)
|
||||
(sortOn (^. clPos . _3) $ w ^. cWorld . lWorld . clouds)
|
||||
(V.fromList $ w ^. cWorld . lWorld . clouds)
|
||||
--(sortOn (^. clPos . _3) $ w ^. cWorld . lWorld . clouds)
|
||||
-- bind wall points, silhouette data, surface geometry
|
||||
bufferShaderLayers shadV layerCounts
|
||||
mapM_
|
||||
@@ -226,8 +228,11 @@ doDrawing' win pdata u = do
|
||||
glBindTextureUnit 0 (pdata ^. fboBloom . _2 . unTO)
|
||||
glDisable GL_BLEND
|
||||
drawShader (_bloomBlurShader pdata) 4
|
||||
replicateM_ 2 $ pingPongBetween (_fboHalf1 pdata) (_fboHalf2 pdata) (_bloomBlurShader pdata)
|
||||
glEnable GL_BLEND
|
||||
if cfig ^. graphics_bloom
|
||||
then do
|
||||
replicateM_ 2 $ pingPongBetween (_fboHalf1 pdata) (_fboHalf2 pdata) (_bloomBlurShader pdata)
|
||||
glEnable GL_BLEND
|
||||
else return ()
|
||||
setViewport _graphics_world_resolution cfig
|
||||
--draw clouds onto cloud buffer
|
||||
glBindFramebuffer GL_FRAMEBUFFER (_unFBO (fst (_fboCloud pdata)))
|
||||
@@ -341,12 +346,12 @@ doDrawing' win pdata u = do
|
||||
glBlendFunc GL_ONE GL_ZERO
|
||||
-- perform any radial distortion
|
||||
-- this is hideous
|
||||
case getDistortions cfig w of
|
||||
[] -> do
|
||||
case (getDistortions cfig w, cfig ^. graphics_distortions) of
|
||||
(rds, x) | null rds || not x -> do
|
||||
glBindTextureUnit 0 $ pdata ^. fboBase . _2 . _1 . unTO
|
||||
glBindFramebuffer GL_FRAMEBUFFER 0
|
||||
drawShader (_fullscreenShader pdata) 4
|
||||
rds -> do
|
||||
(rds,_) -> do
|
||||
let bindDrawDist :: Distortion -> IO ()
|
||||
bindDrawDist (RadialDistortion (V2 a b) (V2 c d) (V2 e f) g) = do
|
||||
pokeArray (shadVBOptr $ _barrelShader pdata) [a, b, c, d, e, f, g]
|
||||
|
||||
+7
-5
@@ -150,7 +150,7 @@ renderShadows ::
|
||||
RenderData ->
|
||||
IO ()
|
||||
renderShadows shadrendertype nWalls nSils nCaps positiontexture normaltexture lightPoints pdata = do
|
||||
glBindFramebuffer GL_FRAMEBUFFER (_unFBO (fst (_fboLighting pdata)))
|
||||
glBindFramebuffer GL_FRAMEBUFFER $ pdata ^. fboLighting . _1 . unFBO --(_unFBO (fst (_fboLighting pdata)))
|
||||
let llinesShad = _lightingLineShadowShader pdata
|
||||
lcapShad = _lightingCapShader pdata
|
||||
lwallShad = _lightingWallShadShader pdata
|
||||
@@ -166,9 +166,7 @@ renderShadows shadrendertype nWalls nSils nCaps positiontexture normaltexture li
|
||||
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 and normal
|
||||
-- setup stencil and blending
|
||||
glBlendFunc GL_ZERO GL_ONE_MINUS_SRC_COLOR
|
||||
glEnable GL_STENCIL_TEST
|
||||
glStencilOpSeparate GL_FRONT GL_KEEP GL_KEEP GL_INCR_WRAP
|
||||
@@ -176,6 +174,9 @@ renderShadows shadrendertype nWalls nSils nCaps positiontexture normaltexture li
|
||||
-- bind world position texture-- these will be used by the lighting shader
|
||||
glBindTextureUnit 0 (positiontexture ^. unTO)
|
||||
glBindTextureUnit 1 (normaltexture ^. unTO)
|
||||
-- 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 and normal
|
||||
flip VFSM.mapM_ (VFSM.fromList lightPoints) $ \(V3 x y z, rad, V3 r g b) -> do
|
||||
glDepthFunc GL_LESS
|
||||
-- setup stencil
|
||||
@@ -226,7 +227,7 @@ renderShadows shadrendertype nWalls nSils nCaps positiontexture normaltexture li
|
||||
--draw lightmap itself
|
||||
glDepthFunc GL_ALWAYS
|
||||
glDisable GL_CULL_FACE
|
||||
glColorMask GL_TRUE GL_TRUE GL_TRUE GL_TRUE
|
||||
glColorMask GL_TRUE GL_TRUE GL_TRUE GL_FALSE
|
||||
glStencilFunc GL_EQUAL 0 255
|
||||
glUseProgram (ltextShad ^. shaderUINT) --Just (_shadProg ltextShad)
|
||||
glUniform3f 0 x y z
|
||||
@@ -238,6 +239,7 @@ renderShadows shadrendertype nWalls nSils nCaps positiontexture normaltexture li
|
||||
(fromIntegral (4 :: Int))
|
||||
--cleanup: may not be necessary, depending on what comes after...
|
||||
glDisable GL_STENCIL_TEST
|
||||
glColorMask GL_TRUE GL_TRUE GL_TRUE GL_TRUE
|
||||
|
||||
lightsToArray :: [(Point3, Float, Point3)] -> [Float]
|
||||
lightsToArray xs =
|
||||
|
||||
Reference in New Issue
Block a user