From 71ae82ee4de67f213ab133a5ce15248a8078ccb1 Mon Sep 17 00:00:00 2001 From: justin Date: Thu, 13 Nov 2025 18:09:12 +0000 Subject: [PATCH] Reduce poked cloud verx size --- shader/pull/cloud.vert | 7 +++++-- src/Preload/Render.hs | 2 +- src/Shader/Poke/Cloud.hs | 19 ++++++++++--------- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/shader/pull/cloud.vert b/shader/pull/cloud.vert index d72b29609..15dcd675f 100644 --- a/shader/pull/cloud.vert +++ b/shader/pull/cloud.vert @@ -1,5 +1,7 @@ #version 450 core -struct CloudPosCol { vec4 pos; vec4 col; }; +//struct CloudPosCol { vec4 pos; vec4 col; }; +//struct CloudPosCol { vec3 pos; uint colx; vec4 col; }; +struct CloudPosCol { vec3 pos; uint colx; }; layout (std140, binding = 0) uniform TheMat { mat4 theMat; } ; layout (std430, binding = 6) readonly buffer CPos { CloudPosCol data[]; }; const vec2 indices[6] = @@ -17,7 +19,8 @@ void main() { uint i = gl_VertexID / 6; uint k = gl_VertexID % 6; - vCol = data[i].col; + //vCol = data[i].col; + vCol = unpackUnorm4x8(data[i].colx); 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/Preload/Render.hs b/src/Preload/Render.hs index dbbd56ac4..5ed7605e7 100644 --- a/src/Preload/Render.hs +++ b/src/Preload/Render.hs @@ -83,7 +83,7 @@ preloadRender = do ieptr <- mallocArray 65536 -- so we can go back to glushort... cloudbo <- mglCreate glCreateBuffers - let cvsize = (sizeOf (0 :: Float)) * 8 + let cvsize = (sizeOf (0 :: Float)) * 4 cloudbosize = fromIntegral cvsize * 65536 -- this should be changed glNamedBufferStorage cloudbo cloudbosize nullPtr GL_DYNAMIC_STORAGE_BIT glBindBufferBase GL_SHADER_STORAGE_BUFFER 6 cloudbo diff --git a/src/Shader/Poke/Cloud.hs b/src/Shader/Poke/Cloud.hs index a21168468..e1c665790 100644 --- a/src/Shader/Poke/Cloud.hs +++ b/src/Shader/Poke/Cloud.hs @@ -2,6 +2,7 @@ module Shader.Poke.Cloud (pokeCloud, pokeDust) where +import Shader.Parameters import Color import Control.Lens --import qualified Data.Vector.Unboxed as UV @@ -40,15 +41,15 @@ mkDustCloudLike x = (x ^. dsPos, V4 r g b a) -- 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, V4 r g b a) = do - pokeElemOff ptr (nv * 8) x - pokeElemOff ptr (nv * 8 + 1) y - pokeElemOff ptr (nv * 8 + 2) z - pokeElemOff ptr (nv * 8 + 3) 1 - pokeElemOff ptr (nv * 8 + 4) r - pokeElemOff ptr (nv * 8 + 5) g - pokeElemOff ptr (nv * 8 + 6) b - pokeElemOff ptr (nv * 8 + 7) a +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 + 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 ()