Bind some fixed texture arrays only once
This commit is contained in:
@@ -5,8 +5,8 @@ layout (location=0) out vec4 fCol;
|
|||||||
layout (location=1) out vec4 fPos;
|
layout (location=1) out vec4 fPos;
|
||||||
layout (location=2) out vec4 normal;
|
layout (location=2) out vec4 normal;
|
||||||
//layout (binding=0) uniform sampler2DArray tilesetSampler;
|
//layout (binding=0) uniform sampler2DArray tilesetSampler;
|
||||||
layout (binding=1) uniform sampler2DArray normalSampler;
|
layout (binding=40) uniform sampler2DArray diffuseSampler;
|
||||||
layout (binding=2) uniform sampler2DArray diffuseSampler;
|
layout (binding=41) uniform sampler2DArray normalSampler;
|
||||||
vec2 rotateV2 (float a, vec2 v)
|
vec2 rotateV2 (float a, vec2 v)
|
||||||
{
|
{
|
||||||
return vec2(v.x*cos(a) - v.y*sin(a), v.x*sin(a) + v.y*cos(a));
|
return vec2(v.x*cos(a) - v.y*sin(a), v.x*sin(a) + v.y*cos(a));
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ const vec2 winSize = vec2 (300.0,300.0);
|
|||||||
// note that the above opening bracket should be the first in this file
|
// note that the above opening bracket should be the first in this file
|
||||||
// this is so that the window size can be extracted and the shader recompiled on
|
// this is so that the window size can be extracted and the shader recompiled on
|
||||||
// the fly
|
// the fly
|
||||||
uniform sampler2D screenTexture;
|
layout (binding = 0) uniform sampler2D screenTexture;
|
||||||
const float hOff = 3 / winSize.x;
|
const float hOff = 3 / winSize.x;
|
||||||
const float vOff = 3 / winSize.y;
|
const float vOff = 3 / winSize.y;
|
||||||
//const vec2 off[9] = vec2[]
|
//const vec2 off[9] = vec2[]
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ in vec4 gPos;
|
|||||||
in vec4 gNorm;
|
in vec4 gNorm;
|
||||||
in vec4 gColor;
|
in vec4 gColor;
|
||||||
in float gAng;
|
in float gAng;
|
||||||
layout (binding=1) uniform sampler2DArray normalSampler;
|
layout (binding=40) uniform sampler2DArray diffuseSampler;
|
||||||
layout (binding=2) uniform sampler2DArray diffuseSampler;
|
layout (binding=41) uniform sampler2DArray normalSampler;
|
||||||
vec2 rotateV2 (float a, vec2 v)
|
vec2 rotateV2 (float a, vec2 v)
|
||||||
{
|
{
|
||||||
return vec2(v.x*cos(a) - v.y*sin(a), v.x*sin(a) + v.y*cos(a));
|
return vec2(v.x*cos(a) - v.y*sin(a), v.x*sin(a) + v.y*cos(a));
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ in vec4 gPos;
|
|||||||
in vec4 gNorm;
|
in vec4 gNorm;
|
||||||
in vec4 gColor;
|
in vec4 gColor;
|
||||||
in float gRot;
|
in float gRot;
|
||||||
layout (binding=1) uniform sampler2DArray normalSampler;
|
layout (binding=40) uniform sampler2DArray diffuseSampler;
|
||||||
layout (binding=2) uniform sampler2DArray diffuseSampler;
|
layout (binding=41) uniform sampler2DArray normalSampler;
|
||||||
vec2 rotateV2 (float a, vec2 v)
|
vec2 rotateV2 (float a, vec2 v)
|
||||||
{
|
{
|
||||||
return vec2(v.x*cos(a) - v.y*sin(a), v.x*sin(a) + v.y*cos(a));
|
return vec2(v.x*cos(a) - v.y*sin(a), v.x*sin(a) + v.y*cos(a));
|
||||||
|
|||||||
@@ -54,8 +54,8 @@ data RenderData = RenderData
|
|||||||
, _vboShapes :: VBO
|
, _vboShapes :: VBO
|
||||||
, _floorVBO :: VBO
|
, _floorVBO :: VBO
|
||||||
, _floorShader :: Shader
|
, _floorShader :: Shader
|
||||||
, _toNormalMaps :: TO
|
, _texaNormalMaps :: TO
|
||||||
, _toDiffuse :: TO
|
, _texaDiffuse :: TO
|
||||||
, _wallVBO :: VBO
|
, _wallVBO :: VBO
|
||||||
, _wallShader :: Shader
|
, _wallShader :: Shader
|
||||||
, _cloudVBO :: VBO
|
, _cloudVBO :: VBO
|
||||||
|
|||||||
+1
-4
@@ -179,9 +179,6 @@ doDrawing' win pdata u = do
|
|||||||
--draw floor onto base buffer
|
--draw floor onto base buffer
|
||||||
glUseProgram (pdata ^. floorShader . shaderUINT)
|
glUseProgram (pdata ^. floorShader . shaderUINT)
|
||||||
glBindVertexArray $ pdata ^. floorShader . shaderVAO . vaoName
|
glBindVertexArray $ pdata ^. floorShader . shaderVAO . vaoName
|
||||||
glBindTextureUnit 1 (pdata ^. toNormalMaps . unTO)
|
|
||||||
--glTextureParameteri (pdata ^. toNormalMaps . unTO) GL_TEXTURE_BASE_LEVEL 3
|
|
||||||
glBindTextureUnit 2 (pdata ^. toDiffuse . unTO)
|
|
||||||
glDrawArrays
|
glDrawArrays
|
||||||
(_unPrimitiveMode $ pdata ^. floorShader . shaderPrimitive )
|
(_unPrimitiveMode $ pdata ^. floorShader . shaderPrimitive )
|
||||||
0
|
0
|
||||||
@@ -227,7 +224,7 @@ doDrawing' win pdata u = do
|
|||||||
setViewportSize (round winx `div` (2 * resFact)) (round winy `div` (2 * resFact))
|
setViewportSize (round winx `div` (2 * resFact)) (round winy `div` (2 * resFact))
|
||||||
glBindFramebuffer GL_FRAMEBUFFER (_unFBO (fst (_fboHalf1 pdata)))
|
glBindFramebuffer GL_FRAMEBUFFER (_unFBO (fst (_fboHalf1 pdata)))
|
||||||
glDepthFunc GL_ALWAYS
|
glDepthFunc GL_ALWAYS
|
||||||
glBindTexture GL_TEXTURE_2D (pdata ^. fboBloom . _2 . unTO)
|
glBindTextureUnit 0 (pdata ^. fboBloom . _2 . unTO)
|
||||||
glDisable GL_BLEND
|
glDisable GL_BLEND
|
||||||
drawShader (_bloomBlurShader pdata) 4
|
drawShader (_bloomBlurShader pdata) 4
|
||||||
replicateM_ 9 $ pingPongBetween (_fboHalf1 pdata) (_fboHalf2 pdata) (_bloomBlurShader pdata)
|
replicateM_ 9 $ pingPongBetween (_fboHalf1 pdata) (_fboHalf2 pdata) (_bloomBlurShader pdata)
|
||||||
|
|||||||
@@ -161,8 +161,10 @@ preloadRender = do
|
|||||||
let floorverxstrd = 8
|
let floorverxstrd = 8
|
||||||
floorvbo <- setupVBOStatic floorverxstrd
|
floorvbo <- setupVBOStatic floorverxstrd
|
||||||
floorshader <- makeShader4 "floor/arrayPos" [vert, frag] [4,4] floorverxstrd pmTriangles floorvbo
|
floorshader <- makeShader4 "floor/arrayPos" [vert, frag] [4,4] floorverxstrd pmTriangles floorvbo
|
||||||
tonormalmap <- initTexture2DArray 3 GL_LINEAR_MIPMAP_LINEAR GL_LINEAR "data/normalMaps/normalArray.png"
|
|
||||||
todiffusemap <- initTexture2DArray 3 GL_LINEAR_MIPMAP_LINEAR GL_LINEAR "data/normalMaps/diffuseArray.png"
|
todiffusemap <- initTexture2DArray 3 GL_LINEAR_MIPMAP_LINEAR GL_LINEAR "data/normalMaps/diffuseArray.png"
|
||||||
|
tonormalmap <- initTexture2DArray 3 GL_LINEAR_MIPMAP_LINEAR GL_LINEAR "data/normalMaps/normalArray.png"
|
||||||
|
glBindTextureUnit 40 (todiffusemap ^. unTO)
|
||||||
|
glBindTextureUnit 41 (tonormalmap ^. unTO)
|
||||||
|
|
||||||
let cloudverxsizes = [4,4,4,4]
|
let cloudverxsizes = [4,4,4,4]
|
||||||
cloudvbo <- setupVBO (sum cloudverxsizes)
|
cloudvbo <- setupVBO (sum cloudverxsizes)
|
||||||
@@ -250,8 +252,8 @@ preloadRender = do
|
|||||||
, _vboShapes = shVBO
|
, _vboShapes = shVBO
|
||||||
, _floorVBO = floorvbo
|
, _floorVBO = floorvbo
|
||||||
, _floorShader = floorshader
|
, _floorShader = floorshader
|
||||||
, _toNormalMaps = tonormalmap
|
, _texaNormalMaps = tonormalmap
|
||||||
, _toDiffuse = todiffusemap
|
, _texaDiffuse = todiffusemap
|
||||||
, _wallVBO = wallvbo
|
, _wallVBO = wallvbo
|
||||||
, _wallShader = wallshader
|
, _wallShader = wallshader
|
||||||
, _cloudVBO = cloudvbo
|
, _cloudVBO = cloudvbo
|
||||||
|
|||||||
Reference in New Issue
Block a user