Move towards pixel upscaling filter
This commit is contained in:
@@ -21,6 +21,7 @@ data RenderData = RenderData
|
||||
, _windowPullShader :: GLuint
|
||||
, _pullWallShader :: GLuint
|
||||
, _fullscreenShader :: GLuint
|
||||
, _textureAntiaShader :: GLuint
|
||||
, _bloomBlurShader :: GLuint
|
||||
, _barrelShader :: (GLuint,VBO)
|
||||
, _shapeShader :: GLuint
|
||||
|
||||
+2
-1
@@ -367,7 +367,8 @@ doDrawing' win pdata u = do
|
||||
[] -> do
|
||||
glBindTextureUnit 0 $ pdata ^. fboBase . _2 . _1 . unTO
|
||||
glBindFramebuffer GL_FRAMEBUFFER 0
|
||||
glUseProgram (pdata ^. fullscreenShader)
|
||||
glUseProgram (pdata ^. textureAntiaShader)
|
||||
glUniform2f 0 (windowXFloat cfig) (windowYFloat cfig)
|
||||
--glDrawArrays GL_TRIANGLES 0 6
|
||||
glDrawArrays GL_TRIANGLES 0 3
|
||||
rs' -> do
|
||||
|
||||
@@ -21,17 +21,29 @@ import Unsafe.Coerce
|
||||
sizeFBOs :: Config -> RenderData -> IO RenderData
|
||||
sizeFBOs cfig rdata =
|
||||
uncurryV (resizeRBO (_rboBaseBloom rdata)) (getWindowSize _gr_world_res cfig)
|
||||
>> updateFBOTO3
|
||||
-- >> updateFBOTO3
|
||||
-- (getWindowSize _gr_world_res cfig)
|
||||
-- GL_NEAREST
|
||||
-- GL_NEAREST
|
||||
-- GL_RGB16F -- RGBAF not sure if the alpha is necessary here
|
||||
-- GL_RGB16F -- could possibly recover using depth in a clever way
|
||||
-- -- but probably not, because the projection matrix is
|
||||
-- -- not always on-center
|
||||
-- GL_RGBA8_SNORM
|
||||
-- rdata
|
||||
-- fboBase
|
||||
>> fboBase (resizeFBOTO3'
|
||||
(getWindowSize _gr_world_res cfig)
|
||||
GL_NEAREST
|
||||
GL_NEAREST
|
||||
GL_RGBA16F -- not sure if the alpha is necessary here
|
||||
GL_NEAREST
|
||||
GL_NEAREST
|
||||
GL_RGB16F -- RGBAF not sure if the alpha is necessary here
|
||||
GL_RGB16F -- could possibly recover using depth in a clever way
|
||||
-- but probably not, because the projection matrix is
|
||||
-- not always on-center
|
||||
GL_RGB8_SNORM
|
||||
GL_RGBA8_SNORM)
|
||||
rdata
|
||||
fboBase
|
||||
>>= flip
|
||||
(
|
||||
updateFBOTO3
|
||||
@@ -181,8 +193,39 @@ resizeFBOTO3 (fbo, (told1, told2, told3)) xsize ysize minfilt magfilt form1 form
|
||||
to1 <- initializeTexture2D fbo GL_COLOR_ATTACHMENT0 xsize ysize minfilt magfilt form1
|
||||
to2 <- initializeTexture2D fbo GL_COLOR_ATTACHMENT1 xsize ysize minfilt magfilt form2
|
||||
to3 <- initializeTexture2D fbo GL_COLOR_ATTACHMENT2 xsize ysize minfilt magfilt form3
|
||||
withArray [GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2] $ \ptr ->
|
||||
glNamedFramebufferDrawBuffers (_unFBO fbo) 3 ptr
|
||||
withArray [GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2] $
|
||||
glNamedFramebufferDrawBuffers (_unFBO fbo) 3
|
||||
checkFBO fbo
|
||||
return (fbo, (TO to1, TO to2, TO to3))
|
||||
|
||||
resizeFBOTO3' ::
|
||||
V2 Int ->
|
||||
-- | minification filter
|
||||
GLenum ->
|
||||
-- | magnification filter
|
||||
GLenum ->
|
||||
-- | minification filter
|
||||
GLenum ->
|
||||
-- | magnification filter
|
||||
GLenum ->
|
||||
-- | internal color format1
|
||||
GLenum ->
|
||||
-- | internal color format2
|
||||
GLenum ->
|
||||
-- | internal color format3
|
||||
GLenum ->
|
||||
(FBO, (TO, TO, TO)) ->
|
||||
IO (FBO, (TO, TO, TO))
|
||||
resizeFBOTO3' (V2 xsize ysize) min1 mag1 minfilt magfilt form1 form2 form3 (fbo, (told1, told2, told3)) = do
|
||||
glBindFramebuffer GL_FRAMEBUFFER (_unFBO fbo)
|
||||
mglDelete glDeleteTextures $ _unTO told1
|
||||
mglDelete glDeleteTextures $ _unTO told2
|
||||
mglDelete glDeleteTextures $ _unTO told3
|
||||
to1 <- initializeTexture2D fbo GL_COLOR_ATTACHMENT0 xsize ysize min1 mag1 form1
|
||||
to2 <- initializeTexture2D fbo GL_COLOR_ATTACHMENT1 xsize ysize minfilt magfilt form2
|
||||
to3 <- initializeTexture2D fbo GL_COLOR_ATTACHMENT2 xsize ysize minfilt magfilt form3
|
||||
withArray [GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2] $
|
||||
glNamedFramebufferDrawBuffers (_unFBO fbo) 3
|
||||
checkFBO fbo
|
||||
return (fbo, (TO to1, TO to2, TO to3))
|
||||
|
||||
|
||||
@@ -133,6 +133,7 @@ preloadRender = do
|
||||
putStrLn "Setup full screen shaders"
|
||||
alphadivideshader <- makeSourcedShader "texture2D/alphaDivide" [vert, frag]
|
||||
fsShad <- makeSourcedShader "texture/simple" [vert, frag]
|
||||
textureantiashad <- makeSourcedShader "texture/antia" [vert,frag]
|
||||
bloomBlurShad <- makeSourcedShader "texture/bloomBlur" [vert, frag]
|
||||
lightingTextureShad <- makeSourcedShader "lighting/texture" [vert, frag]
|
||||
lightingCloudShad <- makeSourcedShader "lighting/cloud" [vert, frag]
|
||||
@@ -150,8 +151,9 @@ preloadRender = do
|
||||
flptr <- mallocArray (8 * 65536)
|
||||
let floorvbo = VBO flvbo flptr (8 * floatSize)
|
||||
floorshader <- makeSourcedShader "floor/arrayPos" [vert, frag]
|
||||
initTexture2DArraySquare 40 3 GL_LINEAR_MIPMAP_LINEAR GL_LINEAR "data/normalMaps/diffuseArray.png"
|
||||
initTexture2DArraySquare 41 3 GL_LINEAR_MIPMAP_LINEAR GL_LINEAR "data/normalMaps/normalArray.png"
|
||||
initTexture2DArraySquare 40 5 GL_LINEAR_MIPMAP_LINEAR GL_LINEAR "data/normalMaps/diffuseArray.png"
|
||||
initTexture2DArraySquare 41 5 GL_LINEAR_MIPMAP_LINEAR GL_LINEAR "data/normalMaps/normalArray.png"
|
||||
-- initTexture2DArraySquare 41 3 GL_NEAREST_MIPMAP_LINEAR GL_LINEAR "data/normalMaps/normalArray.png"
|
||||
|
||||
putStrLn "Setup chasm VBO, shader"
|
||||
chvbo <- mglCreate glCreateBuffers
|
||||
@@ -196,6 +198,7 @@ preloadRender = do
|
||||
, _ceilingStencilShader = ceilingstencilshader
|
||||
, _windowPullShader = winpull
|
||||
, _pullWallShader = wallpull
|
||||
, _textureAntiaShader = textureantiashad
|
||||
, _fullscreenShader = fsShad
|
||||
, _alphaDivideShader = alphadivideshader
|
||||
, _lightingTextureShader = lightingTextureShad
|
||||
|
||||
+2
-2
@@ -455,7 +455,7 @@ pokeFlatV ::
|
||||
{-# INLINE pokeFlatV #-}
|
||||
pokeFlatV xdata pnorm col ptr nv sh = do
|
||||
pokeByteOff ptr (nv * shapeVerxSize) (V4 x y z xdata)
|
||||
pokeByteOff ptr (nv *shapeVerxSize + 4 * floatSize) (normalTo8 $ V4 nx ny nz 1)
|
||||
pokeByteOff ptr (nv *shapeVerxSize + 4 * floatSize) (normalTo8 $ V4 nx ny nz (-1))
|
||||
pokeByteOff ptr (nv *shapeVerxSize + 5 * floatSize) (toColor8 col)
|
||||
return (nv + 1)
|
||||
where
|
||||
@@ -463,7 +463,7 @@ pokeFlatV xdata pnorm col ptr nv sh = do
|
||||
V3 nx ny nz = (sh - pnorm) - V3 x y z
|
||||
|
||||
normalTo8 :: Point4 -> V4 Int8
|
||||
normalTo8 = over each f . normalize
|
||||
normalTo8 = over each f . over _xyz normalize
|
||||
where
|
||||
f x = floor $ x * 127
|
||||
|
||||
|
||||
Reference in New Issue
Block a user