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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

How to reduce color depth of a rendertexture/material?

Discussion in 'General Graphics' started by garv3, May 27, 2015.

  1. garv3

    garv3

    Joined:
    Dec 30, 2012
    Posts:
    32
    Hi there!

    I'd like to know if there is a way to reduce the number of colors that are used to render a rendertexture. Is there a way to set the colors to 65k, 256, 64 and so on?

    Thank you in advance!
    garv3
     
  2. AlexBM

    AlexBM

    Joined:
    Mar 26, 2015
    Posts:
    16
  3. garv3

    garv3

    Joined:
    Dec 30, 2012
    Posts:
    32
    Hi Alex!
    Thank you for the answer. Unfortunately this does not work for my renderTexture. If I use RenderTextureFormat.RGBA4444 I get the error "RenderTexture.Create failed: format unsupported."

    So how may I do this using a shader?

    Thanks again!
     
  4. AlexBM

    AlexBM

    Joined:
    Mar 26, 2015
    Posts:
    16
    You may try to use following algorithm. Create a look-up texture with dimensions 1 : x, where x is number of values you want to have per colour channel and fill it with black-and-white gradient. For example, for 4096 colours you need to create texture with dimensions 1:8 pixels. Then use original rgb values as v coordinate in that texture and return it's colour instead. However, this shader will use 4 texture lookups, so there might be a more efficient solution :)