Allow for multiple distortions at once

This commit is contained in:
2025-11-18 22:49:51 +00:00
parent 8428f08ebd
commit b633b9d55f
5 changed files with 41 additions and 31 deletions
+10 -3
View File
@@ -3,14 +3,21 @@
module Dodge.Data.Distortion where
import Control.Lens
import Geometry
import Data.Aeson
import Data.Aeson.TH
data Distortion = RadialDistortion
Point2 Point2 Point2
Point2 Point2 Point2
Int
{ _rdPos :: Point2
, _rdDist1 :: Point2
, _rdDist2 :: Point2
, _rdT1 :: Point2
, _rdT2 :: Point2
, _rdT3 :: Point2
, _rdTime :: Int
}
deriving (Eq, Ord, Show, Read) --Generic, Flat)
makeLenses ''Distortion
deriveJSON defaultOptions ''Distortion
+6 -4
View File
@@ -16,8 +16,10 @@ testEvent w = fromMaybe w $ do
cpos
(V2 distR 0)
(V2 0 distR)
(V2 2 0)
(V2 0 0.5)
(V2 0 0)
(V2 1 (-1))
(V2 1 1)
(V2 distR 0)
20
return $ w & cWorld . lWorld . distortions .~ [distortionBulge]
return $ w & cWorld . lWorld . distortions .~ [distortionBulge
, distortionBulge & rdPos +~ 50
]
+6 -4
View File
@@ -367,12 +367,11 @@ doDrawing' win pdata u = do
glUseProgram (pdata ^. fullscreenShader)
glDrawArrays GL_TRIANGLES 0 6
--(RadialDistortion (V2 a b) (V2 c d) (V2 e f) (V2 g h) _:_) -> do
(RadialDistortion a b c d e f _:_) -> do
rs -> do
glBindFramebuffer GL_FRAMEBUFFER (pdata ^. fbo2 . _1 . unFBO)
-- pokeArray (pdata ^. barrelShader . _2 . vboPtr) [a, b, c, d, e, f, g, h]
withArray [a, b, c, d, e, f] $
withArray (concatMap rdToVec2s rs) $
glNamedBufferSubData (pdata ^. barrelShader . _2 . vboName) 0
(12 * fromIntegral (sizeOf (0 :: Float)))
(12 * fromIntegral (length rs * sizeOf (0 :: Float)))
glBindTextureUnit 1 $ pdata ^. fboBase . _2 . _1 . unTO
glUseProgram (pdata ^. barrelShader . _1)
glDrawArrays GL_TRIANGLES 0 6
@@ -398,6 +397,9 @@ doDrawing' win pdata u = do
renderLayer FixedCoordLayer shadV pokeCounts
SDL.glSwapWindow win
rdToVec2s :: Distortion -> [Point2]
rdToVec2s (RadialDistortion a b c d e f _) = [a,b,c,d,e,f]
bufferPerspectiveMatrixUBO :: Config -> Camera -> GLuint -> IO ()
bufferPerspectiveMatrixUBO cfig cam uboid =
withArray