Advertisement
Guest User

GZDoom Pixelate + Posterize Shader

a guest
Aug 17th, 2016
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement