Poke word8 colors for shapes

This commit is contained in:
2023-04-13 02:30:23 +01:00
parent 5d4234a8f4
commit 3c43caee9c
6 changed files with 33 additions and 15 deletions
+10 -6
View File
@@ -9,6 +9,7 @@ module Shader.Poke (
pokeFloors,
) where
import Color
import Control.Monad.Primitive
import qualified Data.Vector as V
import qualified Data.Vector.Fusion.Stream.Monadic as VFSM
@@ -426,10 +427,11 @@ pokeJustV ::
IO Int
{-# INLINE pokeJustV #-}
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]
pokeByteOff ptr (nv * shapeVerxSize) (V4 x y z xdata)
pokeByteOff ptr (nv *shapeVerxSize + 4 * floatSize) (toColor8 col)
pokeByteOff ptr (nv *shapeVerxSize + 4 * (floatSize + ubyteSize)) (V4 nx ny nz 1)
return (nv + 1)
where
f i = pokeElemOff ptr (nv * nShapeVerxComp + i)
V3 x y z = sh
V4 r g b a = col
V3 nx ny nz = cp
@@ -444,10 +446,11 @@ pokeJustVInvNormal ::
IO Int
{-# INLINE pokeJustVInvNormal #-}
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]
pokeByteOff ptr (nv * shapeVerxSize) (V4 x y z xdata)
pokeByteOff ptr (nv *shapeVerxSize + 4 * floatSize) (toColor8 col)
pokeByteOff ptr (nv *shapeVerxSize + 4 * (floatSize + ubyteSize)) (V4 nx ny nz 1)
return (nv + 1)
where
f i = pokeElemOff ptr (nv * nShapeVerxComp + i)
V3 x y z = sh
V4 r g b a = col
V3 nx ny nz = (2 * sh) - cp
@@ -462,10 +465,11 @@ pokeFlatV ::
IO Int
{-# INLINE pokeFlatV #-}
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]
pokeByteOff ptr (nv * shapeVerxSize) (V4 x y z xdata)
pokeByteOff ptr (nv *shapeVerxSize + 4 * floatSize) (toColor8 col)
pokeByteOff ptr (nv *shapeVerxSize + 4 * (floatSize + ubyteSize)) (V4 nx ny nz 1)
return (nv + 1)
where
f i = pokeElemOff ptr (nv * nShapeVerxComp + i)
V3 x y z = sh
V4 r g b a = col
V3 nx ny nz = sh - norm