Fix direction stuttering bug
This commit is contained in:
+10
-20
@@ -11,15 +11,12 @@ module Render
|
||||
import Shader
|
||||
import Shader.ExtraPrimitive
|
||||
import Shader.Data
|
||||
--import Shader.Poke
|
||||
import Data.Preload.Render
|
||||
import Picture.Data
|
||||
import Geometry.Data
|
||||
|
||||
--import Data.Foldable
|
||||
import Foreign hiding (rotate)
|
||||
import Graphics.Rendering.OpenGL hiding (Line,translate,scale,imageHeight,Polygon,Color,T)
|
||||
--import qualified SDL
|
||||
import qualified Data.Vector.Unboxed.Mutable as UMV
|
||||
import qualified Data.Vector.Mutable as MV
|
||||
import Control.Monad.Primitive
|
||||
@@ -29,9 +26,6 @@ import Graphics.GL.Core43
|
||||
divideSize :: Int -> Size -> Size
|
||||
divideSize i (Size x y) = Size (div x $ fromIntegral i) (div y $ fromIntegral i)
|
||||
|
||||
--sizeToTexSize :: Size -> TextureSize2D
|
||||
--sizeToTexSize (Size x y) = TextureSize2D x y
|
||||
|
||||
{- | Determine where light is shining in the world. -}
|
||||
createLightMap
|
||||
:: RenderData
|
||||
@@ -42,6 +36,8 @@ createLightMap
|
||||
-> TextureObject -- ^ the texture object giving positions
|
||||
-> IO ()
|
||||
createLightMap pdata lightPoints nWalls nSils nCaps toPos = do
|
||||
let llsShad = _lightingLineShadowShader pdata
|
||||
let lcShad = _lightingCapShader pdata
|
||||
-- we assume that the renderbuffer's depth has been correctly set elsewhere
|
||||
-- we will not be changing that here
|
||||
depthMask $= Disabled
|
||||
@@ -68,35 +64,29 @@ createLightMap pdata lightPoints nWalls nSils nCaps toPos = do
|
||||
$= Vector3 x y z
|
||||
drawShader (_lightingOccludeShader pdata) nWalls
|
||||
--draw silhouette shadows
|
||||
let llss = _lightingLineShadowShader pdata
|
||||
currentProgram $= Just (_shadProg $ _lightingLineShadowShader pdata)
|
||||
currentProgram $= Just (_shadProg llsShad)
|
||||
uniform (head $ _shadUnis $ _lightingLineShadowShader pdata)
|
||||
$= Vector3 x y z
|
||||
-- drawShader (_lightingLineShadowShader pdata) nSils
|
||||
bindVertexArrayObject $= Just (_vao $ _shadVAO llss)
|
||||
bindVertexArrayObject $= Just (_vao $ _shadVAO llsShad)
|
||||
glDrawElements
|
||||
(marshalEPrimitiveMode $ _shadPrim llss)
|
||||
(marshalEPrimitiveMode $ _shadPrim llsShad)
|
||||
(fromIntegral nSils)
|
||||
GL_UNSIGNED_SHORT
|
||||
nullPtr
|
||||
cullFace $= Just Back
|
||||
|
||||
--draw caps on the near plane as required
|
||||
currentProgram $= Just (_shadProg $ _lightingCapShader pdata)
|
||||
uniform (head $ _shadUnis $ _lightingCapShader pdata)
|
||||
currentProgram $= Just (_shadProg $ lcShad)
|
||||
uniform (head $ _shadUnis $ lcShad)
|
||||
$= Vector3 x y z
|
||||
-- TODO clean this up
|
||||
let fs = _lightingCapShader pdata
|
||||
bindVertexArrayObject $= Just (_vao $ _shadVAO fs)
|
||||
bindVertexArrayObject $= Just (_vao $ _shadVAO lcShad)
|
||||
glDrawElements
|
||||
(marshalEPrimitiveMode $ _shadPrim fs)
|
||||
(marshalEPrimitiveMode $ _shadPrim lcShad)
|
||||
(fromIntegral nCaps)
|
||||
GL_UNSIGNED_SHORT
|
||||
nullPtr
|
||||
--drawShader (_lightingCapShader pdata) nCaps
|
||||
--draw lightmap itself
|
||||
depthFunc $= Just Always
|
||||
--cullFace $= Nothing
|
||||
-- bind world position texture
|
||||
bindTO toPos
|
||||
colorMask $= Color4 Enabled Enabled Enabled Enabled
|
||||
stencilOp $= (OpKeep,OpKeep,OpKeep)
|
||||
|
||||
Reference in New Issue
Block a user