From 87168d42c3c1771e0fd680620986be90f23ed7a8 Mon Sep 17 00:00:00 2001 From: admin Date: Thu, 16 Oct 2025 14:07:01 +0200 Subject: [PATCH] feat: rename shader --- src/shaders/{simple.vs => main.vs} | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) rename src/shaders/{simple.vs => main.vs} (78%) diff --git a/src/shaders/simple.vs b/src/shaders/main.vs similarity index 78% rename from src/shaders/simple.vs rename to src/shaders/main.vs index 36680ec..018c6cc 100644 --- a/src/shaders/simple.vs +++ b/src/shaders/main.vs @@ -4,6 +4,7 @@ layout (location = 0) in vec3 position; // Vertex position in local space (model space) layout (location = 1) in vec3 normal; // vertex normal layout (location = 2) in vec2 texCoord; // Vertex texture uv +layout (location = 3) in mat4 instanceModel; // Vertex texture uv // Output to fragment shader out vec3 vertexPos; @@ -15,12 +16,15 @@ out vec4 fragPosLightSpace; uniform mat4 u_model; // Model matrix: transforms from local space to world space uniform mat4 u_view; // View matrix: transforms from world space to camera space (view space) uniform mat4 u_projection; // Projection matrix: transforms from camera space to clip space +uniform bool u_isInstanced; void main() { - vertexPos = vec3(u_model * vec4(position, 1.0)); + mat4 model = u_isInstanced ? instanceModel : u_model; - mat3 normalMatrix = mat3(transpose(inverse(u_model))); + vertexPos = vec3(model * vec4(position, 1.0)); + + mat3 normalMatrix = mat3(transpose(inverse(model))); vertexNormal = normalMatrix * normal; // vertexNormal = normal;