Innerline - GLSL Shader


SUBMITTED BY: Guest

DATE: April 22, 2013, 1:14 a.m.

FORMAT: C++

SIZE: 1.0 kB

HITS: 1214

  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. float P = 1.0 / 512.0;
  10. float treshold = 0.2;
  11. final = texture2D(texture, texCoord);
  12. if (final.a <= treshold)
  13. discard;
  14. vec4 px[8] = vec4[](
  15. texture2D(texture, texCoord+vec2(P, P)),
  16. texture2D(texture, texCoord+vec2(-P, P)),
  17. texture2D(texture, texCoord+vec2(-P, -P)),
  18. texture2D(texture, texCoord+vec2(P, -P)),
  19. texture2D(texture, texCoord+vec2(P, 0)),
  20. texture2D(texture, texCoord+vec2(0, P)),
  21. texture2D(texture, texCoord+vec2(-P, 0)),
  22. texture2D(texture, texCoord+vec2(0, -P))
  23. );
  24. for(int i = 0; i < 8; ++i)
  25. {
  26. if(px[i].a <= treshold)
  27. myColor = vec4(vec3(0.0), 1.0);
  28. }
  29. final = myColor;
  30. }

comments powered by Disqus