gbuffer.fs 573 B

123456789101112131415161718192021222324252627282930
  1. #version 330 core
  2. layout (location = 0) out vec3 Position;
  3. layout (location = 1) out vec3 Normal;
  4. layout (location = 2) out vec4 Colorspec;
  5. in vec3 frag;
  6. in vec3 normal;
  7. in vec2 uv;
  8. in mat3 TBN;
  9. uniform sampler2D u_texture;
  10. uniform sampler2D u_spec;
  11. uniform sampler2D u_norm;
  12. void main()
  13. {
  14. Position = frag;
  15. vec3 norm = normalize(normal);
  16. norm = texture(u_norm, uv).rgb;
  17. norm = normalize(norm * 2.0 - 1.0);
  18. norm = normalize(TBN * norm);
  19. Normal = norm * 0.5 + 0.5;
  20. Colorspec.rgb = texture(u_texture, uv).rgb;
  21. Colorspec.a = texture(u_spec, uv).r;
  22. }