Implement something like deferred lighting

This commit is contained in:
2021-09-01 00:37:07 +01:00
parent 2d139adc8f
commit 1c587d4b9a
13 changed files with 90 additions and 71 deletions
+6 -6
View File
@@ -1,13 +1,13 @@
#version 430 core
in vec4 vColor;
in vec3 vPosition;
in vec4 vCol;
in vec3 vPos;
in vec3 vparams;
layout (location=0) out vec4 fColor;
layout (location=1) out vec3 fPosition;
layout (location=0) out vec4 fCol;
layout (location=1) out vec4 fPos;
void main()
{
float d = (dot(vec2(vparams.xy),vec2(vparams.xy)));
if ( d > 1 || d < vparams.z ) {discard;}
fColor = vColor;
fPosition = vPosition;
fCol = vCol;
fPos = vec4(vPos,1);
}
+7 -7
View File
@@ -1,14 +1,14 @@
#version 430 core
layout (location = 0) in vec3 position;
layout (location = 1) in vec4 color;
layout (location = 0) in vec3 pos;
layout (location = 1) in vec4 col;
layout (location = 2) in vec3 boxXboxYwidth;
layout (std140, binding = 0) uniform TheMat { mat4 theMat; } ;
out vec4 vColor;
out vec3 vPosition;
out vec4 vCol;
out vec3 vPos;
out vec3 vparams;
void main() {
gl_Position = theMat * vec4(position,1);
vColor = color;
gl_Position = theMat * vec4(pos,1);
vCol = col;
vparams = boxXboxYwidth;
vPosition = position;
vPos = pos;
}
+2 -2
View File
@@ -2,9 +2,9 @@
in vec4 vCol;
in vec3 vPos;
layout (location=0) out vec4 fCol;
layout (location=1) out vec3 fPos;
layout (location=1) out vec4 fPos;
void main()
{
fCol = vCol;
fPos = vPos;
fPos = vec4(vPos,1);
}
+7 -5
View File
@@ -1,7 +1,9 @@
#version 430 core
in vec4 vColor;
out vec4 fColor;
void main()
{
fColor = vColor;
layout (location=0) out vec4 fCol;
layout (location=1) out vec4 fPos;
in vec4 vCol;
in vec3 vPos;
void main() {
fCol = vCol;
fPos = vec4(vPos,1) ;
}
+4 -2
View File
@@ -2,11 +2,13 @@
layout (location = 0) in vec4 position;
layout (location = 1) in vec4 color;
layout (std140, binding = 0) uniform TheMat { mat4 theMat; } ;
out vec4 vColor;
out vec4 vCol;
out vec3 vPos;
void main()
{
vec4 posxy = theMat * vec4(position.xyz,1);
vec4 posz = theMat * vec4(position.xyw,1);
gl_Position = vec4(posxy.xy,posz.z,1);
vColor = color;
vCol = color;
vPos = position.xyz;
}
+4 -2
View File
@@ -3,7 +3,8 @@ in vec4 vColor;
in vec2 boxOut;
in vec2 boxIn;
out vec4 fColor;
layout (location=0) out vec4 fCol;
layout (location=1) out vec4 fPos;
void main()
{
@@ -12,5 +13,6 @@ void main()
// float e = sqrt(f(x,wStart)) + sqrt(f(y,wEnd)) - 1.0;
float e = sqrt(boxIn.x) + sqrt(boxIn.y) - 1.0;
if ( d < 0 || e > 0) { discard; }
fColor = vColor;
fCol = vColor;
fPos = vec4(0,0,0,0) ;
}
+5 -9
View File
@@ -1,15 +1,11 @@
#version 430 core
out vec4 FragColor;
layout (location=0) out vec4 fCol;
layout (location=1) out vec4 fPos;
uniform sampler2D aTexture;
in vec4 gColor;
in vec2 gTexCoord;
uniform sampler2D aTexture;
void main()
{
FragColor = texture(aTexture, vec2 (gTexCoord.x * 0.0078125, gTexCoord.y)) * gColor;
// FragColor = texture(aTexture, vTexCoord);
// FragColor = gColor;
// FragColor = vec4 (1,1,1,1);
fCol = texture(aTexture, vec2 (gTexCoord.x * 0.0078125, gTexCoord.y)) * gColor;
fPos = vec4(0,0,0,0);
}
+4 -7
View File
@@ -1,16 +1,13 @@
#version 430 core
layout (location=0) out vec4 fCol;
layout (location=1) out vec4 fPos;
in vec4 gColC;
in vec4 gColE;
in vec3 gPos;
in vec2 gBoundingBox;
layout (location=0) out vec4 fCol;
layout (location=1) out vec3 fPos;
void main()
{
void main() {
float d = dot(gBoundingBox,gBoundingBox);
if ( d > 1) { discard; }
fCol = mix (gColE , gColC, d);
fPos = vPos;
fPos = vec4(gPos,1);
}