This commit is contained in:
2025-11-13 18:23:45 +00:00
parent 71ae82ee4d
commit 227f09eeda
2 changed files with 5 additions and 47 deletions
+2 -5
View File
@@ -1,7 +1,5 @@
#version 450 core #version 450 core
//struct CloudPosCol { vec4 pos; vec4 col; }; struct CloudPosCol { vec3 pos; uint col; };
//struct CloudPosCol { vec3 pos; uint colx; vec4 col; };
struct CloudPosCol { vec3 pos; uint colx; };
layout (std140, binding = 0) uniform TheMat { mat4 theMat; } ; layout (std140, binding = 0) uniform TheMat { mat4 theMat; } ;
layout (std430, binding = 6) readonly buffer CPos { CloudPosCol data[]; }; layout (std430, binding = 6) readonly buffer CPos { CloudPosCol data[]; };
const vec2 indices[6] = const vec2 indices[6] =
@@ -19,8 +17,7 @@ void main()
{ {
uint i = gl_VertexID / 6; uint i = gl_VertexID / 6;
uint k = gl_VertexID % 6; uint k = gl_VertexID % 6;
//vCol = data[i].col; vCol = unpackUnorm4x8(data[i].col);
vCol = unpackUnorm4x8(data[i].colx);
vControls = indices[k]; vControls = indices[k];
vPos = vec3(data[i].pos.xy + 20*vControls, data[i].pos.z); vPos = vec3(data[i].pos.xy + 20*vControls, data[i].pos.z);
gl_Position = theMat * vec4(vPos,1); gl_Position = theMat * vec4(vPos,1);
+3 -42
View File
@@ -10,13 +10,9 @@ import Dodge.Data.Cloud
import Dodge.Material.Color import Dodge.Material.Color
import Foreign import Foreign
import Geometry.Data 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 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 :: Ptr Float -> Int -> Dust -> IO Int
pokeDust vptr nv = pokeCloudLike vptr nv . mkDustCloudLike 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 (V4 r g b a') = dustColor x
a = a' * min 1 (fromIntegral (_dsTimer x) / 100) 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 Float -> Int -> (Point3, Point4) -> IO Int
pokeCloudLike ptr nv (V3 x y z, col@(V4 r g b a)) = do pokeCloudLike ptr nv (pos, col) = do
pokeElemOff ptr (nv * 4) x pokeByteOff ptr (floatSize * nv * 4) pos
pokeElemOff ptr (nv * 4 + 1) y
pokeElemOff ptr (nv * 4 + 2) z
pokeByteOff ptr (floatSize * (nv * 4 + 3)) (toColor8 col) 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 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 :: CloudType -> Color
clColor = \case clColor = \case
Smoke -> greyN 0.7 Smoke -> greyN 0.7
@@ -73,13 +42,5 @@ clColor = \case
CryoReleaseCloud -> white CryoReleaseCloud -> white
GasCloud -> green 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 :: Dust -> Color
dustColor = materialColor . _dsType dustColor = materialColor . _dsType