Search Unity

A direction on how to develop a "single mesh pixelization" shader?

Discussion in 'Shaders' started by Zimbres, Mar 21, 2016.

  1. Zimbres

    Zimbres

    Joined:
    Nov 17, 2014
    Posts:
    180
    Hello,

    I'm still getting into shaderworld, but I'm a little stuck on a specific situation of mine:

    I would like to pixelize a mesh on my game, while keeping everything else on the game non-pixelated.

    There's how to write a shader to pixelize a mesh where a material/shader is attached?

    Thanks,,
     
  2. aubergine

    aubergine

    Joined:
    Sep 12, 2009
    Posts:
    2,880
    You render a mask of the object(s) to be pixelated and do the thing as an image effect using this mask.
    I had a package for unity 4.x on the assetstore but i removed it recently to update for 5.x, if you want a custom copy, you can pm me.
     
  3. Zimbres

    Zimbres

    Joined:
    Nov 17, 2014
    Posts:
    180
    It would not involve something on the "frag" pass?
     
  4. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    You can pixelate the surface texture in the fragment function for the object you're rendering, but the geometry would still be full resolution. You need to pixelate the result of the object rendering with another shader after the fact, usually using a full screen post process, or render your object at a lower resolution to in a render texture and composite it back into the scene.
     
  5. Zimbres

    Zimbres

    Joined:
    Nov 17, 2014
    Posts:
    180
    Hum.... I've tried the last option (the renderTexture at lower res), but, two problems arise:
    -there's no z-depth, the models shows always on front of everything
    -Maybe I'm wrong, but render texture is not something kind of heavy?
     
  6. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    You can get a depth with the render texture (you need a second depth render texture) and use that to composite back into your scene. And yes there is some expense to this, but any kind of post effect also uses render textures.
     
  7. Zimbres

    Zimbres

    Joined:
    Nov 17, 2014
    Posts:
    180
    Thanks for the insight Bgolus. I will think about my options and reply again later.