Prevent drawing of shadow caps when turned off
This commit is contained in:
@@ -3,6 +3,7 @@ layout (triangles) in;
|
||||
layout (triangle_strip, max_vertices = 3) out;
|
||||
layout (std140, binding = 0) uniform TheMat { mat4 theMat; } ;
|
||||
layout(location=0)uniform vec3 lightPos;
|
||||
in float drawbit[];
|
||||
// this code is duplicated in lineShadow.geom, should not be changed on its own
|
||||
vec4 projNear (vec4 pos)
|
||||
{
|
||||
@@ -20,7 +21,8 @@ void main()
|
||||
vec4 p2 = gl_in[2].gl_Position ;
|
||||
if ( //if Light Source is below all vertices, draw cap
|
||||
// TODO think about when LS is beside the object
|
||||
( p0.z - lightPos.z > 0 )
|
||||
(drawbit[0] == 1)
|
||||
&& ( p0.z - lightPos.z > 0 )
|
||||
&& ( p1.z - lightPos.z > 0 )
|
||||
&& ( p2.z - lightPos.z > 0 )
|
||||
)
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#version 450 core
|
||||
layout (location = 0) in vec3 position;
|
||||
layout (location = 0) in vec4 position;
|
||||
layout (std140, binding = 0) uniform TheMat { mat4 theMat; } ;
|
||||
uniform vec3 lightPos;
|
||||
uniform vec4 lumRad;
|
||||
out vec3 dField;
|
||||
out vec3 lum;
|
||||
out float drawbit;
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(position,1);
|
||||
gl_Position = vec4(position.xyz,1);
|
||||
drawbit = position.w;
|
||||
}
|
||||
|
||||
+31
-20
@@ -133,7 +133,7 @@ pokeRoundedFaces ::
|
||||
IO (Int, Int, Int)
|
||||
{-# INLINE pokeRoundedFaces #-}
|
||||
pokeRoundedFaces sfid col size ptr iptr ieptr (nv, nsi, nei) (tc : bc : svs) = do
|
||||
nv' <- pokeRoundedCurve col ptr tc bc svs nv
|
||||
nv' <- pokeRoundedCurve xdata col ptr tc bc svs nv
|
||||
nsi' <-
|
||||
UV.foldM'
|
||||
(pokeIndex nv iptr)
|
||||
@@ -143,6 +143,9 @@ pokeRoundedFaces sfid col size ptr iptr ieptr (nv, nsi, nei) (tc : bc : svs) = d
|
||||
else UV.foldM' (pokeIndex nv ieptr) nei $
|
||||
memoTopPrismEdgeIndices V.! (size - 3)
|
||||
return (nv', nsi', nei')
|
||||
where
|
||||
xdata | sfid = 0
|
||||
| otherwise = 1
|
||||
pokeRoundedFaces _ _ _ _ _ _ _ _ = undefined
|
||||
|
||||
pokeCylinder ::
|
||||
@@ -157,7 +160,7 @@ pokeCylinder ::
|
||||
IO (Int, Int, Int)
|
||||
{-# INLINE pokeCylinder #-}
|
||||
pokeCylinder sfid col size ptr iptr ieptr (nv, nsi, nei) (tc : bc : svs) = do
|
||||
nv' <- pokeRoundedCurve col ptr tc bc svs nv >>= pokeCylinderCaps col ptr tc bc svs
|
||||
nv' <- pokeRoundedCurve xdata col ptr tc bc svs nv >>= pokeCylinderCaps xdata col ptr tc bc svs
|
||||
nsi' <-
|
||||
UV.foldM'
|
||||
(pokeIndex nv iptr)
|
||||
@@ -168,21 +171,24 @@ pokeCylinder sfid col size ptr iptr ieptr (nv, nsi, nei) (tc : bc : svs) = do
|
||||
else UV.foldM' (pokeIndex nv ieptr) nei $
|
||||
memoTopPrismEdgeIndices V.! (size - 3)
|
||||
return (nv', nsi', nei')
|
||||
where
|
||||
xdata | sfid = 0
|
||||
| otherwise = 1
|
||||
pokeCylinder _ _ _ _ _ _ _ _ = undefined
|
||||
|
||||
pokeRoundedCurve :: Point4 -> Ptr Float -> Point3 -> Point3 -> [Point3] -> Int -> IO Int
|
||||
pokeRoundedCurve :: Float -> Point4 -> Ptr Float -> Point3 -> Point3 -> [Point3] -> Int -> IO Int
|
||||
{-# INLINE pokeRoundedCurve #-}
|
||||
pokeRoundedCurve col ptr tc bc = go True
|
||||
pokeRoundedCurve xdata col ptr tc bc = go True
|
||||
where
|
||||
go True (x : xs) n = pokeJustV tc col ptr n x >>= go False xs
|
||||
go False (x : xs) n = pokeJustV bc col ptr n x >>= go True xs
|
||||
go True (x : xs) n = pokeJustV xdata tc col ptr n x >>= go False xs
|
||||
go False (x : xs) n = pokeJustV xdata bc col ptr n x >>= go True xs
|
||||
go _ [] n = return n
|
||||
|
||||
pokeCylinderCaps :: Point4 -> Ptr Float -> Point3 -> Point3 -> [Point3] -> Int -> IO Int
|
||||
pokeCylinderCaps col ptr tc bc = go True
|
||||
pokeCylinderCaps :: Float -> Point4 -> Ptr Float -> Point3 -> Point3 -> [Point3] -> Int -> IO Int
|
||||
pokeCylinderCaps xdata col ptr tc bc = go True
|
||||
where
|
||||
go True (x : xs) n = pokeJustVInvNormal tc col ptr n x >>= go False xs
|
||||
go False (x : xs) n = pokeJustVInvNormal bc col ptr n x >>= go True xs
|
||||
go True (x : xs) n = pokeJustVInvNormal xdata tc col ptr n x >>= go False xs
|
||||
go False (x : xs) n = pokeJustVInvNormal xdata bc col ptr n x >>= go True xs
|
||||
go _ [] n = return n
|
||||
|
||||
pokeBox ::
|
||||
@@ -197,7 +203,7 @@ pokeBox ::
|
||||
IO (Int, Int, Int)
|
||||
{-# INLINE pokeBox #-}
|
||||
pokeBox sfid col size ptr iptr ieptr (nv, nsi, nei) svs = do
|
||||
nv' <- VFSM.foldM' (pokeBoxSurface col ptr svsv) nv $ VFSM.fromList $ boxSurfaces size
|
||||
nv' <- VFSM.foldM' (pokeBoxSurface xdata col ptr svsv) nv $ VFSM.fromList $ boxSurfaces size
|
||||
nsi' <-
|
||||
UV.foldM'
|
||||
(pokeIndex nv iptr)
|
||||
@@ -209,12 +215,14 @@ pokeBox sfid col size ptr iptr ieptr (nv, nsi, nei) svs = do
|
||||
return (nv', nsi', nei')
|
||||
where
|
||||
svsv = UV.fromList svs
|
||||
xdata | sfid = 0
|
||||
| otherwise = 1
|
||||
|
||||
-- should probably use a vector of Point3
|
||||
pokeBoxSurface :: Point4 -> Ptr Float -> UV.Vector Point3 -> Int -> [Int] -> IO Int
|
||||
pokeBoxSurface col ptr vs n is =
|
||||
pokeBoxSurface :: Float -> Point4 -> Ptr Float -> UV.Vector Point3 -> Int -> [Int] -> IO Int
|
||||
pokeBoxSurface xdata col ptr vs n is =
|
||||
UV.foldM'
|
||||
(pokeFlatV norm col ptr)
|
||||
(pokeFlatV xdata norm col ptr)
|
||||
n
|
||||
v
|
||||
where
|
||||
@@ -346,6 +354,7 @@ topPrismIndices n =
|
||||
-- and just doing two pokes rather than seven
|
||||
-- (especially if adding normal data)
|
||||
pokeJustV ::
|
||||
Float ->
|
||||
Point3 ->
|
||||
Point4 ->
|
||||
Ptr Float ->
|
||||
@@ -353,8 +362,8 @@ pokeJustV ::
|
||||
Point3 ->
|
||||
IO Int
|
||||
{-# INLINE pokeJustV #-}
|
||||
pokeJustV cp col ptr nv sh = do
|
||||
UV.imapM_ f $ UV.fromList [x, y, z, 1, r, g, b, a, nx, ny, nz, 1]
|
||||
pokeJustV xdata cp col ptr nv sh = do
|
||||
UV.imapM_ f $ UV.fromList [x, y, z, xdata, r, g, b, a, nx, ny, nz, 1]
|
||||
return (nv + 1)
|
||||
where
|
||||
f i = pokeElemOff ptr (nv * nShapeVerxComp + i)
|
||||
@@ -363,6 +372,7 @@ pokeJustV cp col ptr nv sh = do
|
||||
V3 nx ny nz = cp
|
||||
|
||||
pokeJustVInvNormal ::
|
||||
Float ->
|
||||
Point3 ->
|
||||
Point4 ->
|
||||
Ptr Float ->
|
||||
@@ -370,8 +380,8 @@ pokeJustVInvNormal ::
|
||||
Point3 ->
|
||||
IO Int
|
||||
{-# INLINE pokeJustVInvNormal #-}
|
||||
pokeJustVInvNormal cp col ptr nv sh = do
|
||||
UV.imapM_ f $ UV.fromList [x, y, z, 1, r, g, b, a, nx, ny, nz, 1]
|
||||
pokeJustVInvNormal xdata cp col ptr nv sh = do
|
||||
UV.imapM_ f $ UV.fromList [x, y, z, xdata, r, g, b, a, nx, ny, nz, 1]
|
||||
return (nv + 1)
|
||||
where
|
||||
f i = pokeElemOff ptr (nv * nShapeVerxComp + i)
|
||||
@@ -380,6 +390,7 @@ pokeJustVInvNormal cp col ptr nv sh = do
|
||||
V3 nx ny nz = (2 * sh) - cp
|
||||
|
||||
pokeFlatV ::
|
||||
Float ->
|
||||
Point3 ->
|
||||
Point4 ->
|
||||
Ptr Float ->
|
||||
@@ -387,8 +398,8 @@ pokeFlatV ::
|
||||
Point3 ->
|
||||
IO Int
|
||||
{-# INLINE pokeFlatV #-}
|
||||
pokeFlatV norm col ptr nv sh = do
|
||||
UV.imapM_ f $ UV.fromList [x, y, z, 1, r, g, b, a, nx, ny, nz, 1]
|
||||
pokeFlatV xdata norm col ptr nv sh = do
|
||||
UV.imapM_ f $ UV.fromList [x, y, z, xdata, r, g, b, a, nx, ny, nz, 1]
|
||||
return (nv + 1)
|
||||
where
|
||||
f i = pokeElemOff ptr (nv * nShapeVerxComp + i)
|
||||
|
||||
Reference in New Issue
Block a user