fix: shader load fail

This commit is contained in:
2026-04-16 13:06:49 +08:00
parent ecc1595a39
commit 42b5661a28
11 changed files with 3 additions and 2 deletions

View File

@@ -0,0 +1,12 @@
#version 460
in vec2 tc;
flat in int tex_layer;
out vec4 color;
layout (binding = 0) uniform sampler2DArray samp;
void main(void) {
color = texture(samp, vec3(tc, tex_layer));
//color = varyingColor;
}

View File

@@ -0,0 +1,63 @@
#version 460
layout (location = 0) in vec3 pos;
layout (location = 1) in vec2 texCoord;
layout (location = 2) in float layer;
out vec2 tc;
flat out int tex_layer;
mat4 buildRotateX(float rad);
mat4 buildRotateY(float rad);
mat4 buildRotateZ(float rad);
mat4 buildTranslate(float x, float y, float z);
uniform mat4 mv_matrix;
uniform mat4 proj_matrix;
void main(void) {
gl_Position = proj_matrix * mv_matrix * vec4(pos, 1.0);
tc = texCoord;
tex_layer = int(layer);
}
mat4 buildTranslate(float x, float y, float z) {
mat4 trans = mat4(
1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
x, y, z, 1.0
);
return trans;
}
mat4 buildRotateX(float rad) {
mat4 xrot = mat4(
1.0, 0.0, 0.0, 0.0,
0.0, cos(rad), -sin(rad), 0.0,
0.0, sin(rad), cos(rad), 0.0,
0.0, 0.0, 0.0, 1.0
);
return xrot;
}
mat4 buildRotateY(float rad) {
mat4 yrot = mat4(
cos(rad), 0.0, sin(rad), 0.0,
0.0, 1.0, 0.0, 0.0,
-sin(rad), 0.0, cos(rad), 0.0,
0.0, 0.0, 0.0, 1.0
);
return yrot;
}
mat4 buildRotateZ(float rad) {
mat4 zrot = mat4(
cos(rad), -sin(rad), 0.0, 0.0,
sin(rad), cos(rad), 0.0, 0.0,
0.0, 0.0,1.0 , 0.0,
0.0, 0.0, 0.0, 1.0
);
return zrot;
}

View File

@@ -0,0 +1,7 @@
#version 460
out vec4 frag_color;
void main(void) {
frag_color = vec4(0.0, 0.0, 0.0, 1.0);
}

View File

@@ -0,0 +1,10 @@
#version 460
layout (location = 0) in vec3 vertices_pos;
uniform mat4 mv_matrix;
uniform mat4 proj_matrix;
void main(void) {
gl_Position = proj_matrix * mv_matrix * vec4(vertices_pos, 1.0);
}

View File

@@ -0,0 +1,9 @@
#version 460
out vec4 frag_color;
void main(void) {
frag_color = vec4(0.529, 0.808, 0.922, 1.0);
}

View File

@@ -0,0 +1,10 @@
#version 460
layout (location = 0) in vec3 vertices_pos;
uniform mat4 mv_matrix;
uniform mat4 proj_matrix;
void main(void) {
gl_Position = proj_matrix * mv_matrix * vec4(vertices_pos, 1.0);
}

View File

@@ -0,0 +1,14 @@
#version 460
in vec2 tc;
flat in int tex_layer;
layout (binding = 0) uniform sampler2DArray text;
uniform vec3 textColor;
out vec4 color;
void main(void) {
vec4 smapled = vec4(1.0, 1.0, 1.0, texture(text, vec3(tc, tex_layer)).r);
color = vec4(textColor, 1.0) * smapled;
}

View File

@@ -0,0 +1,15 @@
#version 460
layout (location = 0) in vec2 pos;
layout (location = 1) in vec2 texCoord;
layout (location = 2) in float layer;
out vec2 tc;
flat out int tex_layer;
uniform mat4 projection;
uniform mat4 mv_matrix;
void main(void) {
gl_Position = projection * mv_matrix * vec4(pos, 0.0, 1.0);
tc = texCoord;
tex_layer = int(layer);
}

View File

@@ -0,0 +1,12 @@
#version 460
in vec2 tc;
flat in int tex_layer;
out vec4 color;
layout (binding = 0) uniform sampler2DArray samp;
void main(void) {
color = texture(samp, vec3(tc, tex_layer));
}

View File

@@ -0,0 +1,18 @@
#version 460
layout (location = 0) in vec2 pos;
layout (location = 1) in vec2 texCoord;
layout (location = 2) in float layer;
out vec2 tc;
flat out int tex_layer;
uniform mat4 m_matrix;
uniform mat4 proj_matrix;
void main(void) {
gl_Position = proj_matrix * m_matrix * vec4(pos, 0.0, 1.0);
tc = texCoord;
tex_layer = int(layer);
}