Search Unity

Mobile HDR

Discussion in 'Assets and Asset Store' started by forcepusher, Jun 15, 2013.

  1. forcepusher

    forcepusher

    Joined:
    Jun 25, 2012
    Posts:
    227
    PROJECT DISCONTINUED DUE TO RELEASE OF NEW INCOMPATIBLE GPUs

    "Bloom" and "Gradual adaptive brightness correction" effects that support HDR.
    This shader boosts the look and feel of your game without any effort.

    $ScreenShot1.png $ScreenShot2.png

    - Full support for iOS/Android. Since v2.0 it works on everything except PowerVR SGX543MP3 and 544MP3 mobile devices (iPhone 5, iPhone 5C, Samsung Galaxy S4), this GPU is bugged. Workaround fix is pending.
    - Incredible output quality. Perfectly fits PC games.
    - Very fast. Performance is approximately equal to Unity's FastBloom. Basically you can expect ~3% fps drop.
    - Custom inspector. Over 15 easy-to-understand parameters with documentation inside inspector UI.
    - No need to hit Play to see the results.
    - One or other effect can be completely turned off without wasting performance.
    - Code written on C# and Cg. Well, no lies - I can't really call it "Simple" due to nature of CPU+GPU cooperative code, level of optimization, and compatibility tricks. Still it's clean, self-commented and well structured.
    - Full source code included, no DLLs or compiled-only shaders.
    - Requires Unity Pro. Shader model 2.0.
    - To run on Android it will also require Android Pro, same with iOS.
     
    Last edited: Apr 8, 2016
  2. Drakorian-Labs

    Drakorian-Labs

    Joined:
    Feb 23, 2012
    Posts:
    88
    Hi,
    this does look good indeed.
    some questions:
    -With effects on is running at 30fps, what's the fps without the effect on?
    -it has bloom and brightness correction, can you turn one or the other off?
    -Will it run at the same speed in iOS?

    Looking forward to your answer :)
     
  3. Andrew_atl

    Andrew_atl

    Joined:
    Sep 21, 2010
    Posts:
    103
    Nice job.
     
  4. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
    If it's mobile please provide apk
     
  5. forcepusher

    forcepusher

    Joined:
    Jun 25, 2012
    Posts:
    227
    Okay, done.
    client.apk for mobile devices

    ~32 fps with the effect off against ~30 fps with the effect on.

    I've made a v1.2 Update where you can turn off the brightness correction or bloom off selectively. Additionally, instead of turning adaptive brightness correction off completely you can dim down its strength.

    Thanks.
     
    Last edited: Jan 29, 2014
  6. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
    Hello, in your video, you are setting the camera render path to Deferred render instead of Forward render.
    In the docs, Unity mobile shouldn't support deferred render at all. Why do we have to set the camera to deferred render?
    Does it really switch to deferred render or is it some kind of trick for doing a faster hdr effect??
    Will it finally render to deferred or forward mode?
     
  7. forcepusher

    forcepusher

    Joined:
    Jun 25, 2012
    Posts:
    227
    It will probably be forward rendering. This is just a workaround to avoid expected Unity Editor bug that flips over debug view if you activate anti-aliasing with forward rendering (it still renders fine on the device with those settings).
     
    Last edited: Jul 1, 2013
  8. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
    Ok, thanks for the quick answer. You have a new customer :)
     
  9. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
    Just installed it and set up to my taste in less than five minutes.
    10-11 draw calls here, wich is cool and fast. A little tricky to set up for optimal / aesthetic results, but worth the time spent.
    However, the Bloom effect is prone to desaturate the image. An additional "saturation boost" control would be awesome.
    I have combined it here with the PRO image effect "color correction and saturation" for boosting saturation at 1.25 and did the trick, however I don't know the impact it will have on android devices (or if it will run at all...)

    Very happy with my purchase! Thank you VERY much for this! I was needing it BADLY :D
     
  10. forcepusher

    forcepusher

    Joined:
    Jun 25, 2012
    Posts:
    227
    Thanks a lot for very informative review, I will add this feature in the next update.
     
  11. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
    shame, please check pm.
     
  12. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
    The bloom is adding white additive to the scene. In my lava scene, it looks wrong. Is there a color selector?
     
  13. forcepusher

    forcepusher

    Joined:
    Jun 25, 2012
    Posts:
    227
    Not yet, but I will work on it right now and release a minor update for it.

    Update1: Here is what i've achieved. It should work a lot better with the colors now. Just need some final adjustments.

    $bloom better.jpg
     
    Last edited: Jul 10, 2013
  14. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
    Excellent! that's what we needed! :)
    By the way, I took a look on the code and made some (very) minor optimizations: you should use CLAMP instead of an IF to keep a variable between 2 values. Also, you should multiply instead of divide ( a=b*0.5 instead of a=b/2 )
    Multiply is faster than divide and should be avoided if possible, however some compilers are smart enough to change this for you when compiling. It's a good practice thought.

    About clamp instead of IF, conditions are always slower than clamp or max, and for some mobile chipsets like the Tegra family, CLAMP is a FREE operation, meaning you can use it all you want, it will not slow down anything !
    I have been reading some white papers for gpu optimizations for my custom shaders ;-p

    I really like your image effect and I'm very happy with my purchase :)
     
  15. forcepusher

    forcepusher

    Joined:
    Jun 25, 2012
    Posts:
    227
    Very good point about the clamp, thanks.
    And yea, i've already figured the division problem out when was working on porting this to iOS (still in progress).

    Update is up at Asset Store.
    # Fixed saturation drop issue.
    # Improved bloom glow algorithm.
    # Fixed brightness clamping when decreasing brightness of very bright surfaces.
    # Heavy optimizations.
     
    Last edited: Jul 13, 2013
  16. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
    Cool thanks for update, this is on v1.2, in my lava scene which is quite large, when I run around, the bloom will flicker on and off. Will try out 1.3
     
  17. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
    I found a bug with 1.3. When I enter the scene again, the camera is zoomed in a bit. It keeps zooming in a bit everytime I reenter the scene.
     
  18. forcepusher

    forcepusher

    Joined:
    Jun 25, 2012
    Posts:
    227
    There is no way it could be related to shader code, especially if it does that in the scene view only (same happened to me long ago when I didn't create that shader yet).
     
    Last edited: Jul 12, 2013
  19. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
    Shame, your avatar is hipnotic xD
     
  20. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
    Hate to break it to you, but if I remove the HDR script from the camera, it does not happen. I can send apk to see.
     
  21. forcepusher

    forcepusher

    Joined:
    Jun 25, 2012
    Posts:
    227
    Still there is no way it's related to this specific shader code. Send me all you got to help identify a problem
     
  22. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
    Found the problem. The script halves the resolution every time it is run as it is set to half so every scene will the camera will halve it. It should only be set once.
     
  23. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
    Found more issues. The HDR and Antialiasing does not work together in forward rendering mode, so to get acceptable performance, I have to half the resolution, and that's a bummer.
     
  24. forcepusher

    forcepusher

    Joined:
    Jun 25, 2012
    Posts:
    227
    Why people hate Readme.txt ? It makes life so much easier.
    Also refer to post http://forum.unity3d.com/threads/186404-Mobile-HDR?p=1286809&viewfull=1#post1286809
     
    Last edited: Jul 19, 2013
  25. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
    Shame, I do read the readme.txt, and your readme says to set HDR and Set AntiAlias, both which are non compatible. I'm putting this in a real world project, not a sample. And I find these issues, which you did not face/consider in your demo.
     
  26. forcepusher

    forcepusher

    Joined:
    Jun 25, 2012
    Posts:
    227
    They are compatible, just set your camera to deferred lighting to avoid editor bug.
     
  27. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
    It's not the editor flip bug, I'm deploying on device, and switching resolution, it throws this error in the log. If you catch the debug.log on mobile, you will see the error, I suspect in your test scene too.
     
  28. FractalCore

    FractalCore

    Joined:
    May 15, 2009
    Posts:
    151
    Hi, just started using this. Amazing how bad the Unity tonemapping looks by comparison. Even with the three confusing settings it has, it's still impossible to get results as good as with this...

    However. There's one thing the Tonemapping component still does better. Adaption Speed. The automatic brightness adaptation shouldn't happen instantly. There's supposed to be a delay, or at least the option of defining how slowly it adapts to different lighting. Human eyes and camera lenses take a few seconds and it would be perfect if this simulated that.
     
  29. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
    I think adaption speed is needed even if you want it to happen very quickly because right now the screen blinks in some situations, like if you have some animated grass with specularity and animated with the wind or if you use dinamic clothing (as the cloth has a tendency to giggle a little at very fast speed when at rest)

    However, adaption speed would make the code slower, so I think the best aproch is to make 2 versions: one with instant adaption and the other with variable adaption speed.

    In my case, if I have to choose between performance and adaption speed, I choose performance. And I know of a lot of gamers that really don't like the adaption speed effect. For me, tonemapping is needed, but it shouldn't be noticeable.
     
  30. forcepusher

    forcepusher

    Joined:
    Jun 25, 2012
    Posts:
    227
    In this case I will consider creating optional mobile Anti-Aliasing post processing effect.

    Thanks for very constructive suggestion and yep, you both guys right. I've had this idea since the beginning, but some performance and iOS issues just overcrowded it. I will work on adding smooth adaptation right after I release an update that grants iOS compatibility, which will happen after iOS 7 release.
     
    Last edited: Aug 29, 2013
  31. FractalCore

    FractalCore

    Joined:
    May 15, 2009
    Posts:
    151
    That's cool. I didn't realize having it adapt gradually would be slow enough on mobile devices to warrant not having it. I thought it must have been an oversight.

    I generally make higher end PC stuff so not having it is a deal breaker. I can't use it flicking like it does. And I just assumed a script that does dynamic adapting HDR, would do it gradually. I know it's called MOBILE HDR, but still. Might want to mention that up front. Because like I said, add that and this thing is hands down better than what Unity Pro ships with!

    But it's only $15, I'll keep looking in from time to time and see if there's been any updates.
     
  32. forcepusher

    forcepusher

    Joined:
    Jun 25, 2012
    Posts:
    227
    You say that you want to use it for PC build ? I might add a high quality blur algorithm.

    I am happy to announce new upcoming update. It is promising to be absolutely mind blowing.
    I doubt anybody saw such fancy cool effects on a mobile game before.

    Finished:
    1) iOS compatibility was granted, tested on iPad1 and iPad4 (iPhone 4 test scheduled).
    2) Gradual brightness adaptation feature was added with no performance overhead. In fact it became ~2 times faster since now it skips some heavy calculations between frames.
    3) GLES 0x0506 error fix and other random GL errors relating to that.

    Still in progress:
    1) Custom editor interface to make it much more user friendly.
    2) General clean up.


    If any iPhone5 owner who purchased this shader wants to test iOS compatibility - that would be greatly appreciated.
    Price will be raised from 15$ to 25$ or 35$ when the update is released.
     
    Last edited: Jan 23, 2014
  33. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
    Hey, that's very nice! :)

    But I prefer your other avatar, Shame. The pink bunny guy was awesome! xD
     
  34. kaz2057

    kaz2057

    Joined:
    Jan 18, 2011
    Posts:
    326
    This asset is interesting.

    About performance, with new release, what are the performance compared to fast bloom of unity?

    Thanks
     
  35. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869

    I think performance is roughly equal (on PC and Android/OUYA at least) , but I prefer the ouput of this one.
    Very satisfied with it :)
     
  36. forcepusher

    forcepusher

    Joined:
    Jun 25, 2012
    Posts:
    227
    I will do detailed benchmark when I'l add "enable/disable this and that" checkboxes.
    I checked out FastBloom, it did 0.10ms on my PC, while all effects of MobileHDR on high quality did 0.15 ms, so I expect MobileHDR performance to be equal or faster.
    Of course the output of FastBloom just can't compete with the new updated shader. I'm still working very hard on the update.

    All the complicated tasks are done. ETA ~1 week.
    here is the new interface prototype c:

     
    Last edited: Jan 23, 2014
  37. forcepusher

    forcepusher

    Joined:
    Jun 25, 2012
    Posts:
    227
    v2.0 Update completed and up in the Asset Store.
    http://u3d.as/content/science-laboratory/mobile-hdr/4Sj

    What's new:
    - iOS support.
    - MediaTek processor based device suppoort (usually cheap Android devices).
    - Added Gradual Brightness adaptation.
    - Added very efficient high quality blur effect for bloom. Output should look a whole lot better now, so it really fits PC games.
    - Added bloom contrast preservation. Preserves detail on very bright bloomed surfaces (so it's not all solid white).
    - Better Editor layout and more intuitive variable names.
    - Loads of code optimizations.
    - Price increased to 25$ instead of 15$.

    Make sure you delete the old one before importing new one. Location folder was changed.
    Here's some screenshots of devices running that shader.

    iPhone 4S
    $20140125_123356.jpg

    iPad 4
    $20140125_143300.jpg

    Samsung Galaxy S3
    $IMG_0002.JPG

    Prestigio 4055 (cheap device)
    $20140125_143119.jpg
     
    Last edited: Feb 4, 2014
  38. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
    Cool! Thank you Shame! :-D
     
  39. ElementalSpark

    ElementalSpark

    Joined:
    Jul 20, 2013
    Posts:
    9
    I've just purchased. I'm building under Android and it continues to say HDR is not supported and will not apply your script. Followed the very simple readme.txt - Any ideas on why it is not working?
     
  40. forcepusher

    forcepusher

    Joined:
    Jun 25, 2012
    Posts:
    227
    I think that's because HDR on android devices requires "Android Pro". Anyway it should work just fine without HDR rendering, just ignore this warning until you decide to get Android Pro. This is not critical.
     
  41. ElementalSpark

    ElementalSpark

    Joined:
    Jul 20, 2013
    Posts:
    9
    Well, when I apply your script to my camera, it does nothing but throw an error telling me that HDR is not supported on this platform.. I own Unity Pro, but not the Android Pro license.. Does your script require Android Pro? Maybe I am doing something totally wrong? Do I need to set up my player or render settings differently than I am used to with Android development?
     
  42. forcepusher

    forcepusher

    Joined:
    Jun 25, 2012
    Posts:
    227
    Can you give me screenshots of that error and mobile HDR inspector so I could get a better idea of what's going on ?
    I doubt anybody met this problem before. What version of unity do you use ?
     
  43. ElementalSpark

    ElementalSpark

    Joined:
    Jul 20, 2013
    Posts:
    9
    I really think I'm just doing something foolish. Sorry for the blur there, I'm under NDA. Android project, VR enabled.. anyhow, I've tried this with a standard camera too, but with the same results. I thought I'd be able to see the HDR result and build w/o Android Pro? Am I mistaken?

    $MobiHDR_problem.png
     
  44. forcepusher

    forcepusher

    Joined:
    Jun 25, 2012
    Posts:
    227
    Are you sure your texture format is set to "Default" ?
    $wUVuy9z.jpg
    If this doesn't work - try setting it to ARGB32 or ARGBHalf.

    Next thing I would try is turning off anti aliasing and setting your render path to forward rendering.
    $vEaLz1C.jpg $PQEnGEi.jpg

    If this still doesn't help - then try these.
    $CJV3tXz.jpg

    There's another thing: Edit -> Graphics Emulation must be set to "No Emulation". Otherwise unity starts throwing warnings.



    The license comparison page http://unity3d.com/unity/licenses says that this thing is not really supposed to work in non pro version of android, I get the same warning when I use completely free version of unity "HDR RenderTexture format is not supported on this platform. This camera will render without HDR buffers."
    $4Q65C0K.jpg

    So, if steps above didn't help, then it really requires Android Pro to run on Android, but you will still be able to see the results without it, with just Unity Pro (switching platform to standalone might be required).
     
    Last edited: Mar 10, 2014
  45. ElementalSpark

    ElementalSpark

    Joined:
    Jul 20, 2013
    Posts:
    9
    ^ Android pro license required to see it / use it while Android platform is selected. It runs great in standalone, thank you for your time and help. I can use it still for something else. I'll be getting the Android Pro addon soon, I was hoping this didn't have to have A.Pro to use. (As that would be mighty handy for all of us :p )
     
  46. forcepusher

    forcepusher

    Joined:
    Jun 25, 2012
    Posts:
    227
    Problems while running on iPhone 5 and Samsung Galaxy S4 has been reported.
    Most likely related to bugged 3-core PowerVR SGX543MP3 and SGX544MP3 GPUs.
    Sadly, iPhone 5C has the same chip.
    I call this a "bug" because it runs just fine on older SGX543MP2 (iPhone 4S) and newer SGX554MP4 (iPad 4).
    I don't own any of those devices and nobody wishes to help me out by giving me their phone for like a day or two, so fix might take a lot of time.
     
    Last edited: Apr 3, 2014
  47. forcepusher

    forcepusher

    Joined:
    Jun 25, 2012
    Posts:
    227
    Bad news, still no progress. Behavior on different mobile GPUs is way too random, and the source of the problem is unknown :(
     
    Last edited: Mar 13, 2014
  48. JorgeLuis

    JorgeLuis

    Joined:
    Mar 1, 2013
    Posts:
    28
    Do these work in Windows Phone devices??
     
  49. forcepusher

    forcepusher

    Joined:
    Jun 25, 2012
    Posts:
    227
    Untested but supposed to work. Nobody reported any problems with Adreno GPUs.
    Try it. If it wouldn't work - I will refund you.
     
  50. WooZooHo

    WooZooHo

    Joined:
    Jul 4, 2012
    Posts:
    7