SHARE
TWEET

GZDoom Pixelate + Posterize Shader

a guest Aug 17th, 2016 114 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. out vec4 FragColor;
  2. in vec2 TexCoord;
  3. uniform sampler2D Texture;
  4. //uniform float new_w, new_h, palette;
  5.  
  6. vec4 pixelate(sampler2D tex, vec2 uv)
  7. {
  8. vec2 coord = vec2( ceil(uv.x * 320) /320,
  9. ceil(uv.y * 200) / 200 );
  10. return texture2D(tex, coord);
  11. }
  12.  
  13. vec4 reduce_palette(vec4 color, float max_colors_per_channel)
  14. {
  15. if(max_colors_per_channel < 0) {
  16. return color;
  17. }
  18.    
  19. return ceil(color * max_colors_per_channel) / max_colors_per_channel;
  20. }
  21.  
  22. void main()
  23. {
  24. vec4 color = pixelate(Texture, TexCoord);
  25. FragColor = reduce_palette(color, 20);
  26. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top