preparing doodad rendering, rendering cubes in place, need to fix alignment rotation as it is wildy off

This commit is contained in:
Natsirt867
2026-01-06 23:13:47 -06:00
parent 84f2f7470f
commit 482f92b5c9
13 changed files with 255 additions and 37 deletions

View File

@@ -3,14 +3,21 @@ out vec4 FragColor;
in vec2 TexCoord;
in vec4 VertexColour;
uniform sampler2D texSampler;
uniform vec4 u_overrideColour;
void main() {
// sample the texture
vec4 texColor = texture(texSampler, TexCoord);
if (u_overrideColour.a > 0.0) {
FragColor = u_overrideColour;
return;
}
if (texColor.a < 0.1) discard;
// sample the texture
vec4 texColour = texture(texSampler, TexCoord) * VertexColour;
if (texColour.a < 0.1) discard;
//FragColor = vec4(0.6, 0.0, 1.0, 1.0);
FragColor = texColor * VertexColour;
FragColor = texColour;
}

View File

@@ -7,12 +7,24 @@ layout(location = 3) in vec4 vertex_colour;
out vec2 TexCoord;
out vec4 VertexColour;
uniform mat4 matrix; // must match "matrix" in C code
uniform mat4 view; // must match "view" in C code
uniform mat4 proj; // must match "proj" in C code
// TODO: change c code to match with u_<uniformName>
// also types really matter for shaders!!
uniform mat4 matrix;
uniform mat4 view;
uniform mat4 proj;
uniform vec3 u_lightDir;
uniform float u_lightInfluence; // 0.0 indoors, 1.0 outdoors
void main() {
gl_Position = proj * view * matrix * vec4(vertex_position, 1.0);
// max 0.3 so the shadowed side isn't pure black (ambient light)
float diffuse = max(dot(normalize(vertex_normal), normalize(u_lightDir)), 0.3);
float intensity = mix(1.0, diffuse, u_lightInfluence);
vec3 lighting = intensity * vertex_colour.rgb;
VertexColour = vec4(lighting, vertex_colour.a);
TexCoord = vertex_tex;
VertexColour = vertex_colour;
}