Search Unity

Brightness slider?

Discussion in 'Immediate Mode GUI (IMGUI)' started by Zante, Jan 19, 2010.

  1. Zante

    Zante

    Joined:
    Mar 29, 2008
    Posts:
    429
    I've noticed, over the year, how different machines display scenes in Unity. Some are very dark, others too bright. It's no easy thing to cater for each users display settings.

    How easy is it to create a slider which can be used to increase the gamma of a scene?

    Which properties do I need to look at :?:
     
  2. HiggyB

    HiggyB

    Unity Product Evangelist

    Joined:
    Dec 8, 2006
    Posts:
    6,183
    I suppose that one possible solution here would be to use full-screen post process effects to achieve this sort of effect, like the Color Correction perhaps? Doing something like this, even if by writing your own effect or finding one for gamma correction in specific, should be workable. For example, check this thread as it even offers a gamma correction package file for you to use. :)

    Hope that helps!
     
  3. Jessy

    Jessy

    Joined:
    Jun 7, 2007
    Posts:
    7,325
    Even if it's Advanced-only, we really need a solution for the iPhone, though.

    http://answers.unity3d.com/question...-brightness-gamma-menu-setting-for-the-iphone

    This is pretty important to me. I'm working on a game that's supposed to be spooky. So we made the textures dark. Problem is, I took the iPhone outside, and the glare from the sun made all the dark stuff very hard to see. I'd rather not sacrifice the look of the game just to make it usable in bright environments.
     
  4. Zante

    Zante

    Joined:
    Mar 29, 2008
    Posts:
    429
    Sorted, using GUI slider and colour correction shader. I did find a gamma shader on the forums but it cancelled out the glow shader when used.
     
  5. VCCGeek

    VCCGeek

    Joined:
    Nov 17, 2009
    Posts:
    89
    I've found something that works out for me in terms of user-controlled gamma correction. Create a variable for your gamma correction. Put a slider somewhere in your GUI (probably an options dialogue somewhere). Link its value to that variable. Set RenderSettings.AmbientLight to a colour in which all three components are the gamma correction. Here's some sample code:

    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4.  
    5. public class MyGUISliderExample : MonoBehaviour {
    6.    
    7.     public float GammaCorrection;
    8.    
    9.     public Rect SliderLocation;
    10.    
    11.     void Update() {
    12.        
    13.         RenderSettings.ambientLight = new Color(GammaCorrection, GammaCorrection, GammaCorrection, 1.0f);
    14.        
    15.     }
    16.    
    17.     void OnGUI () {
    18.        
    19.         GammaCorrection = GUI.HorizontalSlider(SliderLocation, GammaCorrection, 0, 1.0f);
    20.        
    21.     }
    22.  
    23. }
    24.  
    Remember that a colour component is in the range of 0 to 1, and it's a float. Anyone, feel free to translate this to JS.

    Hope this helps!
     
  6. epikdude70alt

    epikdude70alt

    Joined:
    Jan 20, 2014
    Posts:
    6
    I can't make it work.
     
  7. 03gramat

    03gramat

    Joined:
    Aug 27, 2012
    Posts:
    3
    I realise this thread is old, but this tutorial works with the updated menus (Unity4+5) incase anyone else comes across this thread and can't get it working:
     
  8. Metalloriff

    Metalloriff

    Joined:
    May 8, 2015
    Posts:
    4
    have you tried using a ScreenOverlay and then doing something like this:



    var brightness:UnityStandardAssets.ImageEffects.ScreenOverlay; //APPLY IT HERE

    var pos:Vector2;//these are totally optional if you use actual coords on the horizontal slider.
    var scale:Vector2;
    var min:float;
    var max:float;

    function OnGUI(){
    brightness.intensity=GUI.HorizontalSlider(Rect(pos.x,pos.y,scale.x,scale.y), brightness.intensity, min, max);
    }



    and then just apply a plain white or plain black texture to it, viola.
     
  9. IMemeManI

    IMemeManI

    Joined:
    May 4, 2017
    Posts:
    2
    I had an idea about this exact sheet, I knew it would work. Here it is in Unity 5:

    "
    RenderSettings.ambientLight = new Color(Sat, Sat, Sat, 1.0f);
    Sat = sat.value; "

    Sat - the float.
    sat - the slider.

    I'll probably be changing the names lol.
     
  10. PRABHBIR123

    PRABHBIR123

    Joined:
    Apr 9, 2017
    Posts:
    72