diff options
author | Michael Brasser <mbrasser@ford.com> | 2019-03-05 13:54:04 -0600 |
---|---|---|
committer | Michael Brasser <michael.brasser@live.com> | 2019-03-06 15:33:35 +0000 |
commit | f72c8abf5f9844214aab9b587bdd7e6921a3e272 (patch) | |
tree | 09f1c13ee9fe2ce65af22c44e5779dc8d98a9ccd | |
parent | 22c66fa9f7a460f077fede22f285c84276ce3883 (diff) |
Fix light attenuation for ES 2
These shaders were never updated to be in sync with the renames
made for Qt 5.7+.
Change-Id: I95c64c150e0c4060374467942a2973b7687a88ca
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
-rw-r--r-- | src/extras/shaders/es2/light.inc.frag | 4 | ||||
-rw-r--r-- | src/extras/shaders/es2/light.inc.frag100 | 4 | ||||
-rw-r--r-- | src/extras/shaders/es2/phong.inc.frag | 6 | ||||
-rw-r--r-- | src/extras/shaders/es2/phong.inc.frag100 | 12 |
4 files changed, 18 insertions, 8 deletions
diff --git a/src/extras/shaders/es2/light.inc.frag b/src/extras/shaders/es2/light.inc.frag index 167ff306e..465138971 100644 --- a/src/extras/shaders/es2/light.inc.frag +++ b/src/extras/shaders/es2/light.inc.frag @@ -10,7 +10,9 @@ struct Light { FP vec3 color; FP float intensity; FP vec3 direction; - FP vec3 attenuation; + FP float constantAttenuation; + FP float linearAttenuation; + FP float quadraticAttenuation; FP float cutOffAngle; }; uniform Light lights[MAX_LIGHTS]; diff --git a/src/extras/shaders/es2/light.inc.frag100 b/src/extras/shaders/es2/light.inc.frag100 index 8680ee423..0b792b98e 100644 --- a/src/extras/shaders/es2/light.inc.frag100 +++ b/src/extras/shaders/es2/light.inc.frag100 @@ -10,7 +10,9 @@ struct Light { FP vec3 color; FP float intensity; FP vec3 direction; - FP vec3 attenuation; + FP float constantAttenuation; + FP float linearAttenuation; + FP float quadraticAttenuation; FP float cutOffAngle; }; uniform Light lights[MAX_LIGHTS]; diff --git a/src/extras/shaders/es2/phong.inc.frag b/src/extras/shaders/es2/phong.inc.frag index 9d17b68b5..a68e8124c 100644 --- a/src/extras/shaders/es2/phong.inc.frag +++ b/src/extras/shaders/es2/phong.inc.frag @@ -81,9 +81,11 @@ void adsModel(const in FP vec3 vpos, const in FP vec3 vnormal, const in FP vec3 FP float att = 1.0; if ( light.type != TYPE_DIRECTIONAL ) { s = light.position - vpos; - if (length( light.attenuation ) != 0.0) { + if (light.constantAttenuation != 0.0 + || light.linearAttenuation != 0.0 + || light.quadraticAttenuation != 0.0) { FP float dist = length(s); - att = 1.0 / (light.attenuation.x + light.attenuation.y * dist + light.attenuation.z * dist * dist); + att = 1.0 / (light.constantAttenuation + light.linearAttenuation * dist + light.quadraticAttenuation * dist * dist); } s = normalize( s ); if ( light.type == TYPE_SPOT ) { diff --git a/src/extras/shaders/es2/phong.inc.frag100 b/src/extras/shaders/es2/phong.inc.frag100 index 507d8eaf5..0c326d0b6 100644 --- a/src/extras/shaders/es2/phong.inc.frag100 +++ b/src/extras/shaders/es2/phong.inc.frag100 @@ -65,9 +65,11 @@ void adsModel(const in FP vec3 vpos, const in FP vec3 vnormal, const in FP vec3 FP float att = 1.0; if ( lights[0].type != TYPE_DIRECTIONAL ) { s = lights[0].position - vpos; - if (length( lights[0].attenuation ) != 0.0) { + if (lights[0].constantAttenuation != 0.0 + || light[0].linearAttenuation != 0.0 + || light[0].quadraticAttenuation != 0.0) { FP float dist = length(s); - att = 1.0 / (lights[0].attenuation.x + lights[0].attenuation.y * dist + lights[0].attenuation.z * dist * dist); + att = 1.0 / (lights[0].constantAttenuation + lights[0].linearAttenuation * dist + lights[0].quadraticAttenuation * dist * dist); } s = normalize( s ); if ( lights[0].type == TYPE_SPOT ) { @@ -96,9 +98,11 @@ void adsModel(const in FP vec3 vpos, const in FP vec3 vnormal, const in FP vec3 att = 1.0; if ( lights[1].type != TYPE_DIRECTIONAL ) { s = lights[1].position - vpos; - if (length( lights[1].attenuation ) != 0.0) { + if (lights[1].constantAttenuation != 0.0 + || light[1].linearAttenuation != 0.0 + || light[1].quadraticAttenuation != 0.0) { FP float dist = length(s); - att = 1.0 / (lights[1].attenuation.x + lights[1].attenuation.y * dist + lights[1].attenuation.z * dist * dist); + att = 1.0 / (lights[1].constantAttenuation + lights[1].linearAttenuation * dist + lights[1].quadraticAttenuation * dist * dist); } s = normalize( s ); if ( lights[1].type == TYPE_SPOT ) { |