From b53a1285f75a6d8eda6d4e96f3d7bb3faa442962 Mon Sep 17 00:00:00 2001 From: nathan Date: Sat, 9 Aug 2025 00:27:38 -0600 Subject: Figured out the shader thingy --- assets/shaders/glsl330/instancing.vs | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'assets/shaders/glsl330') diff --git a/assets/shaders/glsl330/instancing.vs b/assets/shaders/glsl330/instancing.vs index f537278..6473ccf 100644 --- a/assets/shaders/glsl330/instancing.vs +++ b/assets/shaders/glsl330/instancing.vs @@ -1,29 +1,33 @@ -#version 330 core +#version 330 // Input vertex attributes in vec3 vertexPosition; in vec2 vertexTexCoord; +in vec3 vertexNormal; +//in vec4 vertexColor; // Not required -layout (location = 12) in mat4 instance; +in mat4 instanceTransform; // Input uniform values uniform mat4 mvp; -uniform mat4 projection; -uniform mat4 view; +uniform mat4 matNormal; // Output vertex attributes (to fragment shader) +out vec3 fragPosition; out vec2 fragTexCoord; out vec4 fragColor; out vec3 fragNormal; -// NOTE: Add here your custom variables +// NOTE: Add your custom variables here void main() { // Send vertex attributes to fragment shader + fragPosition = vec3(instanceTransform*vec4(vertexPosition, 1.0)); fragTexCoord = vertexTexCoord; + fragColor = vec4(1.0); + fragNormal = normalize(vec3(matNormal*vec4(vertexNormal, 1.0))); - // Calculate final vertex position - mat4 mvpi = mvp * instance; - gl_Position = mvpi * vec4(vertexPosition, 1.0); -} \ No newline at end of file + // Calculate final vertex position, note that we multiply mvp by instanceTransform + gl_Position = mvp*instanceTransform*vec4(vertexPosition, 1.0); +} -- cgit v1.2.3