Work towards using vertex pulling for lighting caps, alignment issues

This commit is contained in:
2025-11-11 12:33:33 +00:00
parent 36d5edc0a6
commit a65a1cab93
9 changed files with 173 additions and 100 deletions
+44 -7
View File
@@ -1,11 +1,48 @@
#version 450 core
layout (location = 0) in vec4 position;
struct PosColNorm { vec4 pos; vec4 col; vec4 norm; };
layout (std140, binding = 0) uniform TheMat { mat4 theMat; } ;
uniform vec3 lightPos;
uniform vec4 lumRad;
out float drawbit;
void main()
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)
{
gl_Position = vec4(position.xyz,1);
drawbit = position.w;
// note we project to a specific height
// this is quite brittle, not ideal
vec3 dir = pos.xyz - lightPos ;
float a = (100 - pos.z) / dir.z ;
vec2 xy = (pos.xyz + a * dir).xy ;
return vec4 ( xy, 100 , 1) ;
}
vec4 tris[3] =
{vec4(0,0,0,1)
,vec4(1,1,0,1)
,vec4(0,1,0,1)
};
bool ztest (vec4 p) {return p.z - lightPos.z > 0;}
void main() {
int j = gl_VertexID/3;
int i1 = j * 3;
uint t = indices[gl_VertexID];
//uint t = gl_VertexID;
gl_Position = tris[t];
//uint t = gl_VertexID % 3;
vec4 p = data[indices[gl_VertexID]].pos;
// gl_Position = (p.w == 1
// && ztest(data[indices[i1]].pos)
// && ztest(data[indices[i1+1]].pos)
// && ztest(data[indices[i1+2]].pos)
// ? theMat * projNear(p)
// : vec4(1,1,1,0)
// );
}
//layout (location = 0) in vec4 position;
//layout (std140, binding = 0) uniform TheMat { mat4 theMat; } ;
//uniform vec3 lightPos;
//uniform vec4 lumRad;
//out float drawbit;
//void main()
//{
// gl_Position = vec4(position.xyz,1);
// drawbit = position.w;
//}
-5
View File
@@ -1,9 +1,4 @@
#version 450 core
//layout (location = 0) in vec4 poss;
//void main()
//{
// gl_Position = poss;
//}
struct PosTex { vec4 pospos; vec4 texang; };
layout (std140, binding = 0) uniform TheMat { mat4 theMat; } ;
layout (std430, binding = 2) readonly buffer Pos { PosTex data[]; };