summaryrefslogtreecommitdiffstats
path: root/src/render/shaders/gl3
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@theqtcompany.com>2015-12-06 14:27:52 +0100
committerLaszlo Agocs <laszlo.agocs@theqtcompany.com>2015-12-07 08:04:23 +0000
commit56bf0a9c8f06b6a38a35c03469b341138336c108 (patch)
tree29dad9ff745879d3565c284fb390b7e95ec3a9d4 /src/render/shaders/gl3
parente4693d6f661e41d76d615ff48d5b06630ca3413a (diff)
Use light type in the shaders
Change-Id: If57f6818fb6c40a9b88b7a2e91088e3daddb435e Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/render/shaders/gl3')
-rw-r--r--src/render/shaders/gl3/light.inc.frag18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/render/shaders/gl3/light.inc.frag b/src/render/shaders/gl3/light.inc.frag
index 235443cde..e9fcd127a 100644
--- a/src/render/shaders/gl3/light.inc.frag
+++ b/src/render/shaders/gl3/light.inc.frag
@@ -1,4 +1,7 @@
const int MAX_LIGHTS = 8;
+const int TYPE_POINT = 0;
+const int TYPE_DIRECTIONAL = 1;
+const int TYPE_SPOT = 2;
struct Light {
int type;
vec3 position;
@@ -23,14 +26,15 @@ void adsModelNormalMapped(const in vec3 vpos, const in vec3 vnormal, const in ve
int i;
vec3 s;
for (i = 0; i < lightCount; ++i) {
- s = -lights[i].direction;
float att = 1.0;
- if (length( s ) == 0.0) {
+ if ( lights[i].type != TYPE_DIRECTIONAL ) {
s = lights[i].position - vpos;
if (length( lights[i].attenuation ) != 0.0) {
float dist = length(s);
att = 1.0 / (lights[i].attenuation.x + lights[i].attenuation.y * dist + lights[i].attenuation.z * dist * dist);
}
+ } else {
+ s = -lights[i].direction;
}
s = normalize( tangentMatrix * s );
@@ -60,14 +64,15 @@ void adsModel(const in vec3 vpos, const in vec3 vnormal, const in vec3 eye, cons
int i;
vec3 s;
for (i = 0; i < lightCount; ++i) {
- s = -lights[i].direction;
float att = 1.0;
- if (length( s ) == 0.0) {
+ if ( lights[i].type != TYPE_DIRECTIONAL ) {
s = lights[i].position - vpos;
if (length( lights[i].attenuation ) != 0.0) {
float dist = length(s);
att = 1.0 / (lights[i].attenuation.x + lights[i].attenuation.y * dist + lights[i].attenuation.z * dist * dist);
}
+ } else {
+ s = -lights[i].direction;
}
s = normalize( s );
@@ -95,14 +100,15 @@ void adModel(const in vec3 vpos, const in vec3 vnormal, out vec3 diffuseColor)
int i;
vec3 s;
for (i = 0; i < lightCount; ++i) {
- s = -lights[i].direction;
float att = 1.0;
- if (length( s ) == 0.0) {
+ if ( lights[i].type != TYPE_DIRECTIONAL ) {
s = lights[i].position - vpos;
if (length( lights[i].attenuation ) != 0.0) {
float dist = length(s);
att = 1.0 / (lights[i].attenuation.x + lights[i].attenuation.y * dist + lights[i].attenuation.z * dist * dist);
}
+ } else {
+ s = -lights[i].direction;
}
s = normalize( s );