Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. //> the compiler should be able to optimize the following branch
  2. if(isMesh){
  3. vec2 invSize = 1.0 / texSize;\
  4. vec4 uvOffset = vec4(1.0, 0.0, 0.0, 1.0) * vec4(invSize, invSize);\
  5. vec4 c1 = texture2D( maskTexture, vUv + uvOffset.xy);\
  6. vec4 c2 = texture2D( maskTexture, vUv - uvOffset.xy);\
  7. vec4 c3 = texture2D( maskTexture, vUv + uvOffset.yw);\
  8. vec4 c4 = texture2D( maskTexture, vUv - uvOffset.yw);\
  9. float diff1 = (c1.r - c2.r)*0.5;\
  10. float diff2 = (c3.r - c4.r)*0.5;\
  11. float d = length( vec2(diff1, diff2) );\
  12. float a1 = min(c1.g, c2.g);\
  13. float a2 = min(c3.g, c4.g);\
  14. float visibilityFactor = min(a1, a2);\
  15. vec3 edgeColor = 1.0 - visibilityFactor > 0.001 ? visibleEdgeColor : hiddenEdgeColor;\
  16. gl_FragColor = vec4(edgeColor, 1.0) * vec4(d);\
  17. } else {
  18. vec4 edge = texture2D( maskTexture, vUv);
  19. vec3 edgeColor = 1.0 - edge.g > 0.001 ? visibleEdgeColor : hiddenEdgeColor;
  20. gl_FragColor = vec4( edgeColor, 1.0) * (1.0-edge.r);
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement