diff options
author | Paul Lemire <paul.lemire@kdab.com> | 2016-04-11 14:58:17 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2016-04-23 11:14:30 +0000 |
commit | 0542f1614aa6d50c4c9809fb0ce5f1adb5666d67 (patch) | |
tree | 77a1ed41c16262f5cc7aa9ddb2d66d3f9b61a719 /src/extras/shaders/es2/normaldiffusemap.frag | |
parent | 8677f62fa690efa29fbb6f870af1ea2b4e7111cf (diff) |
Move defaults and geometries out of Qt3DRender and into Qt3DExtras
QBoundingVolumeDebug has been disabled for now. Will be re-enabled later on.
Change-Id: Id6b0abab2ec2aa697330bd20d782f9d104d25d50
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/extras/shaders/es2/normaldiffusemap.frag')
-rw-r--r-- | src/extras/shaders/es2/normaldiffusemap.frag | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/extras/shaders/es2/normaldiffusemap.frag b/src/extras/shaders/es2/normaldiffusemap.frag new file mode 100644 index 000000000..c69aa8b81 --- /dev/null +++ b/src/extras/shaders/es2/normaldiffusemap.frag @@ -0,0 +1,31 @@ +#define FP highp + +varying FP vec3 worldPosition; +varying FP vec2 texCoord; +varying FP mat3 tangentMatrix; + +uniform sampler2D diffuseTexture; +uniform sampler2D normalTexture; + +// TODO: Replace with a struct +uniform FP vec3 ka; // Ambient reflectivity +uniform FP vec3 ks; // Specular reflectivity +uniform FP float shininess; // Specular shininess factor + +uniform FP vec3 eyePosition; + +#pragma include light.inc.frag + +void main() +{ + // Sample the textures at the interpolated texCoords + FP vec4 diffuseTextureColor = texture2D( diffuseTexture, texCoord ); + FP vec3 normal = 2.0 * texture2D( normalTexture, texCoord ).rgb - vec3( 1.0 ); + + // Calculate the lighting model, keeping the specular component separate + FP vec3 diffuseColor, specularColor; + adsModelNormalMapped(worldPosition, normal, eyePosition, shininess, tangentMatrix, diffuseColor, specularColor); + + // Combine spec with ambient+diffuse for final fragment color + gl_FragColor = vec4( ka + diffuseTextureColor.rgb * diffuseColor + ks * specularColor, 1.0 ); +} |