general-vs.chunk 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. precision highp float;
  2. #include <legacy/input-standard>
  3. #include <builtin/uniforms/cc-global>
  4. #include <legacy/local-batch>
  5. #include <legacy/input-standard>
  6. #include <legacy/fog-vs>
  7. #include <legacy/shadow-map-vs>
  8. in vec4 a_color;
  9. #if HAS_SECOND_UV
  10. in vec2 a_texCoord1;
  11. #endif
  12. out vec3 v_position;
  13. out vec3 v_normal;
  14. out vec3 v_tangent;
  15. out vec3 v_bitangent;
  16. out vec2 v_uv;
  17. out vec2 v_uv1;
  18. out vec4 v_color;
  19. vec4 vert () {
  20. StandardVertInput In;
  21. CCVertInput(In);
  22. mat4 matWorld, matWorldIT;
  23. CCGetWorldMatrixFull(matWorld, matWorldIT);
  24. vec4 pos = matWorld * In.position;
  25. v_position = pos.xyz;
  26. v_normal = normalize((matWorldIT * vec4(In.normal, 0.0)).xyz);
  27. v_tangent = normalize((matWorld * vec4(In.tangent.xyz, 0.0)).xyz);
  28. v_bitangent = cross(v_normal, v_tangent) * In.tangent.w; // note the cross order
  29. v_uv = a_texCoord;
  30. #if HAS_SECOND_UV
  31. v_uv1 = a_texCoord1;
  32. #endif
  33. v_color = a_color;
  34. CC_TRANSFER_FOG(pos);
  35. CC_TRANSFER_SHADOW(pos);
  36. #if CC_USE_2D
  37. return cc_matProj * cc_matView * In.position;
  38. #else
  39. return cc_matProj * (cc_matView * matWorld) * In.position;
  40. #endif
  41. }