diff --git a/shader/lighting/wall.geom b/shader/lighting/wall.geom index 7027ee0c4..2a56b70bf 100644 --- a/shader/lighting/wall.geom +++ b/shader/lighting/wall.geom @@ -25,8 +25,8 @@ if (isLHS (p1.xy - lightPos, p2.xy - lightPos) < 0) lum = radLum.y; float rad = radLum.x; - vec4 p3 = vec4 (p1.xy,-0.5,1); - vec4 p4 = vec4 (p2.xy,-0.5,1); + vec4 p3 = vec4 (p1.xy,-0.2,1); + vec4 p4 = vec4 (p2.xy,-0.2,1); vec2 d1 = p1.xy - lightPos; vec2 d2 = p2.xy - lightPos; @@ -39,13 +39,13 @@ if (isLHS (p1.xy - lightPos, p2.xy - lightPos) < 0) dField = vec3( d1.x/rad, d1.y/rad, 0); gl_Position = a1; EmitVertex(); - dField = vec3( d1.x/rad, d1.y/rad, 1); + dField = vec3( d1.x/rad, d1.y/rad, 0); gl_Position = a3; EmitVertex(); dField = vec3( d2.x/rad, d2.y/rad, 0); gl_Position = a2; EmitVertex(); - dField = vec3( d2.x/rad, d2.y/rad, 1); + dField = vec3( d2.x/rad, d2.y/rad, 0); gl_Position = a4; EmitVertex(); diff --git a/shader/twoD/basic.vert b/shader/twoD/basic.vert index aac780c96..b2b5d4ca6 100644 --- a/shader/twoD/basic.vert +++ b/shader/twoD/basic.vert @@ -3,10 +3,10 @@ layout (location = 0) in vec3 position; layout (location = 1) in vec4 color; out vec4 vColor; -uniform vec2 winSize; -uniform float zoom; -uniform float rotation; -uniform vec2 translation; +//uniform vec2 winSize; +//uniform float zoom; +//uniform float rotation; +//uniform vec2 translation; uniform mat4 worldMat; void main() diff --git a/shader/wall/texture.geom b/shader/wall/texture.geom index 7f2cc9b7d..9f16874c8 100644 --- a/shader/wall/texture.geom +++ b/shader/wall/texture.geom @@ -20,8 +20,8 @@ void main() vec4 p1 = vec4 (gl_in[0].gl_Position.xy,0,1); vec4 p2 = vec4 (gl_in[0].gl_Position.zw,0,1); -vec4 p3 = vec4 (p1.xy,-0.5,1); -vec4 p4 = vec4 (p2.xy,-0.5,1); +vec4 p3 = vec4 (p1.xy,-0.3,1); +vec4 p4 = vec4 (p2.xy,-0.3,1); vec4 a1 = perpMat * p1; vec4 a2 = perpMat * p2; diff --git a/src/Dodge/Data.hs b/src/Dodge/Data.hs index 26ed51874..60a6253ed 100644 --- a/src/Dodge/Data.hs +++ b/src/Dodge/Data.hs @@ -73,6 +73,8 @@ data World = World , _soundQueue :: [(Int,Int16)] , _sounds :: M.Map SoundOrigin Sound , _decorations :: IM.IntMap Picture + , _foregroundDecorations :: [Picture] + , _midgroundDecorations :: [Picture] , _corpses :: IM.IntMap (IM.IntMap [Corpse]) , _clickMousePos :: (Float,Float) , _pathGraph :: ~(Gr Point2 Float) diff --git a/src/Dodge/Default.hs b/src/Dodge/Default.hs index e672956ef..f54b42fe5 100644 --- a/src/Dodge/Default.hs +++ b/src/Dodge/Default.hs @@ -88,7 +88,20 @@ defaultWorld = World , _debugFlags = defaultDebugFlags , _inventoryMode = TopInventory , _lClickHammer = HammerUp + , _foregroundDecorations = + [setDepth (-0.2) $ rotate 0.75 $ pictures + $ map f [5,25,45,65] + ] + , _midgroundDecorations = + [setDepth (-0.1) $ color orange $ pictures + [ polygon $ rectNSEW 50 40 140 (-20) + , translate 60 45 $ thickArc 0 pi 75 10 + ] + ] } + where + f x = polygon $ rectNSEW (x - 20) (x-22) 500 0 + defaultCreature :: Creature defaultCreature = Creature { _crPos = (0,0) diff --git a/src/Dodge/Render.hs b/src/Dodge/Render.hs index 5ba8c1c47..24cac58e4 100644 --- a/src/Dodge/Render.hs +++ b/src/Dodge/Render.hs @@ -52,7 +52,7 @@ doDrawing pdata w = do viewFroms@(viewFromx,viewFromy) = _cameraViewFrom w pic = worldPictures w wallPoints = map fst wallPointsCol - -- set the coordinate uniforms ready for drawing elements with using world coordinates + -- set the coordinate uniforms ready for drawing elements using world coordinates setCommonUniforms pdata rot camzoom trans wins depthFunc $= Just Less pmat <- (newMatrix RowMajor $ perspectiveMatrix rot camzoom trans wins viewFroms) @@ -88,7 +88,22 @@ doDrawing pdata w = do -- render transparent walls -- the ordering between these and transparent clouds perhaps presents a challenge renderBlankWalls pdata windowPoints pmat + + setShaderUniforms rot (camzoom * (1/ 0.9)) trans wins + $ map extractProgAndUnis $ _pictureShaders pdata + depthFunc $= Just Lequal + _ <- renderFoldable pdata $ picToLTree (Just 0) (midgroundPics w) + + --depthMask $= Enabled + -- set the coordinate uniforms for the foreground + setShaderUniforms rot (camzoom * (1/ 0.8)) trans wins + $ map extractProgAndUnis $ _pictureShaders pdata + blendFunc $= (One,Zero) + depthFunc $= Just Always + _ <- renderFoldable pdata $ picToLTree (Just 0) (foregroundPics w) + depthMask $= Enabled + -- draw the fbo to the screen -- allows for post-processing -- first, bind the screen fbo @@ -107,6 +122,7 @@ doDrawing pdata w = do bindShaderBuffers [_grayscaleShader pdata] [4] drawShader (_grayscaleShader pdata) 4 blend $= Enabled + -- reset the coordinate uniforms for pictures that are drawn wrt to window -- coordinates resetShaderUniforms (map extractProgAndUnis $ _pictureShaders pdata) diff --git a/src/Dodge/Render/Picture.hs b/src/Dodge/Render/Picture.hs index 35add98cc..e97f1da39 100644 --- a/src/Dodge/Render/Picture.hs +++ b/src/Dodge/Render/Picture.hs @@ -28,6 +28,11 @@ worldPictures w = pictures $ concat , map drawWallFloor (wallFloorsToDraw w) , testPic w ] +midgroundPics :: World -> Picture +midgroundPics = pictures . _midgroundDecorations + +foregroundPics :: World -> Picture +foregroundPics = pictures . _foregroundDecorations fixedCoordPictures :: World -> Picture fixedCoordPictures w = case _menuLayers w of