summaryrefslogtreecommitdiffstats
path: root/examples/qt3d/advancedcustommaterial
diff options
context:
space:
mode:
authorKevin Ottens <kevin.ottens@kdab.com>2017-08-02 16:31:06 +0200
committerKevin Ottens <kevin.ottens@kdab.com>2017-09-25 13:43:37 +0000
commitfb0c9421b1e172833f3ac2166b9a39bd83a8b6ef (patch)
tree598cdf643af1aa489529b2baeca4acc555eafbbf /examples/qt3d/advancedcustommaterial
parentbae599898a8a6c49df2e4141b7f3750efa40da50 (diff)
Wrap adsModel into phongFunction
This way the use is more similar to the one for metal/rough. Change-Id: I143df910f43e29ef622f24bd97a23c90a2c8ef68 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'examples/qt3d/advancedcustommaterial')
-rw-r--r--examples/qt3d/advancedcustommaterial/shaders/es2/water.frag16
-rw-r--r--examples/qt3d/advancedcustommaterial/shaders/gl3/water.frag15
2 files changed, 13 insertions, 18 deletions
diff --git a/examples/qt3d/advancedcustommaterial/shaders/es2/water.frag b/examples/qt3d/advancedcustommaterial/shaders/es2/water.frag
index 4a417ab34..dfd2650bd 100644
--- a/examples/qt3d/advancedcustommaterial/shaders/es2/water.frag
+++ b/examples/qt3d/advancedcustommaterial/shaders/es2/water.frag
@@ -24,8 +24,7 @@ uniform FP float offsetx;
uniform FP float offsety;
uniform FP float specularity;
uniform FP float waveStrenght;
-uniform FP vec3 ka;
-uniform FP vec3 specularColor;
+uniform FP vec4 ka;
uniform FP float shininess;
uniform FP float normalAmount;
uniform FP vec3 eyePosition;
@@ -61,16 +60,15 @@ void main()
FP mat3 tangentMatrix = calcWorldSpaceToTangentSpaceMatrix(worldNormal, worldTangent);
FP mat3 invertTangentMatrix = transpose(tangentMatrix);
- FP vec3 wNormal = normalize(invertTangentMatrix * tNormal);
-
- // Calculate the lighting model, keeping the specular component separate
- FP vec3 diffuseColor, specularColor;
- adsModel(worldPosition, wNormal, eyePosition, shininess, diffuseColor, specularColor);
- // Combine final fragment color
- FP vec4 outputColor = vec4(((skycolor.rgb + ka + diffuseTextureColor.rgb * (diffuseColor))+(specularColor * specularTextureColor.a*specularity)), vpos.y );
+ FP vec3 wNormal = normalize(invertTangentMatrix * tNormal);
+ FP vec3 worldView = normalize(eyePosition - worldPosition);
+ FP vec4 diffuse = vec4(diffuseTextureColor.rgb, vpos.y);
+ FP vec4 specular = vec4(specularTextureColor.a*specularity);
+ FP vec4 outputColor = phongFunction(ka, diffuse, specular, shininess, worldPosition, worldView, wNormal);
+ outputColor += vec4(skycolor.rgb, vpos.y);
outputColor += (foamTextureColor.rgba*vpos.y);
gl_FragColor = vec4(outputColor.rgb,1.0);
diff --git a/examples/qt3d/advancedcustommaterial/shaders/gl3/water.frag b/examples/qt3d/advancedcustommaterial/shaders/gl3/water.frag
index de6e87281..49d57fcaf 100644
--- a/examples/qt3d/advancedcustommaterial/shaders/gl3/water.frag
+++ b/examples/qt3d/advancedcustommaterial/shaders/gl3/water.frag
@@ -24,7 +24,7 @@ uniform float offsetx;
uniform float offsety;
uniform float specularity;
uniform float waveStrenght;
-uniform vec3 ka;
+uniform vec4 ka;
uniform vec3 specularColor;
uniform float shininess;
uniform float normalAmount;
@@ -65,16 +65,13 @@ void main()
mat3 invertTangentMatrix = transpose(tangentMatrix);
vec3 wNormal = normalize(invertTangentMatrix * tNormal);
+ vec3 worldView = normalize(eyePosition - worldPosition);
+ vec4 diffuse = vec4(diffuseTextureColor.rgb, vpos.y);
+ vec4 specular = vec4(specularTextureColor.a*specularity);
+ vec4 outputColor = phongFunction(ka, diffuse, specular, shininess, worldPosition, worldView, wNormal);
- // Calculate the lighting model, keeping the specular component separate
- vec3 diffuseColor, specularColor;
- adsModel(worldPosition, wNormal, eyePosition, shininess, diffuseColor, specularColor);
-
- // Combine final fragment color
- vec4 outputColor = vec4(((skycolor.rgb + ka + diffuseTextureColor.rgb * (diffuseColor))+(specularColor * specularTextureColor.a*specularity)), vpos.y );
-
-
+ outputColor += vec4(skycolor.rgb, vpos.y);
outputColor += (foamTextureColor.rgba*vpos.y);
fragColor = vec4(outputColor.rgb,1.0);