summaryrefslogtreecommitdiff
path: root/gfx/gl/shaders/spotLight.gs
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2024-01-11 18:57:57 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2024-01-11 18:57:57 +0000
commitb6fbe0bf35bf58447f2f83f6fc519b4d3eaea107 (patch)
tree6bbaad7f0d384bab4f05080b7a65e9540cee2247 /gfx/gl/shaders/spotLight.gs
parentInitial commit with working light instancing (diff)
downloadilt-b6fbe0bf35bf58447f2f83f6fc519b4d3eaea107.tar.bz2
ilt-b6fbe0bf35bf58447f2f83f6fc519b4d3eaea107.tar.xz
ilt-b6fbe0bf35bf58447f2f83f6fc519b4d3eaea107.zip
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.
Diffstat (limited to 'gfx/gl/shaders/spotLight.gs')
-rw-r--r--gfx/gl/shaders/spotLight.gs24
1 files changed, 14 insertions, 10 deletions
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()];