feat: render and manage textures :3

This commit is contained in:
zack 2025-04-05 20:54:38 -04:00
parent 2501390225
commit 74a1be796f
No known key found for this signature in database
GPG key ID: EE8A2B709E2401D1
21 changed files with 2908 additions and 320 deletions

View file

@ -1,26 +1,38 @@
#version 450
// Matches Vertex struct attribute descriptions
// INPUTS from Vertex Buffer (matching Vertex struct)
layout(location = 0) in vec3 inPosition;
layout(location = 1) in vec3 inColor;
// layout(location = 2) in vec2 inTexCoord; // If you add texture coords
layout(location = 1) in vec3 inNormal;
layout(location = 2) in vec2 inTexCoord; // <<< MUST be vec2
// Matches UniformBufferObject struct and descriptor set layout binding
layout(binding = 0) uniform UniformBufferObject {
mat4 model;
// UNIFORMS (Set 0)
layout(set = 0, binding = 0) uniform UniformBufferObject {
mat4 view;
mat4 proj;
} ubo;
// Output to fragment shader
layout(location = 0) out vec3 fragColor;
// layout(location = 1) out vec2 fragTexCoord; // If you add texture coords
// PUSH CONSTANTS
layout(push_constant) uniform PushConstants {
mat4 model;
} pushConstants;
// OUTPUTS to Fragment Shader
layout(location = 0) out vec3 fragNormal; // Location 0 for Normal
layout(location = 1) out vec2 fragTexCoord; // Location 1 for TexCoord
void main() {
// Transform position: Model -> World -> View -> Clip space
gl_Position = ubo.proj * ubo.view * ubo.model * vec4(inPosition, 1.0);
vec4 worldPos = pushConstants.model * vec4(inPosition, 1.0);
// Pass color (and other attributes) through
fragColor = inColor;
// fragTexCoord = inTexCoord;
// Calculate final position
gl_Position = ubo.proj * ubo.view * worldPos;
// --- Pass attributes to Fragment Shader ---
// Pass world-space normal (adjust calculation if needed)
// Ensure fragNormal is assigned a vec3
fragNormal = normalize(mat3(transpose(inverse(pushConstants.model))) * inNormal);
// Pass texture coordinates (ensure inTexCoord is vec2)
// Ensure fragTexCoord is assigned a vec2
fragTexCoord = inTexCoord;
}