Advertisement
Guest User

Untitled

a guest
Dec 6th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. //
  2. // Outline shader
  3. //
  4. varying vec2 v_vTexcoord;
  5. varying vec4 v_vColour;
  6. uniform float pixelW;
  7. uniform float pixelH;
  8. uniform float opacity;
  9. void main()
  10. {
  11. // Compute the textel offsets
  12. vec2 offsetX;
  13. offsetX.x = pixelW;
  14. vec2 offsetY;
  15. offsetY.y = pixelH;
  16.  
  17. float originAlpha = sign(texture2D(gm_BaseTexture, v_vTexcoord).a);
  18. float alpha = originAlpha;
  19. // Combine the alpha from all surrounding textels.
  20. alpha += ceil(texture2D(gm_BaseTexture, v_vTexcoord + offsetX).a);
  21. alpha += ceil(texture2D(gm_BaseTexture, v_vTexcoord - offsetX).a);
  22. alpha += ceil(texture2D(gm_BaseTexture, v_vTexcoord + offsetY).a);
  23. alpha += ceil(texture2D(gm_BaseTexture, v_vTexcoord - offsetY).a);
  24.  
  25. // Only blend with the image_blend factor if the original alpha was 0.
  26. // That means the image_blend parameter is the outline color.
  27. gl_FragColor = (v_vColour * (1.0 - originAlpha)) +
  28. texture2D(gm_BaseTexture, v_vTexcoord);
  29.  
  30. // Use the computed alpha
  31. gl_FragColor.a = alpha;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement