17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-01 09:12:08 +01:00

Make the material shaders physically based

This commit is contained in:
2026-10-20 18:39:31 +02:00
parent cf36b24e8d
commit 7d0f76aaa9
20 changed files with 288 additions and 258 deletions

View File

@@ -38,9 +38,11 @@ void main()
gl_Position = f_clip_pos;
gl_PointSize = param[1].x;
vec3 T = normalize(mvn * v_tangent.xyz);
vec3 N = f_normal;
vec3 B = normalize(cross(N, T));
vec3 T = mvn * v_tangent.xyz;
T = normalize(T - N * dot(N, T));
// w is -1 where the texture is mirrored (calculate_tangents()), the bitangent turns with it
vec3 B = cross(N, T) * (v_tangent.w < 0.0 ? -1.0 : 1.0);
f_tbn = mat3(T, B, N);
mat3 TBN = transpose(f_tbn);