Allow independent distortion of rgb channels
This commit is contained in:
@@ -12,9 +12,15 @@ data Distortion = RadialDistortion
|
||||
{ _rdPos :: Point2
|
||||
, _rdDist1 :: Point2
|
||||
, _rdDist2 :: Point2
|
||||
, _rdT1 :: Point2
|
||||
, _rdT2 :: Point2
|
||||
, _rdT3 :: Point2
|
||||
, _rdT1R :: Point2
|
||||
, _rdT2R :: Point2
|
||||
, _rdT3R :: Point2
|
||||
, _rdT1G :: Point2
|
||||
, _rdT2G :: Point2
|
||||
, _rdT3G :: Point2
|
||||
, _rdT1B :: Point2
|
||||
, _rdT2B :: Point2
|
||||
, _rdT3B :: Point2
|
||||
, _rdTime :: Int
|
||||
}
|
||||
deriving (Eq, Ord, Show, Read) --Generic, Flat)
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
{-# LANGUAGE LambdaCase #-}
|
||||
|
||||
module Dodge.Distortion (updateDistortion) where
|
||||
|
||||
import Dodge.Data.Distortion
|
||||
import Control.Lens
|
||||
|
||||
updateDistortion :: Distortion -> Maybe Distortion
|
||||
updateDistortion = \case
|
||||
RadialDistortion a b c d e f t
|
||||
| t > 0 -> Just $ RadialDistortion a b c d e f $ t-1
|
||||
| otherwise -> Nothing
|
||||
updateDistortion rd
|
||||
| rd ^. rdTime > 0 = Just $ rd & rdTime .~ 1
|
||||
| otherwise = Nothing
|
||||
|
||||
@@ -11,16 +11,17 @@ testEvent :: World -> World
|
||||
testEvent w = fromMaybe w $ do
|
||||
cpos <- w ^? cWorld . lWorld . creatures . ix 0 . crPos . _xy
|
||||
let distR = 50
|
||||
t1 = (V2 1 (-1))
|
||||
t2 = (V2 1 1)
|
||||
t3 = (V2 distR 0)
|
||||
distortionBulge =
|
||||
RadialDistortion
|
||||
cpos
|
||||
(V2 distR 0)
|
||||
(V2 0 distR)
|
||||
(V2 1 (-1))
|
||||
(V2 1 1)
|
||||
(V2 distR 0)
|
||||
t1 t2 t3 t1 t2 t3 t1 t2 t3
|
||||
20
|
||||
return $ w & cWorld . lWorld . distortions .~ [distortionBulge
|
||||
, distortionBulge & rdPos +~ 50
|
||||
, distortionBulge & rdPos +~ 50 & rdT1R +~ V2 (-1) 1
|
||||
, distortionBulge & rdPos +~ (-50)
|
||||
]
|
||||
|
||||
+2
-3
@@ -366,13 +366,12 @@ doDrawing' win pdata u = do
|
||||
glBindFramebuffer GL_FRAMEBUFFER 0
|
||||
glUseProgram (pdata ^. fullscreenShader)
|
||||
glDrawArrays GL_TRIANGLES 0 6
|
||||
--(RadialDistortion (V2 a b) (V2 c d) (V2 e f) (V2 g h) _:_) -> do
|
||||
rs' -> do
|
||||
let rs = take 10 rs'
|
||||
glBindFramebuffer GL_FRAMEBUFFER (pdata ^. fbo2 . _1 . unFBO)
|
||||
withArray (concatMap rdToVec2s rs) $
|
||||
glNamedBufferSubData (pdata ^. barrelShader . _2 . vboName) 0
|
||||
(12 * fromIntegral (length rs * sizeOf (0 :: Float)))
|
||||
(18 * fromIntegral (length rs * sizeOf (0 :: Float)))
|
||||
glBindTextureUnit 1 $ pdata ^. fboBase . _2 . _1 . unTO
|
||||
glUseProgram (pdata ^. barrelShader . _1)
|
||||
glUniform1i 0 (fromIntegral (length rs))
|
||||
@@ -400,7 +399,7 @@ doDrawing' win pdata u = do
|
||||
SDL.glSwapWindow win
|
||||
|
||||
rdToVec2s :: Distortion -> [Point2]
|
||||
rdToVec2s (RadialDistortion a b c d e f _) = [a,b,c,d,e,f]
|
||||
rdToVec2s (RadialDistortion a b c d e f g h i j k l _) = [a,b,c,d,e,f,g,h,i,j,k,l]
|
||||
|
||||
bufferPerspectiveMatrixUBO :: Config -> Camera -> GLuint -> IO ()
|
||||
bufferPerspectiveMatrixUBO cfig cam uboid =
|
||||
|
||||
Reference in New Issue
Block a user