Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Images affected by Color Grading gamma value

Discussion in 'General Graphics' started by getmyisland_dev, Mar 15, 2023.

  1. getmyisland_dev

    getmyisland_dev

    Joined:
    Dec 22, 2020
    Posts:
    100
    I want to create a brightness slider for my game. I have implemented the entire functionality behind it using PostProcessing. See Color Grading -> Linear -> Gamma.

    The problem is finding the correct brightness is a lot of trial and error. You have to adjust brightness go out of the menu, check if its correct and repeat the process x times.

    To make the process of selecting the correct brightness easier I want to implement something seen in a lot of games. A brightness adjustment screen until a logo is barely visible.



    My question is how can I do this in Unity?

    The Unity version I'm using: 2021.3.5f1.
     
  2. D12294

    D12294

    Joined:
    Oct 6, 2020
    Posts:
    81
    What is your question? How to implement the UI from the screenshot?
     
  3. getmyisland_dev

    getmyisland_dev

    Joined:
    Dec 22, 2020
    Posts:
    100
    Yes, my question is how I can implement an UI like in the picture. Whenever the user drags the slider the 3 images change their color according to the gamma value.

    I should also note that the gamma values range from -1 to 1.
     
  4. getmyisland_dev

    getmyisland_dev

    Joined:
    Dec 22, 2020
    Posts:
    100
    I managed to solve this problem myself and it was easier than I thought.

    You just have to reference your images like this:


    Code (CSharp):
    1. [SerializeField] private Image _brightnessNotVisibleImage;
    2.     [SerializeField] private Image _brightnessBarelyVisibleImage;
    3.     [SerializeField] private Image _brightnessVisibleImage;
    And make your slider execute this function whenever his value changes:

    Code (CSharp):
    1. public void UpdateImageBrightness(float brightness)
    2.     {
    3.         float notVisibleBrightness = Mathf.Lerp(0.0f, 1.0f, brightness - 0.1f);
    4.         _brightnessNotVisibleImage.color = new Color(notVisibleBrightness, notVisibleBrightness, notVisibleBrightness, 1.0f);
    5.  
    6.         float barelyVisibleBrightness = Mathf.Lerp(0.0f, 1.0f, brightness);
    7.         _brightnessBarelyVisibleImage.color = new Color(barelyVisibleBrightness, barelyVisibleBrightness, barelyVisibleBrightness, 1.0f);
    8.  
    9.         float visibleBrightness = Mathf.Lerp(0.0f, 1.0f, brightness + 0.1f);
    10.         _brightnessVisibleImage.color = new Color(visibleBrightness, visibleBrightness, visibleBrightness, 1.0f);
    11.     }
    I hope this helps someone in the future.
     
  5. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    4,615
    Wouldn't it make more sense to just update the gamma in your post processing when you move the slider? That way the user can see what they're actually adjusting.
     
    D12294 likes this.