outline-vs.chunk 897 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. precision highp float;
  2. #include <legacy/input-standard>
  3. #include <builtin/uniforms/cc-global>
  4. #include <legacy/local-batch>
  5. out vec2 v_uv;
  6. uniform OutlineVert {
  7. vec4 outlineParams; // x: line width, y: depth hack
  8. };
  9. vec4 vert () {
  10. StandardVertInput In;
  11. CCVertInput(In);
  12. mat4 matWorld;
  13. CCGetWorldMatrix(matWorld);
  14. float width = outlineParams.x * 0.001;
  15. #if USE_POSITION_SCALING
  16. vec3 dir = normalize(In.position.xyz);
  17. float flip = dot(dir, normalize(In.normal)) < 0.0 ? -1.0 : 1.0;
  18. In.position.xyz += flip * dir * width * 2.0;
  19. vec4 pos = cc_matProj * (cc_matView * matWorld) * In.position;
  20. #else
  21. In.position.xyz += normalize(In.normal) * width;
  22. vec4 pos = cc_matProj * (cc_matView * matWorld) * In.position;
  23. #endif
  24. float scaleZ = cc_nearFar.z == 0.0 ? 0.5 : 1.0;
  25. pos.z -= outlineParams.y * 0.002 * scaleZ;
  26. v_uv = a_texCoord;
  27. return pos;
  28. }