Remove individual uniforms from instancing light maps

This commit is contained in:
2023-03-10 14:11:25 +00:00
parent c8b256c939
commit 5724a0543e
6 changed files with 21 additions and 22 deletions
+6 -6
View File
@@ -2,13 +2,13 @@
layout (triangles) in;
layout (triangle_strip, max_vertices = 3) out;
layout (std140, binding = 0) uniform TheMat { mat4 theMat; } ;
//layout (std140, binding = 1) uniform LightsBlock
//{
// vec4 posBool[20];
// vec4 colRad[20];
//} ;
uniform vec3 lightPos;
layout (std140, binding = 1) uniform LightsBlock
{
vec4 posBool[20];
vec4 colRad[20];
} ;
uniform int lightID;
vec3 lightPos = posBool[lightID].xyz ;
// this code is duplicated in lineShadow.geom, should not be changed on its own
vec4 projNear (vec4 pos)
{
-3
View File
@@ -7,11 +7,8 @@ layout (std140, binding = 1) uniform LightsBlock
vec4 posBool[20];
vec4 colRad[20];
} ;
//uniform vec3 lightPos;
//uniform float radiusUniform;
uniform int lightID;
vec3 lightPos1 = posBool[lightID].xyz;
//vec3 lightPos1 = lightPos;
float theBool = posBool[lightID].w;
vec4 shift (vec4 p) { return (vec4 (p.xyz + (100000*(p.xyz-lightPos1)), 1));} ;
vec4 shiftBy (float x,vec4 p) { return (vec4 (lightPos1 + (x*normalize(p.xyz-lightPos1)), 1));} ;
+3 -2
View File
@@ -4,8 +4,9 @@ layout (std140, binding = 1) uniform LightsBlock
vec4 posBool[20];
vec4 colRad[20];
} ;
uniform vec3 lightPos;
uniform vec4 lumRad;
uniform int lightID;
vec3 lightPos = posBool[lightID].xyz;
vec4 lumRad = colRad[lightID];
uniform sampler2D screenTexture;
in vec2 vTexPos;
out vec4 fColor;
+1 -1
View File
@@ -7,8 +7,8 @@ layout (std140, binding = 1) uniform LightsBlock
vec4 posBool[20];
vec4 colRad[20];
} ;
uniform vec3 lightPos;
uniform int lightID;
vec3 lightPos = posBool[lightID].xyz;
vec4 shift (vec4 p)
{ return vec4 (p.xy + (200 * (p.xy-lightPos.xy)), 0 , 1);
}
+4 -3
View File
@@ -145,11 +145,11 @@ preloadRender = do
-- >>= addUniforms ["lightPos", "radiusUniform","lightID"]
shadowcapshader <-
makeShaderUsingVAO "shadow/cap" [vert, geom] ETriangles shPosVAO
>>= addUniforms ["lightPos", "lightID"]
>>= addUniforms [ "lightID"]
-- >>= addUniforms ["lightPos"]
shadowwallshader <-
makeShaderUsingVAO "shadow/wallShadow" [vert, geom] EPoints wpVAO
>>= addUniforms ["lightPos","lightID"]
>>= addUniforms ["lightID"]
-- positional shader
positionalBlankShad <- makeShader "positional/blank" [vert, frag] [3] ETriangles
@@ -183,7 +183,8 @@ preloadRender = do
>>= addUniforms ["lightPos", "lumRad"]
shadowlightshader <-
makeShaderUsingVAO "shadow/light" [vert, frag] ETriangleStrip fsshadvao
>>= addUniforms ["lightPos", "lumRad"]
-- >>= addUniforms ["lightPos", "lumRad"]
>>= addUniforms ["lightID"]
barrelShad <- makeShader "texture/barrel" [vert, geom, frag] [2, 2, 2, 1] EPoints
-- blank wallShader
wallBlankShad <- makeShaderUsingVAO "wall/blank" [vert, geom, frag] EPoints wpColVAO
+7 -7
View File
@@ -183,7 +183,7 @@ instanceLightMap pdata lightPoints nWalls nSils nCaps toPos = do
--stencilOpSeparate Front $= (OpKeep, OpKeep, OpIncrWrap)
--stencilOpSeparate Back $= (OpKeep, OpKeep, OpDecrWrap)
glStencilOpSeparate GL_BACK GL_KEEP GL_KEEP GL_DECR_WRAP
flip VFSM.mapM_ (VFSM.fromList (zip lightPoints [(0::Int)..])) $ \((V3 x y z, rad, V3 r g b),i) -> do
flip VFSM.mapM_ (VFSM.fromList (zip lightPoints [(0::Int)..])) $ \(_,i) -> do
glDepthFunc GL_LESS
-- setup stencil
glColorMask GL_FALSE GL_FALSE GL_FALSE GL_FALSE
@@ -196,8 +196,8 @@ instanceLightMap pdata lightPoints nWalls nSils nCaps toPos = do
glUseProgram (_shadProg' lwallShad)
--uniform (_shadUnis lwallShad V.! 0)
-- $= Vector3 x y z
glUniform3f (_shadUnis' lwallShad V.! 0) x y z
glUniform1i (_shadUnis' lwallShad V.! 1) (fromIntegral i)
--glUniform3f (_shadUnis' lwallShad V.! 0) x y z
glUniform1i (_shadUnis' lwallShad V.! 0) (fromIntegral i)
--bindVertexArrayObject $= lwallShad ^? shadVAO' . vaoName -- Just (_vao $ _shadVAO lwallShad)
glBindVertexArray $ lwallShad ^. shadVAO' . vaoName -- Just (_vao $ _shadVAO lwallShad)
glDrawArrays
@@ -217,8 +217,8 @@ instanceLightMap pdata lightPoints nWalls nSils nCaps toPos = do
glEnable GL_CULL_FACE
glCullFace GL_BACK
glUseProgram (_shadProg' lcapShad)
glUniform3f (_shadUnis' lcapShad V.! 0) x y z
glUniform1i (_shadUnis' lcapShad V.! 1) (fromIntegral i)
--glUniform3f (_shadUnis' lcapShad V.! 0) x y z
glUniform1i (_shadUnis' lcapShad V.! 0) (fromIntegral i)
glBindVertexArray $ lcapShad ^. shadVAO' . vaoName --Just (_vao $ _shadVAO lcapShad)
glDrawElements
(marshalEPrimitiveMode $ _shadPrim' lcapShad)
@@ -238,8 +238,8 @@ instanceLightMap pdata lightPoints nWalls nSils nCaps toPos = do
--uniform (_shadUnis ltextShad V.! 0) $= Vector3 x y z
--uniform (_shadUnis ltextShad V.! 1) $= Vector4 r g b rad
glUseProgram (ltextShad ^. shadProg') --Just (_shadProg ltextShad)
glUniform3f (_shadUnis' ltextShad V.! 0) x y z
glUniform4f (_shadUnis' ltextShad V.! 1) r g b rad
glUniform1i (_shadUnis' ltextShad V.! 0) $ fromIntegral i
--glUniform4f (_shadUnis' ltextShad V.! 1) r g b rad
--bindVertexArrayObject $= ltextShad ^? shadVAO' . vaoName -- Just (_vao $ _shadVAO ltextShad)
glBindVertexArray $ ltextShad ^. shadVAO' . vaoName -- Just (_vao $ _shadVAO ltextShad)
glDrawArrays