summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Blechmann <tim@klingt.org>2016-09-25 14:18:37 +0800
committerTim Blechmann <tim@klingt.org>2016-10-04 04:08:48 +0000
commite6103652f4664e448383fbbafb9d47dfedca4227 (patch)
tree72838e07f7b9fbc4fddae152f042b17ec1485729
parent7e638edbd15640302516f9a69d20f62d26d4af06 (diff)
Fix initialization of loop variables in lighting shaders
The variables have to be declared in the for loop to be compliant with OpenGL ES 2.0. The OpenGL 3 shader is cleaned up as well, to keep the code similar. Change-Id: I9127e9e536e4ec9036e078aaf99955113e81878f Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com> Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
-rw-r--r--src/extras/shaders/es2/light.inc.frag9
-rw-r--r--src/extras/shaders/gl3/gooch.frag3
2 files changed, 4 insertions, 8 deletions
diff --git a/src/extras/shaders/es2/light.inc.frag b/src/extras/shaders/es2/light.inc.frag
index 42a25003d..02660f008 100644
--- a/src/extras/shaders/es2/light.inc.frag
+++ b/src/extras/shaders/es2/light.inc.frag
@@ -25,9 +25,8 @@ void adsModelNormalMapped(const in FP vec3 vpos, const in FP vec3 vnormal, const
FP vec3 n = normalize( vnormal );
- int i;
FP vec3 s, ts;
- for (i = 0; i < lightCount; ++i) {
+ for (int i = 0; i < lightCount; ++i) {
FP float att = 1.0;
if ( lights[i].type != TYPE_DIRECTIONAL ) {
s = lights[i].position - vpos;
@@ -75,9 +74,8 @@ void adsModel(const in FP vec3 vpos, const in FP vec3 vnormal, const in FP vec3
FP vec3 n = normalize( vnormal );
- int i;
FP vec3 s;
- for (i = 0; i < lightCount; ++i) {
+ for (int i = 0; i < lightCount; ++i) {
FP float att = 1.0;
if ( lights[i].type != TYPE_DIRECTIONAL ) {
s = lights[i].position - vpos;
@@ -115,9 +113,8 @@ void adModel(const in FP vec3 vpos, const in FP vec3 vnormal, out FP vec3 diffus
FP vec3 n = normalize( vnormal );
- int i;
FP vec3 s;
- for (i = 0; i < lightCount; ++i) {
+ for (int i = 0; i < lightCount; ++i) {
FP float att = 1.0;
if ( lights[i].type != TYPE_DIRECTIONAL ) {
s = lights[i].position - vpos;
diff --git a/src/extras/shaders/gl3/gooch.frag b/src/extras/shaders/gl3/gooch.frag
index 1beab1c01..168a862f8 100644
--- a/src/extras/shaders/gl3/gooch.frag
+++ b/src/extras/shaders/gl3/gooch.frag
@@ -28,8 +28,7 @@ vec3 goochModel( const in vec3 pos, const in vec3 n )
vec3 kwarm = clamp(kyellow + beta * kd, 0.0, 1.0);
vec3 result = vec3(0.0);
- int i;
- for (i = 0; i < lightCount; ++i) {
+ for (int i = 0; i < lightCount; ++i) {
// Calculate the vector from the light to the fragment
vec3 s = normalize( vec3( lights[i].position ) - pos );