blob: a372c029ecf1389ac2821691b3b7494d9cb8f237 (
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
|
precision highp float;
uniform sampler2D NormalMap;
in vec3 Normal;
in vec4 Tangent;
in vec3 Bitangent; // TODO: Compute here or in PS?
in vec2 Texcoord;
out vec4 FragColour;
// TODO: Move to "normal.h"
vec3 get_vs_normal(vec3 normal, vec4 tangent, vec3 normalMapSample) {
vec3 N = normal;
// vec3 T = normalize(interpTangent - dot(tangent, N)*N);
// vec3 B = normalize(interpBitangent - dot(interpTangent, N)*N - dot(interpTangent, T)*T);
vec3 T = tangent.xyz;
//vec3 B = tangent.w * cross(N,T);
vec3 B = Bitangent;
vec3 n = normalMapSample;
return normalize(n.x*T + n.y*B + n.z*N);
}
void main() {
vec3 normalMapSample = texture(NormalMap, Texcoord).xyz * 2.0 - 1.0;
vec3 N = get_vs_normal(Normal, Tangent, normalMapSample);
FragColour = vec4(pow(N, vec3(1.0 / 2.2)), 1.0);
}
|