diff options
Diffstat (limited to 'examples/qt3d/advancedcustommaterial/shaders/gl3/water.vert')
-rw-r--r-- | examples/qt3d/advancedcustommaterial/shaders/gl3/water.vert | 25 |
1 files changed, 5 insertions, 20 deletions
diff --git a/examples/qt3d/advancedcustommaterial/shaders/gl3/water.vert b/examples/qt3d/advancedcustommaterial/shaders/gl3/water.vert index a4ddcf62b..3af37e9a5 100644 --- a/examples/qt3d/advancedcustommaterial/shaders/gl3/water.vert +++ b/examples/qt3d/advancedcustommaterial/shaders/gl3/water.vert @@ -6,12 +6,13 @@ in vec2 vertexTexCoord; in vec4 vertexTangent; out vec3 worldPosition; +out vec3 worldNormal; +out vec4 worldTangent; out vec2 texCoord; out vec2 movtexCoord; out vec2 multexCoord; out vec2 waveTexCoord; out vec2 skyTexCoord; -out mat3 tangentMatrix; out vec3 vpos; uniform mat4 modelMatrix; @@ -42,25 +43,9 @@ void main() // Transform position, normal, and tangent to world coords worldPosition = vec3(modelMatrix * vec4(vertexPosition, 1.0)); - vec3 normal = normalize(modelNormalMatrix * vertexNormal); - vec3 tangent = normalize(vec3(modelMatrix * vec4(vertexTangent.xyz, 0.0))); - - // Make the tangent truly orthogonal to the normal by using Gram-Schmidt. - // This allows to build the tangentMatrix below by simply transposing the - // tangent -> world space matrix (which would now be orthogonal) - tangent = normalize(tangent - dot(tangent, normal) * normal); - - // Calculate binormal vector. No "real" need to renormalize it, - // as built by crossing two normal vectors. - // To orient the binormal correctly, use the fourth coordinate of the tangent, - // which is +1 for a right hand system, and -1 for a left hand system. - vec3 binormal = cross(normal, tangent) * vertexTangent.w; - - // Construct matrix to transform from eye coords to tangent space - tangentMatrix = mat3( - tangent.x, binormal.x, normal.x, - tangent.y, binormal.y, normal.y, - tangent.z, binormal.z, normal.z); + worldNormal = normalize(modelNormalMatrix * vertexNormal); + worldTangent.xyz = normalize(vec3(modelMatrix * vec4(vertexTangent.xyz, 0.0))); + worldTangent.w = vertexTangent.w; // Calculate animated vertex positions |