Allow shadow fidelity option, fix bug in rendering box shadows

This commit is contained in:
2023-03-25 17:22:58 +00:00
parent cdc4a84d4b
commit d989acd6f2
26 changed files with 410 additions and 258 deletions
+52 -57
View File
@@ -38,10 +38,10 @@ equipItemSPic et _ = case et of
]
)
WRISTARMOUR -> defSPic
INVISIBILITYEQUIPMENT _ -> noPic (colorSH chartreuse $ upperPrismPoly 3 $ rectWH 2 2)
BRAINHAT -> noPic (colorSH yellow $ upperPrismPoly 3 $ rectWH 4 4)
HAT -> noPic (colorSH yellow $ upperPrismPoly 3 $ rectWH 4 4)
TARGETINGHAT _ -> noPic (colorSH yellow $ upperPrismPoly 3 $ rectWH 4 4)
INVISIBILITYEQUIPMENT _ -> noPic (colorSH chartreuse $ upperPrismPolySI 3 $ rectWH 2 2)
BRAINHAT -> noPic (colorSH yellow $ upperPrismPolySU 3 $ rectWH 4 4)
HAT -> noPic (colorSH yellow $ upperPrismPolySU 3 $ rectWH 4 4)
TARGETINGHAT _ -> noPic (colorSH yellow $ upperPrismPolySU 3 $ rectWH 4 4)
HEADLAMP -> noPic headLampShape
POWERLEGS -> legsSPic yellow
SPEEDLEGS -> legsSPic green
@@ -49,11 +49,11 @@ equipItemSPic et _ = case et of
JETPACK -> noPic $ colorSH yellow backpackShape
BATTERYPACK -> noPic $ colorSH blue backpackShape
FUELPACK ->
noPic $ colorSH yellow $ upperPrismPoly 10 $ polyCirc 3 5
AUTODETECTOR dt -> noPic (colorSH (detectorColor dt) $ upperPrismPoly 3 $ rectWH 2 2)
noPic $ colorSH yellow $ upperPrismPolyMT 10 $ polyCirc 3 5
AUTODETECTOR dt -> noPic (colorSH (detectorColor dt) $ upperPrismPolySU 3 $ rectWH 2 2)
backpackShape :: Shape
backpackShape = upperPrismPoly 10 $ rectNSWE 5 (-5) (-4) 4
backpackShape = upperPrismPolyMT 10 $ rectNSWE 5 (-5) (-4) 4
leftItemSPic :: LeftItemType -> Item -> SPic
leftItemSPic lt _ = case lt of
@@ -184,7 +184,7 @@ heldItemSPic ht it = case ht of
POISONSPRAYER -> flamerPic it
DRONELAUNCHER -> defSPic
SHATTERGUN -> shatterGunSPic
HELDDETECTOR dt -> noPic (colorSH (detectorColor dt) $ upperPrismPoly 3 $ rectWH 2 2)
HELDDETECTOR dt -> noPic (colorSH (detectorColor dt) $ upperPrismPolySU 3 $ rectWH 2 2)
KEYCARD _ -> noShape (setDepth 0 $ translate (-5) (-5) $ rotate (pi / 2.5) keyPic)
BINOCULARS -> mempty -- TODO
@@ -197,10 +197,10 @@ torchShape =
<> translateSHz (-0.5) bot
<> back
where
side = upperPrismPoly 3 $ rectXH 10 0.5
top = upperPrismPoly 0.5 $ rectXH 10 2
bot = upperPrismPoly 0.5 $ rectXH 9 2
back = upperPrismPoly 3 $ rectXH 1 2
side = upperPrismPolySE 3 $ rectXH 10 0.5
top = upperPrismPolySE 0.5 $ rectXH 10 2
bot = upperPrismPolySE 0.5 $ rectXH 9 2
back = upperPrismPolySE 3 $ rectXH 1 2
modulesSPic :: Item -> ModuleSlot -> ItemModuleType -> SPic
modulesSPic it _ imt = case imt of
@@ -216,35 +216,36 @@ baseStickShapeX it i = foldMap f [0 .. i -1]
barrelspread = it ^?! itParams . gunBarrels . brlSpread . spreadAngle
baseStickShape :: Shape
baseStickShape = colorSH green $ upperPrismPoly 3 $ rectXH 10 2
baseStickShape = colorSH green $ xCylinderST 3 10
bangConeShape :: Float -> Shape
bangConeShape x =
colorSH cyan $
upperPrismPoly 3 (rectXH x 2)
<> upperPrismPoly 6 (reverse $ rectNSWE 4 (-4) x (10 + x))
xCylinderST 3 x
<> upperPrismPolyST 6 (reverse $ rectNSWE 4 (-4) x (10 + x))
defSPic :: SPic
defSPic = noPic $ colorSH green $ upperPrismPoly 3 $ square 4
defSPic = noPic $ colorSH green $ upperPrismPolyST 3 $ square 4
shatterGunSPic :: SPic
shatterGunSPic =
-- TODO cylinderize
noPic $
colorSH blue $
upperPrismPoly 5 (rectNESW xb 8 xa 0)
<> upperPrismPoly 5 (rectNESW (- xa) 8 (- xb) 0)
upperPrismPolyST 5 (rectNESW xb 8 xa 0)
<> upperPrismPolyST 5 (rectNESW (- xa) 8 (- xb) 0)
where
xa = 1
xb = 9
baseCaneShape :: Shape
baseCaneShape = colorSH red $ upperPrismPoly 3 $ rectXH 15 1.5
baseCaneShape = colorSH red $ xCylinderST 3 15
baseRifleShape :: Shape
--baseRifleShape = colorSH red $ upperPrismPoly 3 $ rectXH 25 2
--baseRifleShape = colorSH red . rotateSHq (V3 0 1 0) (pi/2) . upperCylinder 25 $ polyCirc 3 2
--baseRifleShape = colorSH red $ xCylinder 4 2 25
baseRifleShape = colorSH red $ xCylinder' 3 25
baseRifleShape = colorSH red $ xCylinderST 3 25
addBullets :: Item -> Shape
addBullets itm = fromMaybe mempty $ do
@@ -253,13 +254,14 @@ addBullets itm = fromMaybe mempty $ do
ps <- fmap (take x) $ ammoPosition itm hit ^? amPosDirs
return $ foldMap (uncurry (drawBullet itm)) ps
-- why is this duplicated?
drawBullet :: Item -> Point3 -> Q.Quaternion Float -> Shape
drawBullet itm p q =
translateSH p $
overPosSH (Q.rotate q) $
colorSH
midcol
( upperPrismPoly 0.2 $
( upperPrismPolyTS 0.2 $
reverse
(rectNSWE 0.2 (- 0.2) (-1) 1)
)
@@ -275,14 +277,14 @@ drawBullet itm p q =
ebt <- itm ^? itUse . heldConsumption . laAmmoType . amBullet . buSpawn
return $
colorSH (bulletPayloadColor ebt) $
upperPrismPoly 0.2 $
upperPrismPolyTS 0.2 $
reverse $
rectNSWE 0.2 (- 0.2) 1 2
foot = fromMaybe mempty $ do
ebt <- itm ^? itUse . heldConsumption . laAmmoType . amBullet . buTrajectory
return $
colorSH (bulletTrajColor ebt) $
upperPrismPoly 0.2 $
upperPrismPolyTS 0.2 $
reverse $
rectNSWE 0.2 (- 0.2) (-2) (-1)
@@ -298,7 +300,7 @@ makeTinClip :: Item -> Shape
makeTinClip it =
colorSH
midcol
( upperPrismPoly
( upperPrismPolyTS
1
( reverse $
rectNSWE 0 (- y) (-1) 1
@@ -318,14 +320,14 @@ makeTinClip it =
ebt <- it ^? itUse . heldConsumption . laAmmoType . amBullet . buSpawn
return $
colorSH (bulletPayloadColor ebt) $
upperPrismPoly 1.1 $
upperPrismPolyTS 1.1 $
reverse $
rectNSWE 0 (- y) 1 2
tails = fromMaybe mempty $ do
ebt <- it ^? itUse . heldConsumption . laAmmoType . amBullet . buTrajectory
return $
colorSH (bulletTrajColor ebt) $
upperPrismPoly 1.1 $
upperPrismPolyTS 1.1 $
reverse $
rectNSWE 0 (- y) (-2) (-1)
@@ -362,7 +364,7 @@ volleyGunShape i =
colorSH
red
( foldMap
( (\y -> upperPrismPoly 3 $ map (+.+ V2 0 y) $ rectXH 15 2)
( (\y -> translateSHxy 0 y $ xCylinderST 3 15)
. (\k -> fromIntegral k * 5 - ((fromIntegral i - 1) * 2.5))
)
[0 .. i -1]
@@ -395,13 +397,13 @@ miniGunXPict i spin _ =
--baseSonicShape = colorSH rose $ upperPrismPoly 3 $ rectXH 25 2
baseSMGShape :: Shape
baseSMGShape = colorSH green $ upperPrismPoly 3 $ rectXH 20 2
baseSMGShape = colorSH green $ xCylinderST 3 20
flamerPic :: Item -> SPic
flamerPic it =
( colorSH yellow $
translateSHxy tx ty (upperPrismPoly tz $ polyCirc 3 r)
<> upperPrismPoly 5 (rectNESW 2 18 (-2) 0)
translateSHxy tx ty (upperPrismPolyST tz $ polyCirc 3 r)
<> xCylinderST 5 18
, color black $ translate3 (V3 tx ty (tz + 0.01)) $ circleSolid (r * am)
)
where
@@ -412,7 +414,7 @@ flamerPic it =
am = fractionLoadedAmmo2 it
launcherPic :: Item -> SPic
launcherPic _ = noPic . colorSH cyan $ xCylinder' 5 20
launcherPic _ = noPic . colorSH cyan $ xCylinderST 5 20
--launcherPic _ = noPic . colorSH cyan $ xCylinder 4 5 20
-- ( colorSH cyan $
-- prismPoly
@@ -422,17 +424,17 @@ launcherPic _ = noPic . colorSH cyan $ xCylinder' 5 20
-- )
baseRodShape :: Shape
baseRodShape = colorSH orange $ upperPrismPoly 3 $ rectXH 20 2
baseRodShape = colorSH orange $ xCylinderST 3 20
baseAMRShape :: Shape
baseAMRShape = colorSH orange $ upperPrismPoly 3 $ rectXH 30 2
baseAMRShape = colorSH orange $ xCylinderST 3 30
teslaGunPic :: SPic
teslaGunPic =
noPic $
colorSH blue $
upperPrismPoly 5 (rectNESW xb 8 xa 0)
<> upperPrismPoly 5 (rectNESW (- xa) 8 (- xb) 0)
upperPrismPolyST 5 (rectNESW xb 8 xa 0)
<> upperPrismPolyST 5 (rectNESW (- xa) 8 (- xb) 0)
where
xa = 1
xb = 9
@@ -440,9 +442,9 @@ teslaGunPic =
lasGunPic :: Item -> SPic
lasGunPic it =
( colorSH blue $
upperPrismPoly 4 (rectNESW 3 30 1 0)
<> upperPrismPoly 4 (rectNESW (-1) 30 (-3) 0)
<> upperPrismPoly 1 (rectNESW 3 30 (-3) 0)
upperBoxST 4 (rectNESW 3 30 1 0)
<> upperBoxSU 4 (rectNESW (-1) 30 (-3) 0)
<> upperBoxSU 1 (rectNESW 3 30 (-3) 0)
, setLayer BloomNoZWrite . color col . setDepth 1.1 . polygon $ rectNESW 1 30 (-1) 0
)
where
@@ -452,9 +454,9 @@ lasGunPic it =
dualBeamPic :: Item -> SPic
dualBeamPic it =
( colorSH blue $
upperPrismPoly 4 (rectNESW gap 3 (- gap) 1)
<> upperPrismPoly 4 (rectNESW gap (-1) (- gap) (-3))
<> upperPrismPoly 1 (rectNESW gap 3 (- gap) (-3))
upperBoxST 4 (rectNESW gap 3 (- gap) 1)
<> upperBoxSU 4 (rectNESW gap (-1) (- gap) (-3))
<> upperBoxSU 1 (rectNESW gap 3 (- gap) (-3))
, setLayer BloomNoZWrite . color col . setDepth 1.1 . polygon $ rectNESW gap 1 (- gap) (-1)
)
where
@@ -463,30 +465,23 @@ dualBeamPic it =
gap = _dbGap (_itParams it) - 3
tractorGunPic :: Item -> SPic
tractorGunPic it =
( colorSH red $
upperPrismPoly 4 (rectNESW 3 30 1 0)
<> upperPrismPoly 4 (rectNESW (-1) 30 (-3) 0)
<> upperPrismPoly 1 (rectNESW 3 30 (-3) 0)
, setLayer BloomNoZWrite . color col . setDepth 1.1 . polygon $ rectNESW 1 30 (-1) 0
)
where
amFrac = fractionLoadedAmmo it
col = brightX 2 1.5 $ mixColors amFrac (1 - amFrac) green red
tractorGunPic = lasGunPic
flatShieldEquipSPic :: SPic
flatShieldEquipSPic =
( colorSH yellow $ upperPrismPoly 10 (rectWH 2 10)
( colorSH yellow $ upperBoxMT 10 (rectWH 2 10)
, mempty
)
headLampShape :: Shape
headLampShape =
colorSH yellow $
translateSH (V3 5 2 4) (upperPrismPoly 4 $ rectWH 4 1)
<> translateSH (V3 5 2 0) (upperPrismPoly 4 $ rectWH 4 1)
<> translateSH (V3 5 (-2) 4) (upperPrismPoly 4 $ rectWH 4 1)
<> translateSH (V3 5 (-2) 0) (upperPrismPoly 4 $ rectWH 4 1)
oneside 5 2 4
<> oneside 5 2 0
<> oneside 5 (-2) 4
<> oneside 5 (-2) 0
where
oneside x y z = translateSH (V3 x y z) (upperPrismPolySE 4 $ rectWH 4 1)
detectorColor :: Detector -> Color
detectorColor dt = case dt of
@@ -513,4 +508,4 @@ keyPic =
-- ]
legsSPic :: Color -> SPic
legsSPic col = noPic $ translateSH (V3 0 4 0) $ colorSH col $ upperPrismPoly 3 $ rectWH 2 2
legsSPic col = noPic $ translateSH (V3 0 4 0) $ colorSH col $ upperPrismPolyST 3 $ rectWH 2 2