Deferred.vert 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #include "Uniforms.vert"
  2. #include "Transform.vert"
  3. #include "Lighting.vert"
  4. varying vec2 vTexCoord;
  5. #ifdef VERTEXCOLOR
  6. varying vec4 vColor;
  7. #endif
  8. varying vec4 vVertexLighting;
  9. varying vec3 vNormal;
  10. #ifdef NORMALMAP
  11. varying vec3 vTangent;
  12. varying vec3 vBitangent;
  13. #endif
  14. void main()
  15. {
  16. mat4 modelMatrix = iModelMatrix;
  17. vec3 worldPos = GetWorldPos(modelMatrix);
  18. gl_Position = GetClipPos(worldPos);
  19. vTexCoord = GetTexCoord(iTexCoord);
  20. vNormal = GetWorldNormal(modelMatrix);
  21. #ifdef NORMALMAP
  22. vTangent = GetWorldTangent(modelMatrix);
  23. vBitangent = cross(vTangent, vNormal) * iTangent.w;
  24. #endif
  25. vVertexLighting = vec4(GetAmbient(GetZonePos(worldPos)), GetDepth(gl_Position));
  26. #ifdef NUMVERTEXLIGHTS
  27. vec3 normal = GetWorldNormal(modelMatrix);
  28. for (int i = 0; i < NUMVERTEXLIGHTS; ++i)
  29. vVertexLighting.rgb += GetVertexLight(i, worldPos, normal) * cVertexLights[i * 3].rgb;
  30. #endif
  31. #ifdef VERTEXCOLOR
  32. vColor = iColor;
  33. #endif
  34. }