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

My HDR attempt.

Discussion in 'Made With Unity' started by crystani, Aug 1, 2011.

  1. crystani

    crystani

    Joined:
    Jul 29, 2011
    Posts:
    68




    Live Demo:
    http://hdrattempt.hostzi.com/WebPlayer.html

    Unity Package:
    http://hdrattempt.hostzi.com/HDR_Crystani.unitypackage

    Filmic Tone Mapping, Eye Adaptation, RGBM encoding for saving HDR information within 32-bit int RenderTexture (So sacrifice Alpha channel), Gamma Correction

    Being a shader newbie, I doubt I correctly implemented all the things.
    If you want to TEACH me what I should do for proper implementation for this(if I am wrong), please tell me what to do.

    To use this, you need to do below. You must use Unity Pro version for posteffect.

    1. Attach ToneMapping script to Main camera. It will show an error message.
    2. For the ToneMapping component on the camera, put appropriate shaders. Those are in 'Tone Mapping Posteffects' folder.
    3. Usually other posteffects will be done after tone mapping. For example, if you use Bloom and Lens Flare effect by Unity(built-in shader), you need to put it below the tone mapping effect script on Camera's inspector menu.
    4. There are a few shaders in 'Shaders for surface' folder. If you use tone mapping effect, as it decodes the screen buffer from RGBM to None RGBM, you must set all of you shaders encoded in RGBM format. This is done for putting HDR information inside 32bit-int Rendertexture.
    5. If you want to use shaders other than shaders in 'Shaders for surface', take a look at files like 'Temporary RGBM Diffuse'. It is a surface shader code, and it converts texture looked up from gamma space to linear space. Also see '#pragma debug'. When it is compiled, it will make a source code written in cg language. 'Temporary RGBM' uses that generated code, while finally modifying code like:

    return EncodeRGBM(c.rgb);

    instead of

    return c;

    My questions.

    1. I don't know other ways than this when I use surface shader. Lightmap is used after lighting models of surface shader. If you know how to modify the final value of shaders written in surface shader, please let me know how I can do it.
    2. I think there are way better ways for getting luminance value of the scene.
    3. Cleaning up leaked objects in scene since no game object, component or manager is referencing them. RenderTexture has been leaked 3 times. <- this message is shown whenever I try to save the scene. I am worried whether I am making leaks... Is it okay? Or should I do something?

    References:

    http://www.xnainfo.com/content.php?content=28
    http://graphicrants.blogspot.com/2009/04/rgbm-color-encoding.html
    http://www.slideshare.net/ozlael/hable-john-uncharted2-hdr-lighting
     
    Last edited: Aug 1, 2011
  2. TheMetaMorphe

    TheMetaMorphe

    Joined:
    Nov 9, 2012
    Posts:
    23
    Very interesting and promising !

    Just one suggestion for you gamma correction : use pow( color, 2.2 ) instead of color * color.

    Edit : Nvm :).

    "also I suggest you to read this : http://filmicgames.com/"

    Can't wait to see more !
     
    Last edited: Mar 8, 2013