Cleanup, start to add creature silhouettes

This commit is contained in:
2021-09-02 11:06:04 +01:00
parent 02193add68
commit 9d2f42dbc9
16 changed files with 142 additions and 94 deletions
+2
View File
@@ -26,6 +26,7 @@ import Dodge.Creature.SpreadGunCrit
import Dodge.Creature.AutoCrit
import Dodge.Creature.ChaseCrit
import Dodge.Creature.ArmourChase
import Dodge.Creature.Silhouette
import Dodge.Data
import Dodge.Default
import Dodge.Item.Weapon
@@ -146,6 +147,7 @@ startCr = defaultCreature
, _crMvDir = pi/2
, _crID = 0
, _crPict = basicCrPict black
, _crSilhouette = basicCrSilhouette
, _crUpdate = stateUpdate yourControl
, _crRad = 10
, _crMass = 10
+4 -4
View File
@@ -6,9 +6,9 @@ import Geometry
import qualified Data.IntMap as IM
crToBox :: Creature -> [[Point3]]
crToBox cr = map (map f . polyToTris) $ boxXYZ 10 10 15
crToBox cr = map (map f . polyToTris) $ boxXYZ 8 8 15
where
f = (+ V3 (x-5) (y-5) 1)
f = (+ V3 (x-4) (y-4) 1)
V2 x y = _crPos cr
youBox' :: World -> [[Point3]]
youBox' w = crToBox' $ _creatures w IM.! 0
@@ -17,9 +17,9 @@ youBox :: World -> [Point3]
youBox = concat . youBox'
crToBox' :: Creature -> [[Point3]]
crToBox' cr = map (map f . polyToTris) $ boxXYZ 20 20 15
crToBox' cr = map (map f . polyToTris) $ boxXYZ 12 12 15
where
f = (+ V3 (x-10) (y-10) 1)
f = (+ V3 (x-6) (y-6) 0)
V2 x y = _crPos cr
youSil :: World -> [Point3]
+26
View File
@@ -0,0 +1,26 @@
module Dodge.Creature.Silhouette
( creatureSilhouettes
, basicCrSilhouette
)
where
import Dodge.Data
import Polyhedra
import Geometry
import qualified Data.IntMap as IM
creatureSilhouettes :: World -> [Point3]
creatureSilhouettes w = concatMap f . IM.elems $ _creatures w
where
f cr = _crSilhouette cr cr
crBox :: [Point3]
crBox = constructEdgesList . map (map f . polyToTris) $ boxXYZ 12 12 15
where
f = (+ V3 (-6) (-6) 0)
basicCrSilhouette :: Creature -> [Point3]
basicCrSilhouette cr = map theTrans crBox
where
theTrans = (+ V3 x y 0)
V2 x y = _crPos cr
+1
View File
@@ -161,6 +161,7 @@ data Creature = Creature
, _crMvDir :: Float
, _crID :: Int
, _crPict :: Creature -> World -> Picture
, _crSilhouette :: Creature -> [Point3]
, _crUpdate
:: Creature
-> World
+1
View File
@@ -31,6 +31,7 @@ defaultCreature = Creature
, _crMvDir = 0
, _crID = 1
, _crPict = \_ _ -> setLayer 0 $ onLayer CrLayer $ circleSolid 10
, _crSilhouette = const []
, _crUpdate = \cr _ -> (Endo id , Just cr)
, _crRad = 10
, _crMass = 10
+22 -10
View File
@@ -8,7 +8,8 @@ import Dodge.Data
import Dodge.Config.Data
import Dodge.Base.Window
import Dodge.Render.Picture
--import Dodge.Creature.ShadowBox
import Dodge.Creature.ShadowBox
import Dodge.Creature.Silhouette
import Geometry
import Render
import Data.Preload.Render
@@ -55,7 +56,8 @@ doDrawing pdata w = do
nWalls <- poke224s (shadVBOptr $ _wallTextureShader pdata) wallPointsCol
nSils <- pokePoint3s (shadVBOptr $ _lightingLineShadowShader pdata)
$
--youSil w ++
--youSil w ++
creatureSilhouettes w ++
_foregroundEdgeVerx w
-- poke foreground geometry for caps
nCaps <- pokePoint3s (shadVBOptr $ _lightingCapShader pdata)
@@ -75,9 +77,8 @@ doDrawing pdata w = do
clear [ColorBuffer,DepthBuffer]
depthFunc $= Just Less
-- draw wall occlusions from the camera's point of view
currentProgram $= Just (_shaderProgram $ _lightingOccludeShader pdata)
uniform (head $ _shaderCustomUnis $ _lightingOccludeShader pdata)
$= viewFrom3d
currentProgram $= Just (_shadProg $ _lightingOccludeShader pdata)
uniform (head $ _shadUnis $ _lightingOccludeShader pdata) $= viewFrom3d
drawShader (_lightingOccludeShader pdata) nWalls
--draw walls onto base buffer
if w ^. config . wall_textured
@@ -118,12 +119,12 @@ doDrawing pdata w = do
--setup downscale viewport for blurring bloom
viewport $= (Position 0 0
, divideSize (2 * (w ^. config . shadow_resolution)) $ Size (round $ fstV2 wins) (round $ sndV2 wins))
bindFramebuffer Framebuffer $= fst (_fboFourth1 pdata)
bindFramebuffer Framebuffer $= fst (_fboHalf1 pdata)
depthFunc $= Just Always
textureBinding Texture2D $= Just (snd $ _fboBloom pdata)
blend $= Disabled
drawShader (_bloomBlurShader pdata) 4
replicateM_ 5 $ pingPongBetween (_fboFourth1 pdata) (_fboFourth2 pdata) (_bloomBlurShader pdata)
replicateM_ 5 $ pingPongBetween (_fboHalf1 pdata) (_fboHalf2 pdata) (_bloomBlurShader pdata)
blend $= Enabled
viewport $= (Position 0 0
, divideSize (w ^. config . shadow_resolution) $ Size (round $ fstV2 wins) (round $ sndV2 wins))
@@ -144,11 +145,21 @@ doDrawing pdata w = do
drawBuffers $= [NoBuffers,FBOColorAttachment 1]
renderLayer 2 shadV layerCounts
renderWindows pdata windowPoints
-- --downscale transparency depths
-- viewport $= (Position 0 0
-- , divideSize (2 * (w ^. config . shadow_resolution)) $ Size (round $ fstV2 wins) (round $ sndV2 wins))
-- bindFramebuffer Framebuffer $= fst (_fboHalf3 pdata)
-- bindTO (snd $ snd $ _fboCloud pdata)
-- depthFunc $= Just Always
-- drawShader (_fullscreenShader pdata) 4
-- viewport $= (Position 0 0
-- , divideSize (w ^. config . shadow_resolution) $ Size (round $ fstV2 wins) (round $ sndV2 wins))
----draw lightmap for cloud buffer
depthMask $= Disabled
blend $= Enabled
----draw lightmap for cloud buffer
bindFramebuffer Framebuffer $= fst (_fboLighting pdata)
createLightMap pdata lightPoints nWalls nSils nCaps (snd $ snd $ _fboCloud pdata)
-- createLightMap pdata lightPoints nWalls nSils nCaps (snd $ _fboHalf3 pdata)
colorMask $= Color4 Enabled Enabled Enabled Enabled
clearColor $= Color4 0 0 0 0
--apply lightmap to cloud buffer
@@ -167,7 +178,7 @@ doDrawing pdata w = do
bindFramebuffer Framebuffer $= fst (_fboBase pdata)
blend $= Enabled
blendFunc $= (SrcAlpha, One)
textureBinding Texture2D $= Just (snd $ _fboFourth1 pdata)
textureBinding Texture2D $= Just (snd $ _fboHalf1 pdata)
drawShader (_fullscreenShader pdata) 4
blendFunc $= (SrcAlpha, OneMinusSrcAlpha)
--draw shadowed clouds onto base buffer
@@ -233,7 +244,7 @@ renderWindows
renderWindows pdata wps = do
n <- poke224s (shadVBOptr $ _windowShader pdata) wps
bindShaderBuffers [_windowShader pdata] [n]
currentProgram $= Just (_shaderProgram $ _windowShader pdata)
currentProgram $= Just (_shadProg $ _windowShader pdata)
--cullFace $= Just Back
drawShader (_windowShader pdata) n
--cullFace $= Nothing
@@ -246,3 +257,4 @@ renderTextureWalls pdata nWalls = do
cullFace $= Just Back
drawShader (_wallTextureShader pdata) nWalls
cullFace $= Nothing