Search Unity

Shader for monochrome pixellation effect?

Discussion in 'Shaders' started by sdcur2, Apr 14, 2017.

  1. sdcur2

    sdcur2

    Joined:
    Aug 11, 2013
    Posts:
    6
    I'm trying to mimic the look of an old orange plasma screen from way back in the day (like this: http://i.imgur.com/xkDYSCO.jpg ), and looking to use a shader to create the pixelation effect. But I googled the topic, everything I found was about how to mimic RGB pixels and add CRT-style scanlines, which isn't what I want. I'm after a monochrome pixel shader - basically just a very fine grid.

    If anyone could explain how to achieve this, or point me towards a tutorial that covers this, I'd be grateful.
     
  2. UziMonkey

    UziMonkey

    Joined:
    Nov 7, 2012
    Posts:
    206
    Do you want to do this as an image effect shader or a surface shader? I think either one would be pretty easy.

    For an image effect shader, render your scene in black and white, as close to black and white as possible. Then replace every black pixel with your background color and every white pixel is the foreground color. However, get the screen position first and only add the foreground color for every odd column one row, then every even color the other row.

    You can do a similar thing with the surface shader by getting the screen position there as well.

    Edit: Never mind, I zoomed in on the picture and most of what I was seeing was a scaling artifact from the browser.
     
  3. sdcur2

    sdcur2

    Joined:
    Aug 11, 2013
    Posts:
    6
    I've been attaching shaders to my camera to get the whole scene. I've already got the colours on my scene pretty much as I want them, I just wanted to add a super-faint grid effect to the screen.
     
  4. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,342
  5. sdcur2

    sdcur2

    Joined:
    Aug 11, 2013
    Posts:
    6
    I wrote a shader that breaks the pixels into groups of three (similar to how the RPG ones work), but which simply makes the first pixels slightly dimmer, the second slightly brighter, and leaves the third as-is. It achieves the desired effect.

    HOWEVER: It's dawned on me that a shader like this has a limited lifespan. Because if I run my game at a low resolution (640 x 480), it becomes really obvious that it's a bit of fakey: the space between the pixels real 640 x 480 screen would be smaller than an actual pixel, whereas the shader is darkening entire pixels.

    And so if you go in the other direction, to higher resolutions, you're going to eventually run into a situation where the effect vanishes at the point where individual pixels are too small.