Shader


SUBMITTED BY: Guest

DATE: April 22, 2013, 12:31 a.m.

FORMAT: C++

SIZE: 883 Bytes

HITS: 1581

  1. #version 130
  2. uniform sampler2D texture;
  3. in vec2 texCoord;
  4. in vec4 color;
  5. out vec4 final;
  6. void main(void)
  7. {
  8. vec4 myColor = color;
  9. final = texture2D(texture, texCoord);
  10. int P = 1;
  11. int outline = 0;
  12. if (final.a == 0.0)
  13. {
  14. vec4 px[4] = vec4[](
  15. texture2D(texture, texCoord+vec2(P, 0)),
  16. texture2D(texture, texCoord+vec2(0, P)),
  17. texture2D(texture, texCoord+vec2(-P, 0)),
  18. texture2D(texture, texCoord+vec2(0, -P))
  19. );
  20. for(int i = 0; i < 4; ++i)
  21. {
  22. if(px[i].a > 0.0)
  23. {
  24. myColor = vec4(1.0, 0.0, 0.0, 1.0);
  25. outline++;
  26. }
  27. }
  28. if(outline == 0)
  29. discard;
  30. }
  31. final = myColor;
  32. }

comments powered by Disqus