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