summaryrefslogtreecommitdiffstats
path: root/src/extras/shaders/gl3
diff options
context:
space:
mode:
authorKevin Ottens <kevin.ottens@kdab.com>2017-02-23 16:14:21 +0100
committerSean Harmer <sean.harmer@kdab.com>2017-02-24 16:59:10 +0000
commit271ff077ed2235eee149f23f157d8e17d058af4b (patch)
tree5d4c613313cd5411f00c0062d43f06810e6a118f /src/extras/shaders/gl3
parent98baac15388b536b5108cccc0cf3311c4d9d048c (diff)
MetalRough: Don't call pbrIblModel if we have no env light
Change-Id: I4a09a4a8768c6d5db640b5482ea41601961006fe Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/extras/shaders/gl3')
-rw-r--r--src/extras/shaders/gl3/light.inc.frag1
-rw-r--r--src/extras/shaders/gl3/metalrough.frag14
-rw-r--r--src/extras/shaders/gl3/metalroughuniform.frag12
3 files changed, 16 insertions, 11 deletions
diff --git a/src/extras/shaders/gl3/light.inc.frag b/src/extras/shaders/gl3/light.inc.frag
index aaec83840..ce5c581cf 100644
--- a/src/extras/shaders/gl3/light.inc.frag
+++ b/src/extras/shaders/gl3/light.inc.frag
@@ -22,6 +22,7 @@ struct EnvironmentLight {
samplerCube specular; // For specular contribution
};
uniform EnvironmentLight envLight;
+uniform int envLightCount = 0;
void adsModelNormalMapped(const in vec3 worldPos,
const in vec3 tsNormal,
diff --git a/src/extras/shaders/gl3/metalrough.frag b/src/extras/shaders/gl3/metalrough.frag
index 4712e7cd8..225541775 100644
--- a/src/extras/shaders/gl3/metalrough.frag
+++ b/src/extras/shaders/gl3/metalrough.frag
@@ -317,12 +317,14 @@ void main()
vec3 tNormal = 2.0 * texture(normalMap, texCoord).rgb - vec3(1.0);
vec3 wNormal = normalize(transpose(worldToTangentMatrix) * tNormal);
- cLinear += pbrIblModel(wNormal,
- wView,
- baseColor,
- metalness,
- roughness,
- ambientOcclusion);
+ for (int i = 0; i < envLightCount; ++i) {
+ cLinear += pbrIblModel(wNormal,
+ wView,
+ baseColor,
+ metalness,
+ roughness,
+ ambientOcclusion);
+ }
for (int i = 0; i < lightCount; ++i) {
cLinear += pbrModel(i,
diff --git a/src/extras/shaders/gl3/metalroughuniform.frag b/src/extras/shaders/gl3/metalroughuniform.frag
index 8be76e9c2..a851c957c 100644
--- a/src/extras/shaders/gl3/metalroughuniform.frag
+++ b/src/extras/shaders/gl3/metalroughuniform.frag
@@ -288,11 +288,13 @@ void main()
vec3 cLinear = vec3(0.0);
vec3 worldView = normalize(eyePosition - worldPosition);
- cLinear += pbrIblModel(worldNormal,
- worldView,
- baseColor.rgb,
- metalness,
- roughness);
+ for (int i = 0; i < envLightCount; ++i) {
+ cLinear += pbrIblModel(worldNormal,
+ worldView,
+ baseColor.rgb,
+ metalness,
+ roughness);
+ }
for (int i = 0; i < lightCount; ++i) {
cLinear += pbrModel(i,