toonVert.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import skinningDefines from './skinningDefine';
  2. export default
  3. /* glsl */
  4. `#version 100
  5. uniform highp mat4 u_view;
  6. uniform highp mat4 u_viewInverse;
  7. uniform highp mat4 u_vp;
  8. uniform highp mat4 u_projection;
  9. uniform mat4 u_lightSpaceMatrix;
  10. uniform vec4 u_fogInfos;
  11. uniform vec3 u_fogColor;
  12. uniform float u_gameTime;
  13. uniform float u_aspect;
  14. uniform vec3 u_ambientLight;
  15. uniform vec3 u_lightDir;
  16. uniform vec3 u_lightColor;
  17. uniform vec3 u_shadowColor;
  18. uniform float u_shadowStrength;
  19. uniform float u_shadowBias;
  20. uniform float u_lightWidthPCSS;
  21. uniform float u_blockSizePCSS;
  22. uniform vec4 u_csmFarBounds;
  23. uniform vec4 u_shadowTilingOffsets[4];
  24. uniform mat4 u_csmLightSpaceMatrices[4];
  25. uniform vec3 u_SH[9];
  26. uniform highp mat4 u_world;
  27. ${skinningDefines}
  28. attribute vec3 a_position;
  29. attribute highp vec2 a_texCoord;
  30. attribute highp vec2 a_texCoord_1;
  31. varying highp vec2 v_UV;
  32. varying highp vec2 v_UV1;
  33. varying highp vec3 v_ViewPosition;
  34. #ifdef WX_USE_COLOR_0
  35. attribute vec3 a_color;
  36. varying highp vec3 v_Color;
  37. #endif
  38. #ifdef WX_USE_NORMAL
  39. attribute highp vec3 a_normal;
  40. varying highp vec3 v_Normal;
  41. #endif
  42. void main()
  43. {
  44. #ifdef WX_SKINNED
  45. mat4 boneMat = getBoneMat();
  46. mat4 modelViewMatrix = u_view * boneMat;
  47. #else
  48. mat4 modelViewMatrix = u_view * u_world;
  49. #endif
  50. mat3 normalMatrix = mat3(modelViewMatrix);
  51. vec4 mvPosition = modelViewMatrix * vec4(a_position, 1.0);
  52. v_UV = a_texCoord;
  53. v_UV1 = a_texCoord_1;
  54. #ifdef WX_USE_COLOR_0
  55. v_Color = a_color;
  56. #endif
  57. #ifdef WX_USE_NORMAL
  58. // v_Normal = normalize(vec3(normalMatrix * a_normal));
  59. v_Normal = normalize(a_normal);
  60. #endif
  61. v_ViewPosition = mvPosition.xyz;
  62. gl_Position = u_projection * mvPosition;
  63. }
  64. `;