Improve normal packing and unpacking

This commit is contained in:
2025-11-11 21:47:39 +00:00
parent 4121bfb468
commit ce1937c78e
3 changed files with 8 additions and 8 deletions
+2 -2
View File
@@ -11,8 +11,8 @@ out vec4 vNorm;
void main() {
vPos = data[indices[gl_VertexID]].pos;
vCol = unpackUnorm4x8(data[indices[gl_VertexID]].col);
vec4 n = unpackUnorm4x8(data[indices[gl_VertexID]].norm);
vNorm = n *2 - vec4(1,1,1,1);
vNorm = unpackSnorm4x8(data[indices[gl_VertexID]].norm);
//vNorm = n *2 - vec4(1,1,1,1);
gl_Position = theMat * vec4(vPos.xyz,1);
}
//layout (location = 0) in vec4 pos;
+5 -5
View File
@@ -439,7 +439,7 @@ pokeJustV :: Float -> Point3 -> Point4 -> Ptr Float -> Int -> Point3 -> IO Int
{-# INLINE pokeJustV #-}
pokeJustV xdata cp col ptr nv sh = do
pokeByteOff ptr (nv * shapeVerxSize) (V4 x y z xdata)
pokeByteOff ptr (nv *shapeVerxSize + 4 * floatSize) (normalToColor8 $ V4 nx ny nz 1)
pokeByteOff ptr (nv *shapeVerxSize + 4 * floatSize) (normalTo8 $ V4 nx ny nz 1)
pokeByteOff ptr (nv *shapeVerxSize + 5 * floatSize) (toColor8 col)
return (nv + 1)
where
@@ -457,17 +457,17 @@ pokeFlatV ::
{-# INLINE pokeFlatV #-}
pokeFlatV xdata pnorm col ptr nv sh = do
pokeByteOff ptr (nv * shapeVerxSize) (V4 x y z xdata)
pokeByteOff ptr (nv *shapeVerxSize + 4 * floatSize) (normalToColor8 $ V4 nx ny nz 1)
pokeByteOff ptr (nv *shapeVerxSize + 4 * floatSize) (normalTo8 $ V4 nx ny nz 1)
pokeByteOff ptr (nv *shapeVerxSize + 5 * floatSize) (toColor8 col)
return (nv + 1)
where
V3 x y z = sh
V3 nx ny nz = (sh - pnorm) - V3 x y z
normalToColor8 :: Point4 -> Color8
normalToColor8 = over each f . normalize
normalTo8 :: Point4 -> V4 Int8
normalTo8 = over each f . normalize
where
f x = floor $ (x + 1) * 127.5
f x = floor $ x * 127
pokeLayVerxs ::
MV.MVector (PrimState IO) (Shader, VBO) ->
+1 -1
View File
@@ -4226,7 +4226,7 @@ noclipCheck src/Dodge/WallCreatureCollisions.hs 23;" f
nodeFormatting src/Dodge/Combine/Graph.hs 145;" f
nodesNear src/Dodge/Path.hs 75;" f
normalGait src/Dodge/Creature/State/WalkCycle.hs 30;" f
normalToColor8 src/Shader/Poke.hs 467;" f
normalTo8 src/Shader/Poke.hs 467;" f
normalizeAngle src/Geometry/Vector.hs 128;" f
normalizeAnglePi src/Dodge/Base.hs 154;" f
normalizeColor src/Color.hs 76;" f