Commit before attempt to remove geometry shaders from shadow extrusion

This commit is contained in:
2023-02-23 23:10:00 +00:00
parent f98f95d92f
commit c73e8af72a
15 changed files with 28 additions and 31 deletions
Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

+3 -8
View File
@@ -18,24 +18,19 @@ void main()
vec4 p0 = gl_in[0].gl_Position ;
vec4 p1 = gl_in[1].gl_Position ;
vec4 p2 = gl_in[2].gl_Position ;
if ( //dot( p0.xyz - vec3 (0,0,1), cross( p0.xyz - p1.xyz, p1.xyz - p2.xyz)) < 0
// &&
if ( //if Light Source is below all vertices, draw cap
// TODO think about when LS is beside the object
( p0.z - lightPos.z > 0 )
&& ( p1.z - lightPos.z > 0 )
&& ( p2.z - lightPos.z > 0 )
)
{
// front cap
// the front cap
vec4 v1 = vec4 (0,0,1,0) ;
gl_Position = theMat * projNear(p0); EmitVertex();
gl_Position = theMat * projNear(p1); EmitVertex();
gl_Position = theMat * projNear(p2); EmitVertex();
EndPrimitive();
// if light points downwards onto surface, draw back cap too
if (dot ( p0.xyz - lightPos, vec3 ( 0,0,1) ) > 0)
{
}
else {}
}
else {}
}
+3 -2
View File
@@ -3,7 +3,8 @@ layout (lines_adjacency) in;
layout (triangle_strip, max_vertices = 4) out;
layout (std140, binding = 0) uniform TheMat { mat4 theMat; } ;
uniform vec3 lightPos;
vec4 shift (vec4 p) { return (vec4 (p.xyz + (100000*(p.xyz-lightPos)), 1));}
//vec4 shift (vec4 p) { return (vec4 (p.xyz + (100000*(p.xyz-lightPos)), 1));}
vec4 shift (vec4 p) { return (vec4 (p.xyz + (1000*(p.xyz-lightPos)), 1));}
// copied from lighting/cap.geom, should not be changed on its own
vec4 projNear (vec4 pos)
{
@@ -34,7 +35,7 @@ void main()
//vec3 n2 = n0 + n1; // assumes the summands are normalized
vec3 lightDir = p0.xyz - lightPos.xyz;
// first test if the edge is part of the silhouette
// that is, if the normals of the faces connected by the edge point in
// that is, if the normals of the faces connected by the edge point are in
// "different directions" wrt the light direction
if ( dot(n0 , lightDir) * dot(n1 , lightDir) <= 0 )
// using <= rather than < seems to get rid of overlapping shadow
+1 -1
View File
@@ -130,7 +130,7 @@ visibleWalls sp ep =
allVisibleWalls :: World -> [(Point2, Wall)]
{-# INLINE allVisibleWalls #-}
allVisibleWalls w = concatMap (flip (visibleWalls vPos) w . (+.+ vPos)) $ nRays 20
allVisibleWalls w = concatMap (flip (visibleWalls vPos) w . (+.+ vPos)) $ nRays 15
where
vPos = w ^. cWorld . camPos . camViewFrom
+2 -1
View File
@@ -73,7 +73,8 @@ maybeClearPath :: World -> PathEdgeNodes -> World
maybeClearPath w (PathEdgeNodes x y pe)
| not . null $ overlapSegWalls (_peStart pe) (_peEnd pe) $ wlsNearSeg (_peStart pe) (_peEnd pe) w =
w
| otherwise = w & cWorld . lWorld . pathGraph %~ FGL.insEdge (x, y, pe & peObstacles .~ mempty) . FGL.delEdge (x, y)
| otherwise = w
& cWorld . pathGraph %~ FGL.insEdge (x, y, pe & peObstacles .~ mempty) . FGL.delEdge (x, y)
destroyDoor :: Door -> World -> World
destroyDoor dr w =
+1 -1
View File
@@ -54,4 +54,4 @@ chaseCrit =
0
, _crMvType = defaultChaseMvType
}
& crType . humanoidAI .~ ChaseAI
-- & crType . humanoidAI .~ ChaseAI
+2
View File
@@ -19,6 +19,7 @@ import Dodge.GameRoom
import Geometry.ConvexPoly
import Dodge.Data.CamPos
import qualified Data.IntSet as IS
import Data.Graph.Inductive
data CWorld = CWorld
{ _lWorld :: LWorld
@@ -29,6 +30,7 @@ data CWorld = CWorld
, _timeFlow :: TimeFlowStatus
, _seenWalls :: IS.IntSet
, _floorTiles :: [(Point3, Point3)]
, _pathGraph :: Gr Point2 PathEdge
}
data TimeFlowStatus
-2
View File
@@ -50,7 +50,6 @@ module Dodge.Data.LWorld (
import Control.Lens
import Data.Aeson
import Data.Aeson.TH
import Data.Graph.Inductive
import Dodge.Data.Beam
import Dodge.Data.Block
import Dodge.Data.Bounds
@@ -138,7 +137,6 @@ data LWorld = LWorld
, _decorations :: IM.IntMap Picture
, _foregroundShapes :: IM.IntMap ForegroundShape
, _corpses :: IM.IntMap Corpse
, _pathGraph :: Gr Point2 PathEdge
, _lightSources :: IM.IntMap LightSource
, _tempLightSources :: [TempLightSource]
, _seenLocations :: IM.IntMap (WdP2, String)
+2 -1
View File
@@ -84,6 +84,8 @@ defaultCWorld =
, _timeFlow = NormalTimeFlow
, _seenWalls = mempty
, _floorTiles = mempty
--, _pathGraph = mempty
, _pathGraph = Data.Graph.Inductive.Graph.empty
}
defaultLWorld :: LWorld
@@ -130,7 +132,6 @@ defaultLWorld =
, _buttons = IM.empty
, _corpses = IM.empty
, _decorations = IM.empty
, _pathGraph = Data.Graph.Inductive.Graph.empty
, _lightSources = IM.empty
, _tempLightSources = []
, _seenLocations =
+2 -3
View File
@@ -3,6 +3,7 @@ module Dodge.Layout (
generateLevelFromRoomList,
) where
import Dodge.Path.Translate
import qualified Control.Foldl as L
import Control.Lens
import Data.Foldable
@@ -44,7 +45,7 @@ generateLevelFromRoomList gr' w =
. worldToGenWorld rs'
$ w & cWorld . lWorld . walls .~ wallsFromRooms rs
& cWorld . cwGen . cwgGameRooms .~ gameRoomsFromRooms (IM.elems rs')
& cWorld . lWorld . pathGraph .~ path
& cWorld . pathGraph .~ path
& pnZoning .~ foldl' (flip zonePn) mempty (labNodes path)
& peZoning .~ foldl' (flip zonePe) mempty (map fromEdgeTuple $ labEdges path)
where
@@ -54,8 +55,6 @@ generateLevelFromRoomList gr' w =
rs = map doRoomShift $ IM.elems rs'
rs' = mapM shuffleRoomPos gr' & evalState $ _randGen w
fromEdgeTuple :: (Int, Int, PathEdge) -> PathEdgeNodes
fromEdgeTuple (a, b, pe) = PathEdgeNodes a b pe
randomCompass :: World -> World
randomCompass w = w & cWorld . camPos . camRot .~ (takeOne [0, 0.5 * pi, pi, 1.5 * pi] & evalState $ _randGen w)
+5 -5
View File
@@ -30,14 +30,14 @@ import Data.Bifunctor
getNodePos :: Int -> World -> Maybe Point2
--getNodePos i w = _pathGraph (_cWorld w) `lab` i
getNodePos i w = (w ^. cWorld . lWorld . pathGraph) `lab` i
getNodePos i w = (w ^. cWorld . pathGraph) `lab` i
makePathBetween :: Point2 -> Point2 -> World -> Maybe [Int]
makePathBetween a b w = do
-- join $ sp <$> a' <*> b' <*> return (_pathGraph w)
na <- walkableNodeNear w a
nb <- walkableNodeNear w b
sp na nb (second _peDist (efilter (not . pathEdgeObstructed . (^. _3)) $ w ^. cWorld . lWorld . pathGraph))
sp na nb (second _peDist (efilter (not . pathEdgeObstructed . (^. _3)) $ w ^. cWorld . pathGraph))
--_pathGraph (_cWorld w)))
pathEdgeObstructed :: PathEdge -> Bool
@@ -53,13 +53,13 @@ walkableNodeNear w p = fmap fst . find (flip (isWalkable p) w . snd) $ nodesNear
makePathBetweenPs :: Point2 -> Point2 -> World -> Maybe [Point2]
--makePathBetweenPs a b w = mapMaybe (lab $ _pathGraph (_cWorld w)) <$> makePathBetween a b w
makePathBetweenPs a b w = mapMaybe (lab $ w ^. cWorld . lWorld . pathGraph) <$> makePathBetween a b w
makePathBetweenPs a b w = mapMaybe (lab $ w ^. cWorld . pathGraph) <$> makePathBetween a b w
bfsNodePoints :: Int -> World -> [Point2]
bfsNodePoints n w = mapMaybe (lab g) $ bfs n g
where
--g = _pathGraph (_cWorld w)
g = w ^. cWorld . lWorld . pathGraph
g = w ^. cWorld . pathGraph
pointTowardsImpulse :: Point2 -> Point2 -> World -> Maybe Point2
pointTowardsImpulse a b w = (find (flip (isWalkable a) w) . reverse) =<< makePathBetweenPs a b w
@@ -138,7 +138,7 @@ addEdges nodemap gr = foldl' f (mempty, gr)
obstructPathsCrossing :: EdgeObstacle -> Point2 -> Point2 -> World -> (World, Set PathEdgeNodes)
obstructPathsCrossing obstacletype sp' ep w =
( w & cWorld . lWorld . pathGraph %~ updateedges
( w & cWorld . pathGraph %~ updateedges
, es
)
where
+2 -2
View File
@@ -71,9 +71,9 @@ maybeClearDoorPaths eo es w = foldl' (maybeClearDoorPath eo) w es
maybeClearDoorPath :: EdgeObstacle -> World -> PathEdgeNodes -> World
maybeClearDoorPath eo w (PathEdgeNodes x y pe)
| not . null $ overlapSegWalls (_peStart pe) (_peEnd pe) $ wlsNearSeg (_peStart pe) (_peEnd pe) w =
w & cWorld . lWorld . pathGraph %~ FGL.insEdge (x, y, pe & peObstacles . at eo ?~ ()) . FGL.delEdge (x, y)
w & cWorld . pathGraph %~ FGL.insEdge (x, y, pe & peObstacles . at eo ?~ ()) . FGL.delEdge (x, y)
| otherwise =
w & cWorld . lWorld . pathGraph %~ FGL.insEdge (x, y, pe & peObstacles . at eo .~ Nothing) . FGL.delEdge (x, y)
w & cWorld . pathGraph %~ FGL.insEdge (x, y, pe & peObstacles . at eo .~ Nothing) . FGL.delEdge (x, y)
plSlideDoor ::
Door ->
+1 -1
View File
@@ -463,7 +463,7 @@ drawPathing cfig w =
<> foldMap dispInc (graphToIncidence gr)
where
dispInc (p, n) = setDepth 2 . uncurryV translate p . scale 0.1 0.1 $ text $ show n
gr = w ^. cWorld . lWorld . pathGraph
gr = w ^. cWorld . pathGraph
crDisplayInfo :: Configuration -> CamPos -> Creature -> Maybe (Point2, [String])
crDisplayInfo cfig cam cr
+3 -3
View File
@@ -8,6 +8,8 @@ module Dodge.Save (
reloadLevelStart,
) where
import Dodge.Path.Translate
import Data.Graph.Inductive (labEdges, labNodes)
import Dodge.Zoning.Pathing
import Data.Foldable
@@ -53,11 +55,9 @@ readSaveSlot ss = do
& uvScreenLayers .~ []
else putStrLn "loadSaveSlot failed to find saved file" >> return removescreenlayers
where
path uv = uv ^. uvWorld . cWorld . lWorld . pathGraph
path uv = uv ^. uvWorld . cWorld . pathGraph
removescreenlayers = Just . (uvScreenLayers .~ [])
fromEdgeTuple :: (Int, Int, PathEdge) -> PathEdgeNodes
fromEdgeTuple (a, b, pe) = PathEdgeNodes a b pe
saveSlotPath :: SaveSlot -> String
saveSlotPath (SaveSlotNum i) = "saveSlot/" ++ show i
+1 -1
View File
@@ -165,7 +165,7 @@ pokeJustV :: Ptr Float
-> Int
-> ShapeV
-> IO Int
--{-# INLINE pokeJustV #-}
{-# INLINE pokeJustV #-}
pokeJustV ptr nv sh = do
-- pokeArray (advancePtr ptr (off 0)) [a,b,c,d,e,f,g]
pokeElemOff ptr (off 0) a