-
Notifications
You must be signed in to change notification settings - Fork 0
/
glass.vert
58 lines (40 loc) · 1.09 KB
/
glass.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#version 130
// Glass vertex shader
//
// Author: Jietong Chen
// INCOMING DATA
// Vertex location (in model space)
in vec4 vPosition;
// Normal vector at vertex (in model space)
in vec3 vNormal;
// Model transformations
uniform mat4 modelMat;
// Viewing matrix
uniform mat4 viewMat;
// Projection matrix
uniform mat4 projectionMat;
// Normal matrix
uniform mat3 normalMat;
// Point light position (in world space)
uniform vec4 pLightPosition;
// OUTGOING DATA
// Vertex location (in camera space)
out vec3 position;
// Normal vector at vertex (in camera space)
out vec3 normal;
// Point light position (in camera space)
out vec3 pLightPos;
//
// Main function
//
void main()
{
// convert the vertex location into camera space
position = ( viewMat * modelMat * vPosition ).xyz;
// convert the normal vector into camera space
normal = normalMat * vNormal;
// convert the point light position into camera space
pLightPos = ( viewMat * pLightPosition ).xyz;
// Transform the vertex location into clip space
gl_Position = projectionMat * viewMat * modelMat * vPosition;
}