Vertex pull fullscreen lighting texture shader

This commit is contained in:
2025-11-13 10:28:34 +00:00
parent b012d3c41e
commit 8dee93991a
6 changed files with 28 additions and 21 deletions
-2
View File
@@ -4,8 +4,6 @@ layout (std140, binding = 0) uniform TheMat { mat4 theMat; } ;
layout (std140, binding = 1) uniform TheLight { vec4 lightPos; vec4 lumRad; };
layout (std430, binding = 3) readonly buffer Data { PosColNorm data[]; };
layout (std430, binding = 4) readonly buffer Indices { uint indices[]; };
//layout(location=0)uniform vec3 lightPos;
//layout(location=1)uniform vec4 lumRad;
vec4 projNear (vec4 pos)
{
// note we project to a specific height
+1
View File
@@ -57,6 +57,7 @@ void main()
// test if the edge is part of the silhouette
// that is, if the normals of the faces connected to the edge are in
// "different directions" wrt the light direction
// (first test the "drawbit")
if (p0.w==1 && dot(n0, lightDir) * dot(n1, lightDir) <= 0 &&
(dot(lightDir, lightDir) < ru2 || dot(lightDir2, lightDir2) < ru2))
// using <= rather than < seems to get rid of overlapping shadow
+7 -8
View File
@@ -1,7 +1,6 @@
#version 450 core
layout(early_fragment_tests) in;
layout(location=0)uniform vec3 lightPos;
layout(location=1)uniform vec4 lumRad;
layout (std140, binding = 1) uniform TheLight { vec4 lightPos; vec4 lumRad; };
layout (binding = 0) uniform sampler2D screenTexture;
layout (binding = 1) uniform sampler2D normals;
in vec2 vTexPos;
@@ -9,18 +8,18 @@ out vec4 fColor;
float rad = lumRad.a;
void main() {
vec3 pos = texture(screenTexture, vTexPos).xyz;
vec3 distVec = pos - lightPos;
vec3 distVec = pos - lightPos.xyz;
float dist = dot(distVec, distVec);
if (dist > rad) {
discard;
}
vec4 normbit = texture(normals, vTexPos);
vec3 norm = normbit.xyz;
// if (dist > rad) {
// discard;
// }
vec3 norm = texture(normals, vTexPos).xyz;
float y1 = dot(norm, distVec);
float y2 = float(y1 > 0 ? 1 : 0);
float x = 1 - (pow(dist / rad,4));
//float x = 1 - (dist / rad);
//float x = 1;
//float x = (dist > rad ? 0 : 1);
vec3 c = y2* x * lumRad.rgb;
fColor = vec4(c, 0);
}
+3 -4
View File
@@ -1,9 +1,8 @@
#version 450 core
layout (location = 0) in vec2 pos;
layout (location = 1) in vec2 texPos;
layout (std140, binding = 2) uniform PosTex { vec4 posTex[6]; };
out vec2 vTexPos;
void main()
{
gl_Position = vec4(pos,0,1);
vTexPos = texPos;
gl_Position = vec4(posTex[gl_VertexID].xy,0,1);
vTexPos = posTex[gl_VertexID].zw;
}