forked from GlPortal/glportal-data
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdiffuse.vert
42 lines (35 loc) · 1.12 KB
/
diffuse.vert
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
#version 130
uniform mat4 projectionMatrix;
uniform mat4 viewMatrix;
uniform mat4 modelMatrix;
uniform mat4 invViewMatrix;
uniform mat4 modelTrInv4Matrix;
uniform vec2 tiling;
in vec3 position;
in vec2 texCoord;
in vec3 normal;
in vec3 tangent;
in vec4 color;
out vec3 pass_position;
out vec2 pass_texCoord;
out vec3 pass_normal;
out vec3 pass_tangent;
out vec4 pass_color;
invariant out vec3 pass_viewerPos;
invariant out mat3 pass_surf2world;
out vec3 pass_worldPos;
void main() {
pass_position = position;
pass_texCoord = vec2(texCoord.x / tiling.x, texCoord.y / tiling.y);
pass_tangent = tangent;
pass_color = color;
vec4 worldPos = modelMatrix * vec4(position, 1);
pass_worldPos = worldPos.xyz;
mat3 modelTrInv3Matrix = mat3(modelTrInv4Matrix);
pass_surf2world[0] = normalize(vec3(modelMatrix * vec4(tangent, 0.0)));
pass_surf2world[2] = normalize(modelTrInv3Matrix * normal);
pass_surf2world[1] = normalize(cross(pass_surf2world[2], pass_surf2world[0]));
pass_normal = modelTrInv3Matrix * normal;
pass_viewerPos = (invViewMatrix * vec4(0.0, 0.0, 0.0, 1.0)).xyz;
gl_Position = projectionMatrix * viewMatrix * worldPos;
}