| 1 |
// Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB). |
| 2 |
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 |
|
| 4 |
attribute vec3 vertexPosition; |
| 5 |
attribute vec3 vertexNormal; |
| 6 |
attribute vec4 vertexTangent; |
| 7 |
attribute vec2 vertexTexCoord; |
| 8 |
|
| 9 |
varying vec3 worldPosition; |
| 10 |
varying vec3 worldNormal; |
| 11 |
varying vec4 worldTangent; |
| 12 |
varying vec2 texCoord; |
| 13 |
|
| 14 |
uniform mat4 modelMatrix; |
| 15 |
uniform mat3 modelNormalMatrix; |
| 16 |
uniform mat4 modelViewProjection; |
| 17 |
|
| 18 |
uniform float texCoordScale; |
| 19 |
|
| 20 |
void main() |
| 21 |
{ |
| 22 |
// Pass through texture coordinates |
| 23 |
texCoord = vertexTexCoord * texCoordScale; |
| 24 |
|
| 25 |
// Transform position, normal, and tangent to world coords |
| 26 |
worldPosition = vec3(modelMatrix * vec4(vertexPosition, 1.0)); |
| 27 |
worldNormal = normalize(modelNormalMatrix * vertexNormal); |
| 28 |
worldTangent.xyz = normalize(vec3(modelMatrix * vec4(vertexTangent.xyz, 0.0))); |
| 29 |
worldTangent.w = vertexTangent.w; |
| 30 |
|
| 31 |
// Calculate vertex position in clip coordinates |
| 32 |
gl_Position = modelViewProjection * vec4(vertexPosition, 1.0); |
| 33 |
} |