Clamp framebuffer textures to edges

This commit is contained in:
2025-11-14 12:41:44 +00:00
parent 9fc36ec54c
commit a24ee66f51
6 changed files with 27 additions and 18 deletions
+3 -2
View File
@@ -1,9 +1,10 @@
module Dodge.Distortion where
{-# LANGUAGE LambdaCase #-}
module Dodge.Distortion (updateDistortion) where
import Dodge.Data.Distortion
updateDistortion :: Distortion -> Maybe Distortion
updateDistortion dt = case dt of
updateDistortion = \case
RadialDistortion a b c v
| v > 1 -> Just $ RadialDistortion a b c $ max 1 (v - 0.05)
| v < 1 -> Just $ RadialDistortion a b c $ min 1 (v + 0.05)
+9 -6
View File
@@ -1,11 +1,14 @@
module Dodge.Event.Test (
testEvent,
) where
module Dodge.Event.Test (testEvent) where
--import Dodge.Creature.State
import Dodge.Data.World
--import Control.Lens
import Linear
import LensHelp
import Data.Maybe
testEvent :: World -> World
testEvent w = w
testEvent w = fromMaybe w $ do
cpos <- w ^? cWorld . lWorld . creatures . ix 0 . crPos . _xy
let distR = 50
distortionBulge = RadialDistortion cpos (cpos + V2 distR 0) (cpos + V2 0 distR) 1.9
return $ w & cWorld . lWorld . distortions .~ [distortionBulge]
+2
View File
@@ -220,5 +220,7 @@ initializeTexture2D fbo attachpoint x y minfilt magfilt form = do
glTextureStorage2D to1 1 form xsize' ysize'
glTextureParameteri to1 GL_TEXTURE_MIN_FILTER (unsafeCoerce minfilt)
glTextureParameteri to1 GL_TEXTURE_MAG_FILTER (unsafeCoerce magfilt)
glTextureParameteri to1 GL_TEXTURE_WRAP_S (unsafeCoerce GL_CLAMP_TO_EDGE)
glTextureParameteri to1 GL_TEXTURE_WRAP_T (unsafeCoerce GL_CLAMP_TO_EDGE)
glNamedFramebufferTexture (_unFBO fbo) attachpoint to1 0
return to1
+5 -4
View File
@@ -128,7 +128,7 @@ preloadRender = do
bloomBlurShad <- makeSourcedShader "texture/bloomBlur" [vert, frag]
lightingTextureShad <- makeSourcedShader "lighting/texture" [vert, frag]
barrelShad <- makeShaderVBO "texture/barrel" [vert, geom, frag] (toFloatVAs [2, 2, 2, 1]) pmPoints
-- blank wallShader
putStrLn "Setup floor VBO, shader"
flvbo <- mglCreate glCreateBuffers
flptr <- mallocArray (8 * 65536)
@@ -142,8 +142,7 @@ preloadRender = do
chptr <- mallocArray (2 * 65536)
let chasmvbo = VBO chvbo chptr (2 * floatSize)
chasmshader <- makeSourcedShader "chasm" [vert]
framebuf2 <- newTextureFramebuffer
framebuf3 <- newTextureFramebuffer
putStrLn "Setup framebuffers"
rboBaseBloomName <- mglCreate glCreateRenderbuffers
@@ -157,6 +156,9 @@ preloadRender = do
fboPosName <- setupFramebufferGivenStencil rboBaseBloomName
fboLightingName <- setupFramebufferGivenStencil rboBaseBloomName
framebuf2 <- newTextureFramebuffer
framebuf3 <- newTextureFramebuffer
fboHalf1Name <- newTextureFramebuffer
fboHalf2Name <- newTextureFramebuffer
@@ -205,7 +207,6 @@ preloadRender = do
, _winVBO = winvbo
, _cloudVBO = cloudvbo
, _cloudShader = cloudshader
-- , _screenTextureVAO = screentexturevao
, _dummyVAO = dummyvao
}