16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-22 02:29:17 +02:00

Cleanup of vertex shader by @tmj.

2-channel normalmaps with Z-component reconstruction.
Normal vectors passed from fragment shaders to lightning calculations.
This commit is contained in:
stele
2019-05-03 17:32:46 +02:00
parent 158ebb9c70
commit 410e1452f6
4 changed files with 30 additions and 12 deletions

View File

@@ -8,20 +8,24 @@ flat out vec3 f_normal_raw;
out vec2 f_coord;
out vec4 f_pos;
out mat3 f_tbn;
out vec4 f_tangent;
//out vec4 f_tangent;
out vec4 f_light_pos;
out vec3 TangentFragPos;
out vec4 f_clip_pos;
out vec4 f_clip_future_pos;
//out vec3 TangentLightPos;
//out vec3 TangentViewPos;
out vec3 TangentFragPos;
#include <common>
void main()
{
f_normal = modelviewnormal * v_normal;
f_normal = normalize(modelviewnormal * v_normal);
f_normal_raw = v_normal;
f_coord = v_coord;
f_tangent = v_tangent;
// f_tangent = v_tangent;
f_pos = modelview * vec4(v_vert, 1.0f);
f_light_pos = lightview * f_pos;
@@ -32,9 +36,12 @@ void main()
gl_PointSize = param[1].x;
vec3 T = normalize(modelviewnormal * v_tangent.xyz);
vec3 B = normalize(modelviewnormal * cross(v_normal, v_tangent.xyz) * v_tangent.w);
vec3 N = normalize(modelviewnormal * v_normal);
vec3 N = f_normal;
vec3 B = normalize(cross(N, T));
f_tbn = mat3(T, B, N);
mat3 TBN = transpose(mat3(T, B, N));
mat3 TBN = transpose(f_tbn);
// TangentLightPos = TBN * f_light_pos.xyz;
// TangentViewPos = TBN * vec3(0.0f, 0.0f, 0.0f);
TangentFragPos = TBN * f_pos.xyz;
}