Work on transparency of windows/clouds
This commit is contained in:
@@ -1,11 +1,14 @@
|
|||||||
#version 450 core
|
#version 450 core
|
||||||
layout (location=0) out vec4 fCol;
|
layout (location=0) out vec4 fColOverCloud;
|
||||||
layout (location=1) out vec4 fPos;
|
layout (location=1) out vec4 fColUnderCloud;
|
||||||
layout(binding = 3) uniform sampler2D cloudpos;
|
layout(binding = 3) uniform sampler2D cloudpos;
|
||||||
in vec4 vCol;
|
in vec4 vCol;
|
||||||
in vec4 vPos;
|
in vec4 vPos;
|
||||||
|
in vec2 vScreenPos;
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
fCol = vCol;
|
float cloudz = texture(cloudpos, vScreenPos).z;
|
||||||
fPos = vPos;
|
fColOverCloud = ( cloudz > vPos.z ? vec4(0) : vCol);
|
||||||
|
fColUnderCloud = ( cloudz > vPos.z ? vCol : vec4(0));
|
||||||
|
fColUnderCloud = vec4(0);
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-2
@@ -4,14 +4,22 @@ layout (std140, binding = 0) uniform TheMat { mat4 theMat; } ;
|
|||||||
layout (std430, binding = 1) readonly buffer Pos { PosCol data[]; };
|
layout (std430, binding = 1) readonly buffer Pos { PosCol data[]; };
|
||||||
out vec4 vCol;
|
out vec4 vCol;
|
||||||
out vec4 vPos;
|
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()
|
void main()
|
||||||
{
|
{
|
||||||
vCol = data[gl_VertexID / 6].col;
|
vCol = data[gl_VertexID / 6].col;
|
||||||
vec4 pp = data[gl_VertexID / 6].pospos;
|
vec4 pp = data[gl_VertexID / 6].pospos;
|
||||||
int j = indices[gl_VertexID % 6];
|
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);
|
vec2 xy = (j % 2 > 0 ? pp.xy : pp.zw);
|
||||||
vPos = vec4( xy, z, 1);
|
vPos = vec4( xy, z, 1);
|
||||||
gl_Position = theMat * vPos;
|
gl_Position = theMat * vPos;
|
||||||
|
vScreenPos = 0.5 * (vec2(1) + vec2(gl_Position.x / gl_Position.w
|
||||||
|
,gl_Position.y / gl_Position.w));
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-13
@@ -138,7 +138,7 @@ makeFragBullets p w = w & cWorld . lWorld . bullets .++~ bus
|
|||||||
f a s =
|
f a s =
|
||||||
defaultBullet
|
defaultBullet
|
||||||
& buPayload .~ BulPlain 5
|
& buPayload .~ BulPlain 5
|
||||||
& buVel .~ s *.* unitVectorAtAngle a
|
& buVel .~ s *^ unitVectorAtAngle a
|
||||||
& buDrag .~ 0.8
|
& buDrag .~ 0.8
|
||||||
& buPos .~ p
|
& buPos .~ p
|
||||||
& buOldPos .~ p
|
& buOldPos .~ p
|
||||||
@@ -151,20 +151,10 @@ makeFlak bu _ w = w & cWorld . lWorld . bullets .++~ [f x | x <- xs]
|
|||||||
f x =
|
f x =
|
||||||
bu & buVel %~ g x
|
bu & buVel %~ g x
|
||||||
& buPayload .~ BulPlain 25
|
& 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 :: World -> Bullet -> (World, Bullet)
|
||||||
hitEffFromBul w bu = hitEffFromBul' w' bu
|
hitEffFromBul w bu = case _buEffect bu of
|
||||||
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
|
|
||||||
PenetrateBullet -> movePenBullet bu hitstream w
|
PenetrateBullet -> movePenBullet bu hitstream w
|
||||||
BounceBullet -> fromMaybe (expireAndDamage bu hitstream w) $ do
|
BounceBullet -> fromMaybe (expireAndDamage bu hitstream w) $ do
|
||||||
(hp, crwl) <- hitstream ^? _head
|
(hp, crwl) <- hitstream ^? _head
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import Dodge.Data.Material
|
|||||||
import Color
|
import Color
|
||||||
|
|
||||||
materialColor :: Material -> Color
|
materialColor :: Material -> Color
|
||||||
materialColor =
|
materialColor = \case
|
||||||
withAlpha 0.5 . \case
|
|
||||||
Wood -> dark yellow
|
Wood -> dark yellow
|
||||||
Dirt -> dark $ dark orange
|
Dirt -> dark $ dark orange
|
||||||
Stone -> greyN 0.5
|
Stone -> greyN 0.5
|
||||||
|
|||||||
+20
-14
@@ -308,7 +308,9 @@ doDrawing' win pdata u = do
|
|||||||
glDepthFunc GL_LEQUAL
|
glDepthFunc GL_LEQUAL
|
||||||
glDepthMask GL_FALSE
|
glDepthMask GL_FALSE
|
||||||
glEnable GL_BLEND
|
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
|
glUseProgram $ pdata ^. windowPullShader
|
||||||
glBindVertexArray $ pdata ^. dummyVAO
|
glBindVertexArray $ pdata ^. dummyVAO
|
||||||
glDrawArrays GL_TRIANGLES 0 (fromIntegral nWins * 6)
|
glDrawArrays GL_TRIANGLES 0 (fromIntegral nWins * 6)
|
||||||
@@ -327,22 +329,26 @@ doDrawing' win pdata u = do
|
|||||||
glUseProgram (pdata ^. fullscreenShader)
|
glUseProgram (pdata ^. fullscreenShader)
|
||||||
glDrawArrays GL_TRIANGLES 0 6
|
glDrawArrays GL_TRIANGLES 0 6
|
||||||
glBlendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
|
glBlendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
|
||||||
|
|
||||||
-- bind base buffer for drawing clouds and bloom
|
-- bind base buffer for drawing clouds and bloom
|
||||||
--
|
|
||||||
glBindFramebuffer GL_FRAMEBUFFER (pdata ^. fboBase . _1 . unFBO)
|
glBindFramebuffer GL_FRAMEBUFFER (pdata ^. fboBase . _1 . unFBO)
|
||||||
|
glUseProgram (pdata ^. fullscreenShader)
|
||||||
glBlendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
|
glBindTextureUnit 0 (pdata ^. fboWindow . _2 . _2 . unTO)
|
||||||
-- --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
|
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
|
--Draw blurred bloom onto base buffer
|
||||||
glEnable GL_BLEND
|
glEnable GL_BLEND
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
module Dodge.Render.Walls (wallsToDraw) where
|
module Dodge.Render.Walls (wallsToDraw) where
|
||||||
|
|
||||||
|
import Color.Data
|
||||||
import qualified Control.Foldl as L
|
import qualified Control.Foldl as L
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
import Dodge.Base.Wall
|
import Dodge.Base.Wall
|
||||||
@@ -11,6 +12,7 @@ import Dodge.Wall.Draw
|
|||||||
--import Dodge.Zoning.World
|
--import Dodge.Zoning.World
|
||||||
import Geometry
|
import Geometry
|
||||||
import ShapePicture
|
import ShapePicture
|
||||||
|
import Linear
|
||||||
|
|
||||||
-- not necessary: should just poke all walls to their wanted places
|
-- not necessary: should just poke all walls to their wanted places
|
||||||
wallsToDraw :: World -> ([((Point2, Point2), Point4)], SPic, [Wall])
|
wallsToDraw :: World -> ([((Point2, Point2), Point4)], SPic, [Wall])
|
||||||
@@ -25,7 +27,11 @@ wallsToDraw w =
|
|||||||
where
|
where
|
||||||
-- (wlsFromIXs w $ zonesExtract (w ^. wlZoning) $ zoneOfSight wlZoneSize cam)
|
-- (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
|
-- cam = w ^. cWorld . camPos
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ drawForceField wl =
|
|||||||
noShape
|
noShape
|
||||||
. setLayer BloomLayer
|
. setLayer BloomLayer
|
||||||
. setDepth 20
|
. setDepth 20
|
||||||
. color (materialColor (wl ^. wlMaterial))
|
. color (withAlpha 0.5 $ materialColor (wl ^. wlMaterial))
|
||||||
$ thickLine 5 [a, b]
|
$ thickLine 5 [a, b]
|
||||||
where
|
where
|
||||||
(a, b) = _wlLine wl
|
(a, b) = _wlLine wl
|
||||||
|
|||||||
Reference in New Issue
Block a user