Draw walls using vertex pulling

This commit is contained in:
2025-11-10 19:05:54 +00:00
parent 1546caa6a3
commit 1f01147821
8 changed files with 68 additions and 8 deletions
+19
View File
@@ -0,0 +1,19 @@
#version 450 core
layout (location=0) out vec4 fCol;
layout (location=1) out vec4 fPos;
layout (location=2) out vec4 fNorm;
in vec3 vTexCoords;
in vec4 vPos;
in float vAng;
layout (binding=40) uniform sampler2DArray diffuseSampler;
layout (binding=41) uniform sampler2DArray normalSampler;
vec2 rotateV2 (float a, vec2 v)
{ return vec2(v.x*cos(a) - v.y*sin(a), v.x*sin(a) + v.y*cos(a)); }
void main()
{
fCol = texture(diffuseSampler,vTexCoords);
fPos = vPos;
vec4 basenorm = texture(normalSampler,vTexCoords) - 0.5;
vec2 n1 = rotateV2(vAng,vec2(basenorm.x,basenorm.z));
fNorm = vec4(-vec3(n1,basenorm.y),0);
}
+22
View File
@@ -0,0 +1,22 @@
#version 450 core
struct PosTex { vec4 pospos; vec4 texang; };
layout (std140, binding = 0) uniform TheMat { mat4 theMat; } ;
layout (std430, binding = 2) readonly buffer Pos { PosTex data[]; };
out float vAng;
out vec4 vPos;
out vec3 vTexCoords;
int indices[6] = {0,1,3,0,3,2};
void main()
{
vec4 texang = data[gl_VertexID / 6].texang;
vec4 pp = data[gl_VertexID / 6].pospos;
int j = indices[gl_VertexID % 6];
float z = (j > 1.5 ? 100 : 0);
vec2 xy = (j % 2 > 0 ? pp.xy : pp.zw);
vPos = vec4( xy, z, 1);
gl_Position = theMat * vPos;
vAng = texang.y;
float d = distance(pp.xy,pp.zw) / 50;
int jj = j / 2;
vTexCoords = vec3(d * (j % 2), 2 * jj , texang.x);
}
+2 -1
View File
@@ -12,5 +12,6 @@ void main()
int j = indices[gl_VertexID % 6];
float z = (j > 1.5 ? 5000 : 0);
vec2 xy = (j % 2 > 0 ? pp.xy : pp.zw);
gl_Position = theMat * vec4( xy, z, 1);
vPos = vec4( xy, z, 1);
gl_Position = theMat * vPos;
}