summaryrefslogtreecommitdiffstats
path: root/src/extras/shaders/gl3
diff options
context:
space:
mode:
authorKevin Ottens <kevin.ottens@kdab.com>2016-04-27 15:20:39 +0200
committerSean Harmer <sean.harmer@kdab.com>2016-04-28 11:29:01 +0000
commitb8f599b1062167ce07d944a1c6fb841b6f678d82 (patch)
treee2f8b8422e3c6f7eaade47eaf813cae0a17c1d89 /src/extras/shaders/gl3
parentecbf3bcfe16230067d4b752de465060fee37a653 (diff)
Repair attenuation handling
The property name changed, it used to be a single QVector3D but now it is three floats. Change-Id: I8ad7d502fdee648f5d8e8316829c9af8838dc506 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/extras/shaders/gl3')
-rw-r--r--src/extras/shaders/gl3/light.inc.frag22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/extras/shaders/gl3/light.inc.frag b/src/extras/shaders/gl3/light.inc.frag
index 8cee315c1..7ed8cfdc4 100644
--- a/src/extras/shaders/gl3/light.inc.frag
+++ b/src/extras/shaders/gl3/light.inc.frag
@@ -8,7 +8,9 @@ struct Light {
vec3 color;
float intensity;
vec3 direction;
- vec3 attenuation;
+ float constantAttenuation;
+ float linearAttenuation;
+ float quadraticAttenuation;
float cutOffAngle;
};
uniform Light lights[MAX_LIGHTS];
@@ -29,9 +31,11 @@ void adsModelNormalMapped(const in vec3 vpos, const in vec3 vnormal, const in ve
float att = 1.0;
if ( lights[i].type != TYPE_DIRECTIONAL ) {
s = tangentMatrix * ( lights[i].position - vpos );
- if (length( lights[i].attenuation ) != 0.0) {
+ if (lights[i].constantAttenuation != 0.0
+ || lights[i].linearAttenuation != 0.0
+ || lights[i].quadraticAttenuation != 0.0) {
float dist = length(s);
- att = 1.0 / (lights[i].attenuation.x + lights[i].attenuation.y * dist + lights[i].attenuation.z * dist * dist);
+ att = 1.0 / (lights[i].constantAttenuation + lights[i].linearAttenuation * dist + lights[i].quadraticAttenuation * dist * dist);
}
s = normalize( s );
if ( lights[i].type == TYPE_SPOT ) {
@@ -71,9 +75,11 @@ void adsModel(const in vec3 vpos, const in vec3 vnormal, const in vec3 eye, cons
float att = 1.0;
if ( lights[i].type != TYPE_DIRECTIONAL ) {
s = lights[i].position - vpos;
- if (length( lights[i].attenuation ) != 0.0) {
+ if (lights[i].constantAttenuation != 0.0
+ || lights[i].linearAttenuation != 0.0
+ || lights[i].quadraticAttenuation != 0.0) {
float dist = length(s);
- att = 1.0 / (lights[i].attenuation.x + lights[i].attenuation.y * dist + lights[i].attenuation.z * dist * dist);
+ att = 1.0 / (lights[i].constantAttenuation + lights[i].linearAttenuation * dist + lights[i].quadraticAttenuation * dist * dist);
}
s = normalize( s );
if ( lights[i].type == TYPE_SPOT ) {
@@ -111,9 +117,11 @@ void adModel(const in vec3 vpos, const in vec3 vnormal, out vec3 diffuseColor)
float att = 1.0;
if ( lights[i].type != TYPE_DIRECTIONAL ) {
s = lights[i].position - vpos;
- if (length( lights[i].attenuation ) != 0.0) {
+ if (lights[i].constantAttenuation != 0.0
+ || lights[i].linearAttenuation != 0.0
+ || lights[i].quadraticAttenuation != 0.0) {
float dist = length(s);
- att = 1.0 / (lights[i].attenuation.x + lights[i].attenuation.y * dist + lights[i].attenuation.z * dist * dist);
+ att = 1.0 / (lights[i].constantAttenuation + lights[i].linearAttenuation * dist + lights[i].quadraticAttenuation * dist * dist);
}
s = normalize( s );
if ( lights[i].type == TYPE_SPOT ) {