From a07d2024178106df99b82fe21a34402c5200e8f6 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 15 Apr 2023 00:21:32 +0100 Subject: Add the dynamicPoint shader for instancing Same as dynamicPoint, but the model matrix is a vertex input --- gfx/gl/shaders/dynamicPointInst.vs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 gfx/gl/shaders/dynamicPointInst.vs (limited to 'gfx/gl/shaders') diff --git a/gfx/gl/shaders/dynamicPointInst.vs b/gfx/gl/shaders/dynamicPointInst.vs new file mode 100644 index 0000000..016153a --- /dev/null +++ b/gfx/gl/shaders/dynamicPointInst.vs @@ -0,0 +1,21 @@ +#version 330 core + +include(`meshIn.glsl') +layout(location = 6) in mat4 model; +include(`materialInterface.glsl') + +uniform mat4 viewProjection; + +void +main() +{ + vec4 worldPos = model * vec4(position, 1.0); + + FragPos = worldPos.xyz; + TexCoords = texCoord; + Normal = (model * vec4(normal, 0.0)).xyz; + Colour = colour; + Material = material; + + gl_Position = viewProjection * worldPos; +} -- cgit v1.2.3 From e4414150da485a8aacdd221e23cad801f8d532c6 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Mon, 17 Apr 2023 17:04:32 +0100 Subject: Fix up the way spotlight shader works Was mostly through lack of understanding and coincidences. Position is now the only vertex data, direction is moved to a uniform. Instancing will address this by making everything instance data. --- gfx/gl/shaders/spotLight.vs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gfx/gl/shaders') diff --git a/gfx/gl/shaders/spotLight.vs b/gfx/gl/shaders/spotLight.vs index e648553..dca0854 100644 --- a/gfx/gl/shaders/spotLight.vs +++ b/gfx/gl/shaders/spotLight.vs @@ -1,8 +1,8 @@ #version 330 core layout(location = 0) in vec3 v_position; -layout(location = 1) in vec3 v_direction; +uniform vec3 v_direction; uniform vec3 colour; uniform float kq; uniform float arc; -- cgit v1.2.3 From 97cab8953bfcc8a6d4ae6e327ec57a6d70f8d7e4 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Tue, 18 Apr 2023 01:00:41 +0100 Subject: Fix location of model matrix in vertex shader --- gfx/gl/shaders/dynamicPointInst.vs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gfx/gl/shaders') diff --git a/gfx/gl/shaders/dynamicPointInst.vs b/gfx/gl/shaders/dynamicPointInst.vs index 016153a..1c66979 100644 --- a/gfx/gl/shaders/dynamicPointInst.vs +++ b/gfx/gl/shaders/dynamicPointInst.vs @@ -1,7 +1,7 @@ #version 330 core include(`meshIn.glsl') -layout(location = 6) in mat4 model; +layout(location = 5) in mat4 model; include(`materialInterface.glsl') uniform mat4 viewProjection; -- cgit v1.2.3