aboutsummaryrefslogtreecommitdiff
path: root/libs/preview_nif/data/shaders/default.vert
blob: 90cccd3d6324f9c0f8f118304a3b08e8ddfc875e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#version 120

uniform mat4 modelViewMatrix;
uniform mat4 mvpMatrix;
uniform mat3 normalMatrix;
uniform vec3 lightDirection;
uniform vec4 ambientColor;
uniform vec4 diffuseColor;

attribute vec3 position;
attribute vec3 normal;
attribute vec3 tangent;
attribute vec3 bitangent;
attribute vec2 texCoord;
attribute vec4 color;

varying vec2 TexCoord;
varying vec3 LightDir;
varying vec3 ViewDir;

varying vec3 N;
varying vec3 t;
varying vec3 b;
varying vec3 v;

varying vec4 A;
varying vec4 C;
varying vec4 D;

void main( void )
{
    gl_Position = mvpMatrix * vec4(position, 1.0);
    TexCoord = texCoord;

    N = normalize(normalMatrix * normal);
    t = normalize(normalMatrix * tangent);
    b = normalize(normalMatrix * bitangent);
    v = vec3(modelViewMatrix * vec4(position, 1.0));

    mat3 tbnMatrix = mat3(b.x, t.x, N.x,
                          b.y, t.y, N.y,
                          b.z, t.z, N.z);

    ViewDir = tbnMatrix * -v;
    LightDir = tbnMatrix * lightDirection;

    A = ambientColor;
    C = color;
    D = diffuseColor;
}