diff --git a/shader/pull/window.frag b/shader/pull/window.frag index 83cb12cf2..41a9e5ff7 100644 --- a/shader/pull/window.frag +++ b/shader/pull/window.frag @@ -1,11 +1,14 @@ #version 450 core -layout (location=0) out vec4 fCol; -layout (location=1) out vec4 fPos; +layout (location=0) out vec4 fColOverCloud; +layout (location=1) out vec4 fColUnderCloud; layout(binding = 3) uniform sampler2D cloudpos; in vec4 vCol; in vec4 vPos; +in vec2 vScreenPos; void main() { - fCol = vCol; - fPos = vPos; + float cloudz = texture(cloudpos, vScreenPos).z; + fColOverCloud = ( cloudz > vPos.z ? vec4(0) : vCol); + fColUnderCloud = ( cloudz > vPos.z ? vCol : vec4(0)); + fColUnderCloud = vec4(0); } diff --git a/shader/pull/window.vert b/shader/pull/window.vert index cc3dc284e..1ad2a79e0 100644 --- a/shader/pull/window.vert +++ b/shader/pull/window.vert @@ -4,14 +4,22 @@ layout (std140, binding = 0) uniform TheMat { mat4 theMat; } ; layout (std430, binding = 1) readonly buffer Pos { PosCol data[]; }; out vec4 vCol; out vec4 vPos; -int indices[6] = {0,1,3,0,3,2}; +out vec2 vScreenPos; +//int indices[6] = {0,1,3,0,3,2}; +int indices[6] = + {0,3,1 + ,0,2,3}; +// note reversed compared to walls void main() { vCol = data[gl_VertexID / 6].col; vec4 pp = data[gl_VertexID / 6].pospos; int j = indices[gl_VertexID % 6]; - float z = (j > 1.5 ? 5000 : 0); + //float z = (j > 1.5 ? 5000 : 0); + float z = (j > 1.5 ? 200 : 0); vec2 xy = (j % 2 > 0 ? pp.xy : pp.zw); vPos = vec4( xy, z, 1); gl_Position = theMat * vPos; + vScreenPos = 0.5 * (vec2(1) + vec2(gl_Position.x / gl_Position.w + ,gl_Position.y / gl_Position.w)); } diff --git a/src/Dodge/Bullet.hs b/src/Dodge/Bullet.hs index c512176b5..14b205adf 100644 --- a/src/Dodge/Bullet.hs +++ b/src/Dodge/Bullet.hs @@ -138,7 +138,7 @@ makeFragBullets p w = w & cWorld . lWorld . bullets .++~ bus f a s = defaultBullet & buPayload .~ BulPlain 5 - & buVel .~ s *.* unitVectorAtAngle a + & buVel .~ s *^ unitVectorAtAngle a & buDrag .~ 0.8 & buPos .~ p & buOldPos .~ p @@ -151,20 +151,10 @@ makeFlak bu _ w = w & cWorld . lWorld . bullets .++~ [f x | x <- xs] f x = bu & buVel %~ g x & buPayload .~ BulPlain 25 - g x v = v +.+ x *.* normalizeV (vNormal v) + g x v = v + x *^ normalizeV (vNormal v) hitEffFromBul :: World -> Bullet -> (World, Bullet) -hitEffFromBul w bu = hitEffFromBul' w' bu - where - w' = w & cWorld . lWorld . distortions .:~ x - x = RadialDistortion (_buPos bu + _buVel bu) (V2 50 0) (V2 0 50) - (v3 & _3 .~ t) (v3 & _3 .~ negate t) v3 1 - v3 = V3 (V2 1 0) (V2 0 1) 0 - t = vNormal (_buVel bu) --- (V2 1 0) (V2 - -hitEffFromBul' :: World -> Bullet -> (World, Bullet) -hitEffFromBul' w bu = case _buEffect bu of +hitEffFromBul w bu = case _buEffect bu of PenetrateBullet -> movePenBullet bu hitstream w BounceBullet -> fromMaybe (expireAndDamage bu hitstream w) $ do (hp, crwl) <- hitstream ^? _head diff --git a/src/Dodge/Material/Color.hs b/src/Dodge/Material/Color.hs index 2d1ac2e1d..1a651b3a2 100644 --- a/src/Dodge/Material/Color.hs +++ b/src/Dodge/Material/Color.hs @@ -6,8 +6,7 @@ import Dodge.Data.Material import Color materialColor :: Material -> Color -materialColor = - withAlpha 0.5 . \case +materialColor = \case Wood -> dark yellow Dirt -> dark $ dark orange Stone -> greyN 0.5 diff --git a/src/Dodge/Render.hs b/src/Dodge/Render.hs index af4263f9c..840dbac8f 100644 --- a/src/Dodge/Render.hs +++ b/src/Dodge/Render.hs @@ -308,7 +308,9 @@ doDrawing' win pdata u = do glDepthFunc GL_LEQUAL glDepthMask GL_FALSE glEnable GL_BLEND - glBlendFunc GL_SRC_ALPHA GL_ONE + --glBlendFunc GL_SRC_ALPHA GL_ONE + glBindTextureUnit 3 (pdata ^. fboPos . _2 . unTO) + glBlendFunc GL_ONE_MINUS_DST_ALPHA GL_ONE_MINUS_SRC_ALPHA glUseProgram $ pdata ^. windowPullShader glBindVertexArray $ pdata ^. dummyVAO glDrawArrays GL_TRIANGLES 0 (fromIntegral nWins * 6) @@ -327,22 +329,26 @@ doDrawing' win pdata u = do glUseProgram (pdata ^. fullscreenShader) glDrawArrays GL_TRIANGLES 0 6 glBlendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA - -- bind base buffer for drawing clouds and bloom - -- glBindFramebuffer GL_FRAMEBUFFER (pdata ^. fboBase . _1 . unFBO) - - glBlendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA - -- --draw windows onto base buffer - glBlendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA - glBindTextureUnit 0 (pdata ^. fboWindow . _2 . _1 . unTO) - glBindTextureUnit 1 (pdata ^. fboWindow . _2 . _2 . unTO) - glBindTextureUnit 2 (pdata ^. fboCloud . _2 . _1 . unTO) - glBindTextureUnit 3 (pdata ^. fboPos . _2 . unTO) - - --drawShader (_transparencyCompShader pdata) 4 - glUseProgram (pdata ^. transparencyCompShader) + glUseProgram (pdata ^. fullscreenShader) + glBindTextureUnit 0 (pdata ^. fboWindow . _2 . _2 . unTO) glDrawArrays GL_TRIANGLES 0 6 + glBindTextureUnit 0 (pdata ^. fboCloud . _2 . _1 . unTO) + glDrawArrays GL_TRIANGLES 0 6 + glBindTextureUnit 0 (pdata ^. fboWindow . _2 . _1 . unTO) + glDrawArrays GL_TRIANGLES 0 6 + +-- -- --draw windows onto base buffer +-- glBlendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA +-- glBindTextureUnit 0 (pdata ^. fboWindow . _2 . _1 . unTO) +-- glBindTextureUnit 1 (pdata ^. fboWindow . _2 . _2 . unTO) +-- glBindTextureUnit 2 (pdata ^. fboCloud . _2 . _1 . unTO) +-- glBindTextureUnit 3 (pdata ^. fboPos . _2 . unTO) +-- +-- --drawShader (_transparencyCompShader pdata) 4 +-- glUseProgram (pdata ^. transparencyCompShader) +-- glDrawArrays GL_TRIANGLES 0 6 --Draw blurred bloom onto base buffer glEnable GL_BLEND diff --git a/src/Dodge/Render/Walls.hs b/src/Dodge/Render/Walls.hs index 634bbec0a..31cfcab50 100644 --- a/src/Dodge/Render/Walls.hs +++ b/src/Dodge/Render/Walls.hs @@ -1,5 +1,6 @@ module Dodge.Render.Walls (wallsToDraw) where +import Color.Data import qualified Control.Foldl as L import Control.Lens import Dodge.Base.Wall @@ -11,6 +12,7 @@ import Dodge.Wall.Draw --import Dodge.Zoning.World import Geometry import ShapePicture +import Linear -- not necessary: should just poke all walls to their wanted places wallsToDraw :: World -> ([((Point2, Point2), Point4)], SPic, [Wall]) @@ -25,7 +27,11 @@ wallsToDraw w = where -- (wlsFromIXs w $ zonesExtract (w ^. wlZoning) $ zoneOfSight wlZoneSize cam) - f wl = (_wlLine wl, materialColor $ _wlMaterial wl) + f wl = (_wlLine wl, setWindowColor $ materialColor $ _wlMaterial wl) + +setWindowColor :: Color -> Color +setWindowColor c = c & _w .~ 0.25 +--setWindowColor (V4 r g b _) = V4 (r*0.5) (g*0.5) (b*0.5) 0.8 -- cam = w ^. cWorld . camPos diff --git a/src/Dodge/Wall/Draw.hs b/src/Dodge/Wall/Draw.hs index 4bb7ba52b..8f14dda28 100644 --- a/src/Dodge/Wall/Draw.hs +++ b/src/Dodge/Wall/Draw.hs @@ -17,7 +17,7 @@ drawForceField wl = noShape . setLayer BloomLayer . setDepth 20 - . color (materialColor (wl ^. wlMaterial)) + . color (withAlpha 0.5 $ materialColor (wl ^. wlMaterial)) $ thickLine 5 [a, b] where (a, b) = _wlLine wl