Search Unity

How do I intentionally pixellate a sprite in script?

Discussion in '2D' started by jusw85, Feb 23, 2017.

  1. jusw85

    jusw85

    Joined:
    Apr 21, 2016
    Posts:
    21
  2. SyncomGroup

    SyncomGroup

    Joined:
    May 26, 2014
    Posts:
    6
    You can convert your Sprite into a Texture2D , when you call .Apply() Unity will internal generate your mipmaps after which you can get your pixelated versions using Texture2D.GetPixels and you can go back to a Sprite , it's a bit hacky.

    Version 2: Use post effects , you can use RenderToTex and and a posteffect script to pixelate your image.
     
  3. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    You're talking about a 'de-res' ie de-resolution effect. You can pull this off by using a rendertexture. Render the sprite at a very small size to the render texture, then create custom geometry to ouput the sprite at its normal size but using only the portion of the render texture that you drew. Each frame you draw the sprite a bit bigger. It will gradually de-res into its full resolution. You can also do this with a shader.
     
  4. jusw85

    jusw85

    Joined:
    Apr 21, 2016
    Posts:
    21
    Thanks for the ideas! Will try it out and see how it goes