Implement different shadow resolutions
This commit is contained in:
+7
-13
@@ -50,26 +50,22 @@ setWallDepth pdata wallPoints (viewFromx,viewFromy) pmat = do
|
||||
endTicks <- SDL.ticks
|
||||
return $ endTicks - startTicks
|
||||
|
||||
halfSize (Size x y) = Size (div x 2) (div y 2)
|
||||
divideSize :: Int -> Size -> Size
|
||||
divideSize i (Size x y) = Size (div x $ fromIntegral i) (div y $ fromIntegral i)
|
||||
|
||||
createLightMap
|
||||
:: RenderData
|
||||
-> Float -- Rotation
|
||||
-> Float -- Zoom
|
||||
-> (Float,Float) -- Translation
|
||||
-> (Float,Float) -- Window size
|
||||
-> Int -- Resolution division
|
||||
-> [(Point2,Point2)] -- Wall pairs
|
||||
-> [Point4] -- Lights
|
||||
-> (Float,Float) -- View from position
|
||||
-> GLmatrix GLfloat
|
||||
-> IO ()
|
||||
createLightMap pdata rot zoom (tranx,trany) (winx',winy') wallPoints lightPoints
|
||||
createLightMap pdata resDiv wallPoints lightPoints
|
||||
(viewFromx,viewFromy) pmat = do
|
||||
let winx = winx' / 2
|
||||
winy = winy' / 2
|
||||
|
||||
(vppos,vpsize) <- get viewport
|
||||
viewport $= (vppos, halfSize vpsize)
|
||||
viewport $= (vppos, divideSize resDiv vpsize)
|
||||
|
||||
bindFramebuffer Framebuffer $= _spareFBO pdata
|
||||
-- store wall and light positions into buffer
|
||||
@@ -88,7 +84,7 @@ createLightMap pdata rot zoom (tranx,trany) (winx',winy') wallPoints lightPoints
|
||||
depthFunc $= Just Less
|
||||
-- draw walls from your point of view in order to set z buffer
|
||||
colorMask $= Color4 Disabled Disabled Disabled Disabled
|
||||
let (tx,ty) = (tranx,trany) -.- (viewFromx,viewFromy)
|
||||
-- let (tx,ty) = (tranx,trany) -.- (viewFromx,viewFromy)
|
||||
currentProgram $= Just (_shaderProgram $ _lightingOccludeShader pdata)
|
||||
uniform (head $ fromJust $ _shaderCustomUnis $ _lightingOccludeShader pdata)
|
||||
$= Vector2 viewFromx viewFromy
|
||||
@@ -109,9 +105,7 @@ createLightMap pdata rot zoom (tranx,trany) (winx',winy') wallPoints lightPoints
|
||||
-- bind buffer for floor light circle
|
||||
let lightPtr = (\(_,ptr,_) -> ptr) $ head
|
||||
$ _vaoBufferTargets $ _shaderVAO $ _lightingFloorShader pdata
|
||||
(x',y') = zTran $ rotateV (negate rot) $ (x,y) -.- (tranx,trany)
|
||||
zTran (a,b) = (a*2*zoom / winx, b*2*zoom / winy)
|
||||
pokeFourOff lightPtr 0 (x',y',r,lum)
|
||||
pokeFourOff lightPtr 0 (x,y,r,lum)
|
||||
-- stencil out walls
|
||||
colorMask $= Color4 Disabled Disabled Disabled Disabled
|
||||
clear [StencilBuffer]
|
||||
|
||||
Reference in New Issue
Block a user