Search Unity

Assets Shader quick image recolorization

Discussion in 'Works In Progress - Archive' started by Pode, Dec 2, 2019.

  1. Pode

    Pode

    Joined:
    Nov 13, 2013
    Posts:
    145
    If you don't want to recalculate completely an image, but only recolor part of it, here's a demo of runtime system to recolor part of the image.

    It's done with a shader, with only the "beauty shot" of the 3D render, and the mask from that beauty shot, where the white part of the mask indicates what part must be recolored.
    The image :
    The mask :


    The shader transform the RGB image to grayscale via a simple approximation: (R+G+B)/3. The grayscale value is then multiplied with an RGB color, only where the mask pixels are white.

    If you need to change completely the material (and not only recolor), you need to have a different render per material.

    Of course, this technique doesn't take into account proper like bounces and color bleed, like a full GI algorithm would do.