diff options
Diffstat (limited to 'examples/qt3d/advancedcustommaterial/shaders/es2/water.frag')
-rw-r--r-- | examples/qt3d/advancedcustommaterial/shaders/es2/water.frag | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/examples/qt3d/advancedcustommaterial/shaders/es2/water.frag b/examples/qt3d/advancedcustommaterial/shaders/es2/water.frag index ea54a87f1..4a417ab34 100644 --- a/examples/qt3d/advancedcustommaterial/shaders/es2/water.frag +++ b/examples/qt3d/advancedcustommaterial/shaders/es2/water.frag @@ -1,6 +1,8 @@ #define FP highp varying FP vec3 worldPosition; +varying FP vec3 worldNormal; +varying FP vec4 worldTangent; varying FP vec2 texCoord; varying FP vec2 waveTexCoord; varying FP vec2 movtexCoord; @@ -9,7 +11,6 @@ varying FP vec2 skyTexCoord; varying FP vec3 vpos; -varying FP mat3 tangentMatrix; varying FP vec3 color; uniform FP sampler2D diffuseTexture; @@ -30,6 +31,7 @@ uniform FP float normalAmount; uniform FP vec3 eyePosition; #pragma include light.inc.frag +#pragma include coordinatesystems.inc void main() { @@ -50,16 +52,20 @@ void main() // 2 Animated Layers of specularTexture mixed with the newCoord FP vec4 specularTextureColor = texture2D( specularTexture, multexCoord+newCoord) + (texture2D( specularTexture, movtexCoord+newCoord )); // 2 Animated Layers of normalTexture mixed with the newCoord - FP vec3 normal = normalAmount * texture2D( normalTexture, movtexCoord+newCoord ).rgb - vec3( 1.0 )+(normalAmount * texture2D( normalTexture, multexCoord+newCoord ).rgb - vec3( 1.0 )); + FP vec3 tNormal = normalAmount * texture2D( normalTexture, movtexCoord+newCoord ).rgb - vec3( 1.0 )+(normalAmount * texture2D( normalTexture, multexCoord+newCoord ).rgb - vec3( 1.0 )); // Animated skyTexture layer FP vec4 skycolor = texture2D(skyTexture, skyTexCoord); skycolor = skycolor * 0.4; //Animated foamTexture layer FP vec4 foamTextureColor = texture2D(foamTexture, texCoord); + 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; - adsModelNormalMapped(worldPosition, normal, eyePosition, shininess, tangentMatrix, 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 ); |