From b8401062e1d3f5e6554ab7fd9b983ea63cfb05c5 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Wed, 10 Jan 2024 19:04:30 +0000 Subject: Initial commit with working light instancing --- gfx/gl/shaders/spotLight.gs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'gfx/gl/shaders/spotLight.gs') diff --git a/gfx/gl/shaders/spotLight.gs b/gfx/gl/shaders/spotLight.gs index b58c169..a2805fe 100644 --- a/gfx/gl/shaders/spotLight.gs +++ b/gfx/gl/shaders/spotLight.gs @@ -11,9 +11,9 @@ const vec3[] pyramid = vec3[]( // four-sided ); uniform mat4 viewProjection; uniform ivec3 viewPoint; -uniform float arc; - -in vec3 position[]; +// uniform float arc; +const float arc = 1; +in ivec3 position[]; in vec3 direction[]; in float size[]; in float cosarc[]; -- cgit v1.2.3 From b6fbe0bf35bf58447f2f83f6fc519b4d3eaea107 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Thu, 11 Jan 2024 18:57:57 +0000 Subject: Full implementation passing through light defs from vertex data Note: there is a bug where the light position/direction are rotated backwards to the model even though its using the model's rotation matrix... no idea why/how. --- gfx/gl/shaders/spotLight.gs | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'gfx/gl/shaders/spotLight.gs') diff --git a/gfx/gl/shaders/spotLight.gs b/gfx/gl/shaders/spotLight.gs index a2805fe..194812a 100644 --- a/gfx/gl/shaders/spotLight.gs +++ b/gfx/gl/shaders/spotLight.gs @@ -11,17 +11,19 @@ const vec3[] pyramid = vec3[]( // four-sided ); uniform mat4 viewProjection; uniform ivec3 viewPoint; -// uniform float arc; -const float arc = 1; -in ivec3 position[]; -in vec3 direction[]; -in float size[]; -in float cosarc[]; +flat in ivec3 position[]; +flat in vec3 direction[]; +flat in vec3 colour[]; +flat in float size[]; +flat in float kq[]; +flat in vec2 arc[]; layout(points) in; layout(triangle_strip, max_vertices = 8) out; -out vec4 geo_centre; -out vec4 geo_direction; +flat out vec4 geo_centre; +flat out vec4 geo_direction; +flat out vec3 geo_colour; +flat out float geo_kq; vec3 perp(vec3 a) @@ -36,14 +38,16 @@ doVertex(vec4 ndcpos) { gl_Position = ndcpos; geo_centre = vec4(position[0], size[0]); - geo_direction = vec4(direction[0], cosarc[0]); + geo_direction = vec4(direction[0], arc[0].x); + geo_colour = colour[0]; + geo_kq = kq[0]; EmitVertex(); } void main() { - const float base = size[0] * tan(arc / 2); + const float base = size[0] * arc[0].y; const vec3 offx = perp(direction[0]); const vec3 offy = cross(direction[0], offx); vec4 out_py[pyramid.length()]; -- cgit v1.2.3