From fb0c9421b1e172833f3ac2166b9a39bd83a8b6ef Mon Sep 17 00:00:00 2001 From: Kevin Ottens Date: Wed, 2 Aug 2017 16:31:06 +0200 Subject: Wrap adsModel into phongFunction This way the use is more similar to the one for metal/rough. Change-Id: I143df910f43e29ef622f24bd97a23c90a2c8ef68 Reviewed-by: Sean Harmer --- .../qt3d/advancedcustommaterial/shaders/es2/water.frag | 16 +++++++--------- .../qt3d/advancedcustommaterial/shaders/gl3/water.frag | 15 ++++++--------- 2 files changed, 13 insertions(+), 18 deletions(-) (limited to 'examples/qt3d/advancedcustommaterial') 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); -- cgit v1.2.3