From 227f09eeda0a24d89814bf260c0bf7ca742af227 Mon Sep 17 00:00:00 2001 From: justin Date: Thu, 13 Nov 2025 18:23:45 +0000 Subject: [PATCH] Cleanup --- shader/pull/cloud.vert | 7 ++----- src/Shader/Poke/Cloud.hs | 45 +++------------------------------------- 2 files changed, 5 insertions(+), 47 deletions(-) diff --git a/shader/pull/cloud.vert b/shader/pull/cloud.vert index 15dcd675f..c9c98ae56 100644 --- a/shader/pull/cloud.vert +++ b/shader/pull/cloud.vert @@ -1,7 +1,5 @@ #version 450 core -//struct CloudPosCol { vec4 pos; vec4 col; }; -//struct CloudPosCol { vec3 pos; uint colx; vec4 col; }; -struct CloudPosCol { vec3 pos; uint colx; }; +struct CloudPosCol { vec3 pos; uint col; }; layout (std140, binding = 0) uniform TheMat { mat4 theMat; } ; layout (std430, binding = 6) readonly buffer CPos { CloudPosCol data[]; }; const vec2 indices[6] = @@ -19,8 +17,7 @@ void main() { uint i = gl_VertexID / 6; uint k = gl_VertexID % 6; - //vCol = data[i].col; - vCol = unpackUnorm4x8(data[i].colx); + vCol = unpackUnorm4x8(data[i].col); vControls = indices[k]; vPos = vec3(data[i].pos.xy + 20*vControls, data[i].pos.z); gl_Position = theMat * vec4(vPos,1); diff --git a/src/Shader/Poke/Cloud.hs b/src/Shader/Poke/Cloud.hs index e1c665790..6a4acede2 100644 --- a/src/Shader/Poke/Cloud.hs +++ b/src/Shader/Poke/Cloud.hs @@ -10,13 +10,9 @@ import Dodge.Data.Cloud import Dodge.Material.Color import Foreign import Geometry.Data ---import Graphics.GL.Core45 ---import Linear -pokeCloud :: Ptr Float -> Int -> Cloud -> IO Int +pokeCloud :: Ptr Float -> Int -> Cloud -> IO Int pokeCloud vptr nv = pokeCloudLike vptr nv . mkCloudCloudLike ---pokeCloud :: Ptr Float -> Ptr GLuint -> (Int, Int) -> Cloud -> IO (Int, Int) ---pokeCloud vptr iptr (nv, ni) = pokeCloudLike vptr iptr (nv, ni) . mkCloudCloudLike pokeDust :: Ptr Float -> Int -> Dust -> IO Int pokeDust vptr nv = pokeCloudLike vptr nv . mkDustCloudLike @@ -33,39 +29,12 @@ mkDustCloudLike x = (x ^. dsPos, V4 r g b a) (V4 r g b a') = dustColor x a = a' * min 1 (fromIntegral (_dsTimer x) / 100) ---pokeCloudLike :: --- Ptr Float -> Ptr GLuint -> (Int, Int) -> (Point3, Point4) -> IO (Int, Int) ---pokeCloudLike vptr iptr (nv, ni) x = do --- UV.imapM_ (pokeCloudLikeVerx vptr x nv) $ --- UV.fromList [(1, 1), (-1, 1), (-1, -1), (1, -1)] --- UV.imapM_ (pokeCloudIndex iptr nv ni) $ UV.fromList [0, 1, 2, 2, 0, 3] --- return (nv + 4, ni + 6) pokeCloudLike :: Ptr Float -> Int -> (Point3, Point4) -> IO Int -pokeCloudLike ptr nv (V3 x y z, col@(V4 r g b a)) = do - pokeElemOff ptr (nv * 4) x - pokeElemOff ptr (nv * 4 + 1) y - pokeElemOff ptr (nv * 4 + 2) z +pokeCloudLike ptr nv (pos, col) = do + pokeByteOff ptr (floatSize * nv * 4) pos pokeByteOff ptr (floatSize * (nv * 4 + 3)) (toColor8 col) --- pokeElemOff ptr (nv * 8 + 4) r --- pokeElemOff ptr (nv * 8 + 5) g --- pokeElemOff ptr (nv * 8 + 6) b --- pokeElemOff ptr (nv * 8 + 7) a return $ nv + 1 ---pokeCloudLikeVerx :: Ptr Float -> (Point3, Point4) -> Int -> Int -> (Float, Float) -> IO () ---{-# INLINE pokeCloudLikeVerx #-} ---pokeCloudLikeVerx ptr (V3 cx cy cz, V4 r g b a) nv i (dx, dy) = --- UV.imapM_ (pokeCloudFloat ptr (nv + i)) $ --- UV.fromList [x, y, cz, 1, r, g, b, a, dx, dy, 0, 0] --- where --- V2 x y = V2 cx cy + 20 *^ V2 dx dy - ---pokeCloudLikeVerx :: Ptr Float -> (Point3, Point4) -> Int -> Int -> (Float, Float) -> IO () ---{-# INLINE pokeCloudLikeVerx #-} ---pokeCloudLikeVerx ptr (V3 x y z, V4 r g b a) nv i (dx, dy) = --- UV.imapM_ (pokeCloudFloat ptr (nv + i)) $ --- UV.fromList [x, y, z, 1, r, g, b, a] - clColor :: CloudType -> Color clColor = \case Smoke -> greyN 0.7 @@ -73,13 +42,5 @@ clColor = \case CryoReleaseCloud -> white GasCloud -> green ---pokeCloudFloat :: Ptr Float -> Int -> Int -> Float -> IO () ---{-# INLINE pokeCloudFloat #-} ---pokeCloudFloat ptr nv i = pokeElemOff ptr (nv * 12 + i) --- ---pokeCloudIndex :: Ptr GLuint -> Int -> Int -> Int -> Int -> IO () ---{-# INLINE pokeCloudIndex #-} ---pokeCloudIndex ptr nv ni ioff voff = pokeElemOff ptr (ni + ioff) (fromIntegral $ nv + voff) - dustColor :: Dust -> Color dustColor = materialColor . _dsType