Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Adding pixel crunch to my cel shader

Discussion in 'Shader Graph' started by mrCharli3, Sep 19, 2023.

  1. mrCharli3

    mrCharli3

    Joined:
    Mar 22, 2017
    Posts:
    946
    Hi,

    Is there a way in shader graph to pixelate objects? I am currently doing it by rendering my game to a small render texture and it works OK, but at times I want to render some things at a normal resolution, like damage numbers.

    So I was wondering if its better to use a shader perhaps, so I can control what to pixelate.

    Any pointers that could help me get started?

    upload_2023-9-19_13-59-10.png
     
  2. BenCloward

    BenCloward

    Unity Technologies

    Joined:
    Jul 15, 2021
    Posts:
    89
    I made a video on this topic:



    In the video, I'm applying the effect to the full screen, but you could also just apply it to the UV coordinates on a mesh instead.
     
    mrCharli3 likes this.
  3. mrCharli3

    mrCharli3

    Joined:
    Mar 22, 2017
    Posts:
    946
    Hehe saw this one, I’ve tried this without any success, just messed up UV mapping on model.
     
  4. BenCloward

    BenCloward

    Unity Technologies

    Joined:
    Jul 15, 2021
    Posts:
    89
    It's working pretty ok for me. Here's what the graph looks like:

    upload_2023-9-20_10-12-42.png
     
  5. mrCharli3

    mrCharli3

    Joined:
    Mar 22, 2017
    Posts:
    946
    Hmm maybe I’ll give it another try, thanks!
     
  6. mrCharli3

    mrCharli3

    Joined:
    Mar 22, 2017
    Posts:
    946
    It does indeed work on the texture, but I think since I use this type of palette for my 3d character it will not work.

    upload_2023-9-21_15-45-25.png

    works well on a normal texture tho:

    upload_2023-9-21_15-46-0.png
     
  7. BenCloward

    BenCloward

    Unity Technologies

    Joined:
    Jul 15, 2021
    Posts:
    89
    Ok, so you have your character's UV placed in each of the squares of solid color on your texture instead of uniformly laid out in UV space. Yeah, my technique most definitely won't work with that system.

    It sounds like what you want to do is render things in two separate stages. The things you want pixelated would render into the texture first, and then the things you don't want pixelated would render second.
     
    jGate99 and mrCharli3 like this.
  8. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,836
    Just wanted to say thank you, I recently started learning shader graph and saw your channel, Thanks a lot