From a730dd66e0638a0a5a0bf864f056bf99b05155dd Mon Sep 17 00:00:00 2001 From: jgk Date: Sat, 21 Aug 2021 11:32:50 +0200 Subject: [PATCH] Tweak bloom, remove pistol spread --- shader/texture/bloomBlur.frag | 43 +++++++++++---------------- src/Dodge/Item/Weapon.hs | 2 +- src/Dodge/Item/Weapon/Bezier.hs | 2 +- src/Dodge/Item/Weapon/Bullet.hs | 2 +- src/Dodge/Item/Weapon/Laser.hs | 15 ++++++---- src/Dodge/Particle/Bullet/Spawn.hs | 2 +- src/Dodge/Render.hs | 6 ++-- src/Dodge/WorldEvent/SpawnParticle.hs | 14 ++++----- src/Picture.hs | 5 ++++ 9 files changed, 46 insertions(+), 45 deletions(-) diff --git a/shader/texture/bloomBlur.frag b/shader/texture/bloomBlur.frag index a83b1cef3..f006a6a45 100644 --- a/shader/texture/bloomBlur.frag +++ b/shader/texture/bloomBlur.frag @@ -1,48 +1,41 @@ #version 430 core in vec2 vTexPos; out vec4 fColor; -const vec2 winSize = vec2 (300,300); +const vec2 winSize = vec2 (300.0,300.0); // note that the above opening bracket should be the first in this file // this is so that the window size can be extracted and the shader recompiled on // the fly uniform sampler2D screenTexture; - -const float hOff = 3.0 / winSize.x; -const float vOff = 3.0 / winSize.y; -const float frac = 1.0 / 9; -const vec2 off[9] = vec2[] +const float hOff = 3 / winSize.x; +const float vOff = 3 / winSize.y; +//const vec2 off[9] = vec2[] +// ( vec2( hOff, vOff ) +// , vec2( hOff, 0.0 ) +// , vec2( hOff,-vOff ) +// , vec2( 0.0, vOff ) +// , vec2( 0.0, 0.0 ) +// , vec2( 0.0,-hOff ) +// , vec2(-hOff, vOff ) +// , vec2(-hOff, 0.0 ) +// , vec2(-hOff,-vOff ) +// ); +const vec2 fiveOff[5] = vec2[] ( vec2( hOff, vOff ) - , vec2( hOff, 0.0 ) , vec2( hOff,-vOff ) - , vec2( 0.0, vOff ) , vec2( 0.0, 0.0 ) - , vec2( 0.0,-hOff ) , vec2(-hOff, vOff ) - , vec2(-hOff, 0.0 ) , vec2(-hOff,-vOff ) ); -const vec2 fiveOff[5] = vec2[] - ( vec2( vOff, hOff ) - , vec2( vOff,-hOff ) - , vec2( 0.0, 0.0 ) - , vec2(-vOff, hOff ) - , vec2(-vOff,-hOff ) - ); -vec4 combinef (vec4 ac, vec4 bc) -//{ return vec4 (max(ac.x,bc.x),max(ac.y,bc.y),max(ac.z,bc.z),ac.w + bc.w - -// ac.w*bc.w); -//{ return vec4 (max(ac.x,bc.x),max(ac.y,bc.y),max(ac.z,bc.z),ac.w + bc.w); -{ return vec4 (ac.rgb + bc.rgb * bc.a , ac.a + bc.a ); -} void main() { - vec4 sumFive = vec4 (0,0,0,0); + vec4 sumFive = vec4 (0.0,0.0,0.0,0.0); for (int i=0; i<5; i++) { sumFive += vec4(texture(screenTexture, vTexPos + fiveOff[i])); } + fColor = vec4 ( max( (sumFive / 10) , texture(screenTexture,vTexPos) ) ); //fColor = max(texture(screenTexture,vTexPos), sumFive / 5); - fColor = vec4 ( (sumFive / 5).rgb, max((sumFive/5).a,texture(screenTexture,vTexPos).a) ); + //fColor = vec4 ( (sumFive / 5).rgb, max((sumFive/5.0).a,texture(screenTexture,vTexPos).a) ); // vec4 sampleTex[9]; // for(int i=0; i<9; i++) // { diff --git a/src/Dodge/Item/Weapon.hs b/src/Dodge/Item/Weapon.hs index 042b5aa8b..270222f63 100644 --- a/src/Dodge/Item/Weapon.hs +++ b/src/Dodge/Item/Weapon.hs @@ -61,7 +61,7 @@ pistol = defaultGun , _itUseModifiers = [ hammerCheckI , shootWithSoundI 0 - , withRandomDirI 0.1 +-- , withRandomDirI 0.1 , withMuzFlareI ] , _itLeftClickUse = Nothing diff --git a/src/Dodge/Item/Weapon/Bezier.hs b/src/Dodge/Item/Weapon/Bezier.hs index f78dc4846..be1a9729d 100644 --- a/src/Dodge/Item/Weapon/Bezier.hs +++ b/src/Dodge/Item/Weapon/Bezier.hs @@ -50,7 +50,7 @@ shootBezier targetp cr w = w & particles %~ (theBullet :) where theBullet = aCurveBulAt (Just cid) - white + (V4 200 200 200 1) startp (controlp +.+ randPos) (targetp +.+ randPos') diff --git a/src/Dodge/Item/Weapon/Bullet.hs b/src/Dodge/Item/Weapon/Bullet.hs index 08725473d..d9058ac60 100644 --- a/src/Dodge/Item/Weapon/Bullet.hs +++ b/src/Dodge/Item/Weapon/Bullet.hs @@ -10,7 +10,7 @@ basicBullet = BulletAmmo { _amString = "BULLET" , _amBulEff = destroyOnImpact bulHitCr bulHitWall' bulHitFF' , _amBulWth = 2 - , _amBulVel = V2 30 0 + , _amBulVel = V2 50 0 } hvBullet :: Ammo hvBullet = BulletAmmo diff --git a/src/Dodge/Item/Weapon/Laser.hs b/src/Dodge/Item/Weapon/Laser.hs index 2204186c4..0728baaed 100644 --- a/src/Dodge/Item/Weapon/Laser.hs +++ b/src/Dodge/Item/Weapon/Laser.hs @@ -62,7 +62,6 @@ moveLaser phaseV pos dir w pt xp = pos +.+ 800 *.* unitVectorAtAngle dir (a,g) = randomR (-0.7,0.7) $ _randGen w reflectDir wall = a + argV (reflectIn (uncurry (-.-) (_wlLine wall)) (xp -.- pos)) - (colID,_) = randomR (0,11) $ _randGen w f :: [Wall] -> Point2 -> Point2 -> (Maybe (Point2,Either3 Creature Wall ForceField),[Point2]) f seenWs x y = case find (h' seenWs) $ thingsHitExceptCrLongLine Nothing x y w of Just (p,E3x2 wl) @@ -103,14 +102,18 @@ moveLaser phaseV pos dir w pt Just (p,E3x1 cr) -> over (creatures . ix (_crID cr) . crState . crDamage) ((:) $ Lasering 19 pos p xp) -- . over worldEvents ((.) $ flareAt yellow (flarePos p)) - Just (p,E3x2 wl) -> createSpark 8 colID (p +.+ safeNormalizeV (pos -.- p)) + Just (p,E3x2 wl) -> createSparkCol 8 (V4 20 (-5) 0 1) (p +.+ safeNormalizeV (pos -.- p)) (reflectDir wl) Nothing _ -> id - pic = setDepth 20 $ pictures - [ fadeLine pos (head ps) 0.2 40 yellow - , setLayer 1 $ color (withAlpha 0.9 white) $ vThickLine (pos:ps) - , setLayer 1 $ color (withAlpha 0.5 yellow) $ vvThickLine (pos:ps) + pic = setLayer 1 $ pictures + [ setDepth 19 . color (brightX 0 0.5 yellow) $ lineOfThickness 20 (pos:ps) + , setDepth 19.5 . color (brightX 10 1 yellow) $ lineOfThickness 3 (pos:ps) ] + -- $ pictures + --[ fadeLine pos (head ps) 0.2 40 yellow + --, setLayer 1 $ color (withAlpha 0.9 white) $ vThickLine (pos:ps) + --, setLayer 1 $ color (withAlpha 0.5 yellow) $ vvThickLine (pos:ps) + --] fadeLine :: Point2 -> Point2 -> Float -> Float -> Color -> Picture fadeLine sp ep alph width col = setLayer 1 $ polygonCol diff --git a/src/Dodge/Particle/Bullet/Spawn.hs b/src/Dodge/Particle/Bullet/Spawn.hs index 40a83a375..7f3ec1b4c 100644 --- a/src/Dodge/Particle/Bullet/Spawn.hs +++ b/src/Dodge/Particle/Bullet/Spawn.hs @@ -19,7 +19,7 @@ aGenBulAt maycid pos vel hiteff width = Bul' { _ptDraw = drawBul , _ptUpdate' = mvGenBullet , _btVel' = vel - , _btColor' = V4 100 100 50 1.5 + , _btColor' = V4 2 2 2 2 , _btTrail' = [pos] , _btPassThrough' = maycid , _btWidth' = width diff --git a/src/Dodge/Render.hs b/src/Dodge/Render.hs index aebc93e68..0c0c900d6 100644 --- a/src/Dodge/Render.hs +++ b/src/Dodge/Render.hs @@ -112,7 +112,7 @@ doDrawing pdata w = do textureBinding Texture2D $= Just (snd $ _fboBloom pdata) blend $= Disabled drawShader (_bloomBlurShader pdata) 4 - replicateM_ 2 $ pingPongBetween (_fboFourth1 pdata) (_fboFourth2 pdata) (_bloomBlurShader pdata) + replicateM_ 5 $ pingPongBetween (_fboFourth1 pdata) (_fboFourth2 pdata) (_bloomBlurShader pdata) blend $= Enabled viewport $= (Position 0 0 , divideSize (w ^. config . shadow_resolution) $ Size (round $ fstV2 wins) (round $ sndV2 wins)) @@ -142,8 +142,8 @@ doDrawing pdata w = do textureBinding Texture2D $= Just (snd $ _fboFourth1 pdata) drawShader (_fullscreenShader pdata) 4 blendFunc $= (SrcAlpha, OneMinusSrcAlpha) - textureBinding Texture2D $= Just (snd $ _fboBloom pdata) - drawShader (_fullscreenShader pdata) 4 +-- textureBinding Texture2D $= Just (snd $ _fboBloom pdata) +-- drawShader (_fullscreenShader pdata) 4 depthFunc $= Just Lequal --mapM_ (uncurry $ drawShaderLay 2) (vnums IM.! 2) diff --git a/src/Dodge/WorldEvent/SpawnParticle.hs b/src/Dodge/WorldEvent/SpawnParticle.hs index 30bc24ad8..692d49aaf 100644 --- a/src/Dodge/WorldEvent/SpawnParticle.hs +++ b/src/Dodge/WorldEvent/SpawnParticle.hs @@ -303,10 +303,10 @@ drawTeslaArc pt = pic where ps' = _ptPoints pt pic = setLayer 1 $ pictures - [ setDepth 20.5 $ color (_ptColor pt) $ line ps' - , setDepth 20 $ color (withAlpha 0.02 cyan) $ lineOfThickness 20 ps' - , setDepth 20 $ color (withAlpha 0.02 cyan) $ lineOfThickness 25 ps' - , setDepth 20 $ color (withAlpha 0.02 cyan) $ lineOfThickness 30 ps' + [ setDepth 20.5 $ color (brightX 2 2 $ _ptColor pt) $ lineOfThickness 3 ps' +-- , setDepth 20 $ color (withAlpha 0.02 cyan) $ lineOfThickness 20 ps' +-- , setDepth 20 $ color (withAlpha 0.02 cyan) $ lineOfThickness 25 ps' +-- , setDepth 20 $ color (withAlpha 0.02 cyan) $ lineOfThickness 30 ps' ] -- todo: fix electrical damage location moveTeslaArc @@ -326,13 +326,13 @@ moveTeslaArc p d w pt | otherwise = (w , Just $ pt & ptTimer -~ 1) where t = _ptTimer pt - ps = take 15 $ p : map f (crsLightChain p d 0 w) + ps = take 25 $ p : map f (crsLightChain p d 0 w) f (E3x1 cr) = _crPos cr f (E3x2 p1) = p1 f (E3x3 p1) = p1 ps' = lightningMids d pers ps pers = evalState (sequence $ repeat $ randInCirc 5) $ _randGen w - (nc,g) = randomR (0::Int,11) $ _randGen w + (nc,g) = randomR (0::Int,5) $ _randGen w theColor = f2 nc f2 0 = cyan f2 1 = azure @@ -452,7 +452,7 @@ createSpark time colid pos dir maycid w { _ptDraw = drawBul , _ptUpdate' = mvGenBullet , _btVel' = rotateV dir (V2 5 0) - , _btColor' = numColor colid + , _btColor' = brightX 100 1.5 $ numColor colid , _btTrail' = [pos] , _btPassThrough' = maycid , _btWidth' = 1 diff --git a/src/Picture.hs b/src/Picture.hs index 84b034af1..cf320450a 100644 --- a/src/Picture.hs +++ b/src/Picture.hs @@ -50,6 +50,7 @@ module Picture , light , dark , bright + , brightX , mixColors , zeroZ , setDepth @@ -381,6 +382,10 @@ dim :: Color -> Color {-# INLINE dim #-} dim (V4 r g b a) = V4 (r/1.2) (g/1.2) (b/1.2) a +brightX :: Float -> Float -> Color -> Color +{-# INLINE brightX #-} +brightX cm am (V4 r g b a) = V4 (r*cm) (g*cm) (b*cm) (a*am) + bright :: Color -> Color {-# INLINE bright #-} bright (V4 r g b a) = V4 (r*1.2) (g*1.2) (b*1.2) a