Guest User

3d Pixel shader 2

a guest
Sep 18th, 2022
3,723
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. shader_type canvas_item;
  2.  
  3. uniform int pixelSize: hint_range(2, 16, 2) = 4;
  4.  
  5. void fragment()
  6. {
  7.     vec2 iRes = 1.0 / SCREEN_PIXEL_SIZE;
  8.    
  9.     float onePixelSizeX = 1.0 / iRes.x;
  10.     float onePixelSizeY = 1.0 / iRes.y;
  11.    
  12.     float cellSizeX =  float(pixelSize) * onePixelSizeX;
  13.     float cellSizeY = float(pixelSize) * onePixelSizeY;
  14.    
  15.     float x = cellSizeX * floor(UV.x / cellSizeX);
  16.     float y = cellSizeY * floor(UV.y / cellSizeY);
  17.    
  18.     COLOR = texture(SCREEN_TEXTURE, vec2(x, y));
  19. }
Advertisement
Add Comment
Please, Sign In to add comment