-
-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathmdl.vert
More file actions
34 lines (28 loc) · 766 Bytes
/
mdl.vert
File metadata and controls
34 lines (28 loc) · 766 Bytes
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
#version 150 core
attribute vec3 vPos;
attribute vec3 vNormal;
attribute vec2 vUV;
uniform mat4 uMVP;
uniform mat4 uMV;
uniform mat3 uNormalMatrix;
uniform vec3 uEyePosition;
out vec3 fNormal;
out float fDepth;
out vec2 fUVMesh;
out vec2 fUVMatCap;
void main() {
vec4 position = uMVP * vec4(vPos, 1.0);
gl_Position = position;
fNormal = vNormal;
fUVMesh = vUV;
// https://www.clicktorelease.com/blog/creating-spherical-environment-mapping-shader
vec4 eyePos = vec4(uEyePosition, 1.0);
vec3 e = normalize(vec3(uMV * eyePos));
vec3 n = normalize(uNormalMatrix * vNormal);
vec3 r = reflect(e, n);
r.z += 1.0;
float m = 2.0 * length(r);
fUVMatCap = r.xy / m + 0.5;
// Unused right now
fDepth = position.w;
}