GBufferWrite.frag 987 B

12345678910111213141516171819202122232425262728293031323334
  1. // ----------------------------------------------------------------
  2. // From Game Programming in C++ by Sanjay Madhav
  3. // Copyright (C) 2017 Sanjay Madhav. All rights reserved.
  4. //
  5. // Released under the BSD License
  6. // See LICENSE in root directory for full details.
  7. // ----------------------------------------------------------------
  8. // Request GLSL 3.3
  9. #version 330
  10. // Inputs from vertex shader
  11. // Tex coord
  12. in vec2 fragTexCoord;
  13. // Normal (in world space)
  14. in vec3 fragNormal;
  15. // Position (in world space)
  16. in vec3 fragWorldPos;
  17. // This corresponds to the outputs to the G-buffer
  18. layout(location = 0) out vec3 outDiffuse;
  19. layout(location = 1) out vec3 outNormal;
  20. layout(location = 2) out vec3 outWorldPos;
  21. // This is used for the texture sampling
  22. uniform sampler2D uTexture;
  23. void main()
  24. {
  25. // Diffuse color is sampled from texture
  26. outDiffuse = texture(uTexture, fragTexCoord).xyz;
  27. // Normal/world pos are passed directly along
  28. outNormal = fragNormal;
  29. outWorldPos = fragWorldPos;
  30. }