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