outline.vertex.fx 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #ifdef GL_ES
  2. precision highp float;
  3. #endif
  4. // Attribute
  5. attribute vec3 position;
  6. attribute vec3 normal;
  7. #ifdef BONES
  8. attribute vec4 matricesIndices;
  9. attribute vec4 matricesWeights;
  10. #endif
  11. // Uniform
  12. uniform float offset;
  13. #ifdef INSTANCES
  14. attribute vec4 world0;
  15. attribute vec4 world1;
  16. attribute vec4 world2;
  17. attribute vec4 world3;
  18. #else
  19. uniform mat4 world;
  20. #endif
  21. uniform mat4 viewProjection;
  22. #ifdef BONES
  23. uniform mat4 mBones[BonesPerMesh];
  24. #endif
  25. #ifdef ALPHATEST
  26. varying vec2 vUV;
  27. uniform mat4 diffuseMatrix;
  28. #ifdef UV1
  29. attribute vec2 uv;
  30. #endif
  31. #ifdef UV2
  32. attribute vec2 uv2;
  33. #endif
  34. #endif
  35. void main(void)
  36. {
  37. #ifdef INSTANCES
  38. mat4 finalWorld = mat4(world0, world1, world2, world3);
  39. #else
  40. mat4 finalWorld = world;
  41. #endif
  42. vec3 offsetPosition = position + normal * offset;
  43. #ifdef BONES
  44. mat4 m0 = mBones[int(matricesIndices.x)] * matricesWeights.x;
  45. mat4 m1 = mBones[int(matricesIndices.y)] * matricesWeights.y;
  46. mat4 m2 = mBones[int(matricesIndices.z)] * matricesWeights.z;
  47. mat4 m3 = mBones[int(matricesIndices.w)] * matricesWeights.w;
  48. finalWorld = finalWorld * (m0 + m1 + m2 + m3);
  49. gl_Position = viewProjection * finalWorld * vec4(offsetPosition, 1.0);
  50. #else
  51. gl_Position = viewProjection * finalWorld * vec4(offsetPosition, 1.0);
  52. #endif
  53. #ifdef ALPHATEST
  54. #ifdef UV1
  55. vUV = vec2(diffuseMatrix * vec4(uv, 1.0, 0.0));
  56. #endif
  57. #ifdef UV2
  58. vUV = vec2(diffuseMatrix * vec4(uv2, 1.0, 0.0));
  59. #endif
  60. #endif
  61. }