diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-01-11 18:57:57 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-01-11 18:57:57 +0000 |
commit | b6fbe0bf35bf58447f2f83f6fc519b4d3eaea107 (patch) | |
tree | 6bbaad7f0d384bab4f05080b7a65e9540cee2247 /gfx/gl/shaders/spotLight.vs | |
parent | Initial commit with working light instancing (diff) | |
download | ilt-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.vs')
-rw-r--r-- | gfx/gl/shaders/spotLight.vs | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/gfx/gl/shaders/spotLight.vs b/gfx/gl/shaders/spotLight.vs index a2b755d..8023f18 100644 --- a/gfx/gl/shaders/spotLight.vs +++ b/gfx/gl/shaders/spotLight.vs @@ -2,29 +2,29 @@ layout(location = 0) in vec3 v_position; layout(location = 1) in vec3 v_direction; -// layout(location = 2) in vec3 colour; -// layout(location = 3) in float kq; -// layout(location = 4) in float arc; +layout(location = 2) in vec3 v_colour; +layout(location = 3) in float v_kq; +layout(location = 4) in float v_arc; layout(location = 5) in mat4 model; layout(location = 9) in ivec3 modelPos; -const vec3 colour = vec3(1); -const float kq = 0.01; -const float arc = 1; - uniform ivec3 viewPoint; -out ivec3 position; -out vec3 direction; -out float size; -out float cosarc; +flat out ivec3 position; +flat out vec3 direction; +flat out float size; +flat out vec2 arc; // cos,tan (v_arc/2) +flat out vec3 colour; +flat out float kq; void main() { position = modelPos + ivec3(v_position * mat3(model)); direction = normalize(v_direction * mat3(model)); + colour = v_colour; + kq = v_kq; size = (8000 * sqrt(max(max(colour.r, colour.g), colour.b))) / sqrt(kq); - cosarc = cos(arc / 2); + arc = vec2(cos(v_arc / 2), tan(v_arc / 2)); gl_Position = vec4(position - viewPoint, 0); } |