Search Unity

How to make AAA graphics in Unity/Enlighten

Discussion in 'General Discussion' started by Billy4184, May 18, 2017.

  1. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    6,493
    Yes but there is no actual light value, since the light value is the color themselves, it is compute per component.

    It's more interesting to see why green is having a bigger weight, which is something that were already done in 16bits era with 565 bit attribution's pattern. And it's also teh rational behind camera sensor using bayer's pattern (50% green, 25 for everything else):

    Why more green, what is the relation with light intensity?

    Reverse searching from these lead, the wikipedia is saying:
    Well there it is ... I learned something thanks!
     
    Martin_H and frosted like this.
  2. GarBenjamin

    GarBenjamin

    Joined:
    Dec 26, 2013
    Posts:
    7,441
    @Billy4184 you'll have to excuse this if it is an ignorant line of thought. Do you think maybe you are trying to "automatically" get a perfect scene using settings for light and whatever there is available you are adjusting... and maybe the way the AAA games get there is through spot tweaks?

    I mean just maybe they make a scene and have these same overlit areas so they adjust those. Like if you used the exact same texture for those "blown out" rocks but on a different material that was darker... what effect would that have? Would it get rid of those brightly lit rocks?
     
    Last edited: May 21, 2017
  3. frosted

    frosted

    Joined:
    Jan 17, 2014
    Posts:
    4,044

    Right. The question is, is the presence of green encoding in pixel data the correct measure to adjust exposure for tonemapping?


    Should the left side be treated as much darker than the right side before being handed off to ACES? I'm very skeptical of this.

    In terms of "light" in a 3d engine, we have measures of this through shadow/light maps. So the engine produces a greyscale map of "light", which it uses to modify the colors present in textures.

    What if, instead of using green, we used the light/shadow maps to determine "brightness" -- what would that look like?

    I'd like to find out. It might be really cool, who knows. It might even be better.

    The idea simply, is given that the 3d engine is calculating out light - we don't need to infer brightness from rgb values, we can simply use the actual light calculations to determine the range of brightness in a scene.
     
    Last edited: May 21, 2017
  4. DominoM

    DominoM

    Joined:
    Nov 24, 2016
    Posts:
    460
    Sorry for the scaling in the Sponza file. You can reimport the obj without generating materials at smaller scale (I used 0.01) and it should be ok. I'll update the download when I get chance tomorrow. In the meantime I've had a go as an absolute beginner to Unity lighting (though somewhat familiar with the concepts from Blender) and here's my Sponza so far.
    Sponza01.png
    It has baked ambient and two realtime directional lights. Any suggestions on what to do next to improve it would be welcomed.
     
    frosted likes this.
  5. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    6,493
    No because albedo ("color" for profane) are the actual percent of light reflected, ie we use albedo map to weight the analytic light to actual light (ie the response of the material). Lightmap are only reflected light given an ideal white material.

    But I still want to see what happen if you do your way, it will be interesting :p

    Also how true is your example, it looks green on the left, but it still a composite image in RGB, so what is teh component deconstruction? I'll bet the green component is still rather present in the blue, so it must be proportional assuming it's equiluminance.

    And there is something call the purkinje effect (color shifting toward blue in darkness by the eyes, hence why so many art depict night with blue), and blue is notoriously known as a recessive color .
     
  6. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    6,014
    Well, the only way is to find out. I'm just going to practice trying to find something relatively automatic in both engines, and if the results are the same then it's pretty clear that it's a question of handiwork. At least at the end I'll have the best solution for my situation.
     
    GarBenjamin likes this.
  7. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    6,014
    Try it out and see :)
     
  8. frosted

    frosted

    Joined:
    Jan 17, 2014
    Posts:
    4,044
    The example swath is specific to have combined average RGB values equal across range.

    Base
    upload_2017-5-21_17-55-30.png

    Desaturate Luminosity
    upload_2017-5-21_17-56-3.png

    Desaturate RGB Average
    upload_2017-5-21_17-55-44.png

    This effect is because as light dims the rods in your eyes take over. Rods in eye are "color blind" (they only pick up one wavelength - a bit between green and blue). The cones in your eyes are generally responsible for RGB, but these are only dominant in brighter light (they are not as sensitive to light overall as rods are).

    So in very dark conditions, what you will see is closer and closer to actual greyscale (tinted blue/green).

    Rod spectrum shown in dotted line
    In general, the rods and rod pathways are responsible for helping to determine the form of what you're seeing. Even in bright light, the rod pathways will be used by cones to assist in creating a sense of contrast and silhouette.

    It is so cyan, clearly this is pitch black :)
     
    Last edited: May 21, 2017
  9. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    6,493
    So the answer you are looking for is that tonemapping should not be just based on overall brightness but adjusted on a per component basis + luminance? Ie adjusting colors based on luminance to have a proper eye reaction?
     
  10. frosted

    frosted

    Joined:
    Jan 17, 2014
    Posts:
    4,044
    Maybe, yeah... this is pretty funny.


    So this guy wrote about aces tonemapping specifically.
    https://knarkowicz.wordpress.com/2016/01/06/aces-filmic-tone-mapping-curve/

    The code in the aces tonemapping in the version I'm using is clipped exactly from that article:
    Code (csharp):
    1.  
    2. half3 tonemapACES(half3 color){
    3.     color *= _Exposure;
    4.  
    5.     // See https://knarkowicz.wordpress.com/2016/01/06/aces-filmic-tone-mapping-curve/
    6.     const half a = 2.51;
    7.     const half b = 0.03;
    8.     const half c = 2.43;
    9.     const half d = 0.59;
    10.     const half e = 0.14;
    11.     return saturate((color * (a * color + b)) / (color * (c * color + d) + e));
    12. }
    13.  
    It's worth noting though at the bottom of the article he includes this note:
    So basically, in the ACES tonemapping (at least in the older version I'm using), the code was lifted from a guy who says that it will over saturate brights because it's too reliant on luminance...

    The code may have been updated in the newer "Post Stack" but in the older "Cinematic Effects" the guy who wrote the calculation says it will over saturate bright spots.

    Look! I'm totally not crazy! :D
     
    Deleted User likes this.
  11. Martin_H

    Martin_H

    Joined:
    Jul 11, 2015
    Posts:
    4,436
    You really should upgrade. In the current version the code you quoted looks different and has different numbers. And there is this:

    Code (csharp):
    1.  
    2. #include "ACES.cginc"
    3.  
    4. // Set to 1 to use the full reference ACES tonemapper. This should only be used for research
    5. // purposes and it's quite heavy and generally overkill.
    6. #define TONEMAPPING_USE_FULL_ACES 0
    7.  
    I've compared the two and made a side by side comparison (split right in the middle):



    One of them is ever so slightly darker, but it's totally negligable. I agree that it's overkill if the full calculation is more expensive.
     
    Deleted User, Billy4184 and neoshaman like this.
  12. frosted

    frosted

    Joined:
    Jan 17, 2014
    Posts:
    4,044
    I would have felt more need to upgrade if I knew they totally fixed the tonemapper.

    The difference in the version I'm using is a bit more pronounced...Here's the histogram:

    2017-05-21_19-48-42.png
    Unity_2017-05-21_19-48-27.png

    That's the level of difference between the original code and the suggested code. I had no idea the tonemapper I was using was close to broken, it certainly explains a lot.

    In all seriousness, I've lost tons and tons of hours to trying to get vivid color without blowout. This explains a great deal of it.
     
  13. Deleted User

    Deleted User

    Guest

    @frosted

    You know you can just tone down the highlights in photoshop right (especially good for crap bloom post)? One of your biggest friends throughout your graphics journey is the LUT..
     
  14. frosted

    frosted

    Joined:
    Jan 17, 2014
    Posts:
    4,044
    Yes. There's a difference between tonemapping and grading,

    if the tonemapping and eye adapt is shifting the range to blowing out the highs consistently, there is going to be problems with the results regardless of grading. You can make a screenshot work, but in game it's going to be a nightmare when you have dramatically varied lighting / condition.

    That Histogram was not the product of bloom, it was the same set of settings, same camera rig - only difference was using one ACES calculation vs the other.
     
  15. frosted

    frosted

    Joined:
    Jan 17, 2014
    Posts:
    4,044
    John Hable's Uncharted 2 talk

    http://www.gdcvault.com/play/1012351/Uncharted-2-HDR

    Covers some details on:
    - Gamma vs Linear space color
    - HDR
    - Tonemapping (ACES, Reinhardt)
    - AO/GI

    Good level of detail in the talk, he's very specific without being overly technical. This talk is highly cited by people doing graphics, lighting, tonemapping work. It was very influential.

    It's maybe the single best overview on how these different elements work together.


    Researchers at Disney working on local tonemapping:


    This tonemapping approach maintains detail and resists blowout even when dealing with extremely large changes in light. If you look at this video, the results are immensely better.
     
    Last edited: May 22, 2017
    Martin_H and neoshaman like this.
  16. DominoM

    DominoM

    Joined:
    Nov 24, 2016
    Posts:
    460
    I've updated the Crytek Sponza for Unity template.

    It now has correct scaling, all the Sponza objects are marked static and I added a simple screen shot script on main camera (key F12). My lighting isn't in the template so you have a clean slate to start from.

    I've added Ambient Occlusion & Final Gather to my baking and altered my two directional lights and post for this version.

    Sponza04.png

    Is the overly dark seeming shadows on the green and red fabric compared to blue the reason you were discussing eye responses?
    Is the best way to improve that with a LUT that adds a bit of blue into red/green shadows?
     
    Martin_H and frosted like this.
  17. frosted

    frosted

    Joined:
    Jan 17, 2014
    Posts:
    4,044
    I'm not an expert, and I can still be misunderstanding some of the material I've been reading.

    But basically yeah, the shadows on the blue are softer than the shadows on the red and green because the blue is considered a darker color, so the shadow has lower contrast.

    The result is a soft shadow on the blue, and harsher shadows on the greens and reds.

    Changing the color grading might be a smart way to address that - but it will also change the hues a bit. I'm honestly not sure what the solution is (?)

    ___
    Look's good btw, obviously a huge step forward from the last one!
     
  18. Martin_H

    Martin_H

    Joined:
    Jul 11, 2015
    Posts:
    4,436
    Imho absolutely not, because that would also change all the colors in that range that actually should be there on other objects. I'm not at all familiar with the baking stuff, but to me it looks like you should look for the cause there. Compare the front red curtain with the red one far back where the shadow is far less dark. Also where is that light on the top edge of the red curtain on the left coming from? That looks like skybox reflection to me, and imho shouldn't be there. You could try adding more reflection probes.

    I'm always confused when you mention the RGB perception things because it's the first time I hear about that making big differences in realtime CGI. I've certainly heard it often in color theory material that some color hues are perceived as brighter than others but it never was a big deal to me. The way I see it, areas on which the sun casts a shadow should - without GI - look exactly the same as if the sun wasn't there (only lit by ambient light and reflections) and if GI is present, then it's ambient light + reflections + GI.

    Dumb question, but do you know how the basics of light/material interaction work? Because imho that actually would explain brighter shadows on blue than on red a lot better in this scene. Since the ambient light coming from the sky is blue, most of the light still hitting cast-shadow areas is blueish (sky's shade of blue in the ambient light plus warm colors from GI contribution), and a "perfect red" material would not reflect "perfect blue" at all, but a "perfect blue" object would reflect nearly all of "perfect blue" light.
    Try making 3 cubes red, green, blue with maxed out R G B color values, shine a bright light on them, make the light 255/0/0 and then turn the hue slider. You'll see varying degrees of light reflection on the cubes, based on how much of each RGB component is present in the light. Make the light cast a shadow across all cubes with a 4th cube, to have a comparison of how it should look without the influence of the light.

    Though I still think messed up GI on the curtain is more likely, because the ambient light isn't that strongly tinted.
     
  19. DominoM

    DominoM

    Joined:
    Nov 24, 2016
    Posts:
    460
    Thanks, on the first one I was imaging it in a zombie shooter (lots of shadows for things to hide in) and ended up where the scene was under lit. Most of the improvement is just from turning the lights intensity up :)
     
  20. Martin_H

    Martin_H

    Joined:
    Jul 11, 2015
    Posts:
    4,436
    In that case you could try one that is only lit by the sky, using baked GI and AO, and play with contrast and color grading in post. I might give it a try myself, sounds like a fun idea.

    By the way, thanks a lot for uploading the Sponza scene! I gave it a go myself just for fun and you made it really easy for us :).



    Setup: no pre-baked lighting, all realtime, one directional light, custom color gradient for ambient light, some reflection probes (although they don't do much for this scene because nothing is shiny), and tonnes of post (even stacked 2 SSAOs). Might have overdone it a tiny bit with the contrast and colorgrading.
     
    Peter77 likes this.
  21. DominoM

    DominoM

    Joined:
    Nov 24, 2016
    Posts:
    460
    Yeah, I was thinking the banner colours are digital primary (deliberate to test lighting edge cases?), so I end up with a digital black, where a perceived real world black might be a dark grey with a hint of blue (kinda like my logo black verses the post button black, though I think I went with a hint of green there). Hence my wondering if a LUT to map the digital blacks to more realistic looking ones was an option.

    I've currently no reflection probes, so I'll make that my next job on this.. It's going to end up a long thread if the entire "How to" is learning from my mistakes :D
     
    frosted and Martin_H like this.
  22. DominoM

    DominoM

    Joined:
    Nov 24, 2016
    Posts:
    460
    Given the thread title I'm kinda expecting materials to be part of the discussion at some point, so if AAA attention to detail means something needs to be shiny I'd vote for going for it. I saw one with a gold lion before..
     
    Martin_H likes this.
  23. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    6,493
  24. Martin_H

    Martin_H

    Joined:
    Jul 11, 2015
    Posts:
    4,436
    I liked your idea so much that I gave it a go:

     
    Gametyme, cyberpunk, Arowx and 7 others like this.
  25. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    8,194

    Added attempt at Mech and played with the Post settings to try and get a more vibrant look.
     
    Gametyme, ManAmazin, kB11 and 2 others like this.
  26. Deleted User

    Deleted User

    Guest

    I cannot believe the amount of time I ended up wasting on this :)..

    I tried to match the lightbox with the UE one and I'll be honest, failed miserably.. I couldn't get skybox calibrated for colour contrast w/ proper diffuse reflectence (I've been stepping out doors constantly measuring the impact of atmospheric intervention) .. I couldn't post process it because it ended up causing issues on other areas, it really looked boxy for some odd reason and everything was shadowed + AO'd incorrectly (when baked).

    The bake times are silly long..

    I kept getting lightmap resolution errors, when I switched to enlighten the strong colour bounce washed it straight out of being physically accurate. So I was seperating layers in photoshop and even that couldn't properly correct it because there was too much light bleed. I think I got away with it on my original test because the materials were hiding it.!

    Now I'm sure someone with a lot more experience / time on there hands could get it pretty close, but I gotta be blunt here.. The quickest most efficient way for me to improve rendering is to click the uninstall button on Unity and forget it ever exists, I think getting used to the engine and it's quirks / pipelines is far more important than anything else.. Even when it comes to graphics.!
     
    Last edited by a moderator: May 24, 2017
    Billy4184 likes this.
  27. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    6,014
    Would be interesting to see your results anyway ..
     
  28. Deleted User

    Deleted User

    Guest

    This is where I got before I gave up, to me personally it looks horrible in every concievable way.! I've put the UE one up for comparison.. I mean, even if you can beat the UE one hands down.. Its taken me hours of messing about with long bake times, I can set up a scene like that lightbox in 20 minutes with Unreal (including bake times)..

    UnityLightbox.jpg

     
    Velo222, Billy4184 and neoshaman like this.
  29. GarBenjamin

    GarBenjamin

    Joined:
    Dec 26, 2013
    Posts:
    7,441
    Looks good man! Remember it doesn't matter how much time it takes only that you are putting forth maximum effort! :)
     
  30. OCASM

    OCASM

    Joined:
    Jan 12, 2011
    Posts:
    328
    Or just use the progressive lightmapper.
     
  31. iamthwee

    iamthwee

    Joined:
    Nov 27, 2015
    Posts:
    2,149
    @ShadowK
    That is one hell of a difference, if you care to share the .obj file (not fbx or max), I'd like to have a tinker with enlighten.

    I got this result from my game which I didn't think was too bad for enlighten. baked.jpg
     
    Gametyme and Deleted User like this.
  32. Martin_H

    Martin_H

    Joined:
    Jul 11, 2015
    Posts:
    4,436
    Thanks a lot for investing so much time and sharing your results! I see why you are unhappy with it.
    I wouldn't expect it to be possible to get them the same result like this, since it seems you haven't laid out the textures the same way. The windowframes lack the wood texture, the outside walls and floors are way darker (which probably has a fairly big impact on indirect light getting in through the windows, at least it should), the light bleed edge on the ceiling might be fixable with thicker walls, and the different tint of the wood suggests that colorgrading settings are fairly different.
    I have no experience with the progressive lightbaker but it sounds like this would be a good candidate for a test. If you can find the motivation to give it another go, I'd love to see it with the different baker! It should be way more fun to work with too, since it's more interactive.



    About my "Dystopian Sponza" - I'm happy it was so positively received. And it got me wondering why? I mean, I kinda like it too, but that doesn't necessarily mean anything. It's not something that I'd imagine people commonly find "pretty". My best guess is, that it's interesting, simply because it's a bit different and the normal sunlit Sponza scene has been done to death. Thoughts?



    @Arowx: I think you way overdid it with the chromatic aberation, but apart from that I think this might be the most polished visual I've seen from you so far. Good job.
     
  33. iamthwee

    iamthwee

    Joined:
    Nov 27, 2015
    Posts:
    2,149
    I'm not sure about anyone else, but my testing with progressive lightmapper I found the bake times about the same and lighting worser (not by much) than enlighten - enlighten has a subtle GI effect which progressive lightmapper lacks IMO.

    The only advantages I found was real time feedback and better coping with larger scenes. I reckon I could get enlighten close to the unreal one, perhaps maybe faking the light by putting a large area light in front of the windows.
     
  34. Deleted User

    Deleted User

    Guest

    Nope, I did test it in the exact same format as the Unreal one.. With the same textures / setup and everything, it looks no different really... Billy wanted to see it, I'm not willing to spend another second on it so I posted it in the state it's in.!

    If I get better results faster with X, it doesn't really matter.. You use whatever gives you the advantage.

    @OCASM

    That is the progressive lightmapper.. But let's check out the original one I did in Unity (again with the progressive lightmapper) to match anywhere near the quality of my UE example I'm masking issues with shadows, I'm using multiple area lights and using "blocking" volumes to get rid of the horrid lighting that comes from directional lights so I could get some physically correct inverse square and match the soft shadows that come default with UE (in realtime):

    But the bake times are silly.! I mean I'm not running a wind up PC here, its 14 core 3.6GHZ xeon.! Unreal bake time (1 minute (production quality), Unity 23 minutes, which ain't bad by itself but it's an empty corridor.!?!

    You also got to remember, the lightmapper is a beta item..

     
    Last edited by a moderator: May 25, 2017
  35. Martin_H

    Martin_H

    Joined:
    Jul 11, 2015
    Posts:
    4,436
    Totally understandable!

    If you wanna zip and upload it, I might tinker with it on the weekend, but I only have a normal i7 and way less patience for bake times than you. So I'm not sure anything will come of it.
     
    Deleted User likes this.
  36. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    6,493
    It's because it say something and it say it very well, it's DYSTOPIAN sponza and that was well reflected. Context matter in aesthetics.
     
    frosted and Martin_H like this.
  37. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    6,014
    Thanks for showing. I wouldn't want to take my 540m anywhere near that ..

    The lightmapper's obviously got issues that need to be sorted out, it's clearly not ready. Although to be honest, I didn't really like the village shot myself:



    Lighting is a bit uncomfortable and harsh - but again maybe we just have to wait for a bit until things improve. Only when it comes out of beta we can really judge the quality.
     
    Deleted User likes this.
  38. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,750
    Yeah the progressive lightmapper is very slow. much slower than it should be.
     
  39. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    8,194
    I wonder if lightmaping would be quicker if the GPU was utilised, after all GPU's have massive core counts and are designed to work with vector operations.

    Is that what Unreal are doing using compute shaders to speed up the lighting calculations?
     
  40. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,750
    No, not really.
     
  41. OCASM

    OCASM

    Joined:
    Jan 12, 2011
    Posts:
    328
    Seemed to run fast enough when I tried it on my ancient E8400. You must be using very extreme settings.

    If you guys really want to make a comparison between Lightmass and the PL just make a simple Cornell box. That's the standard way to test different lighting technologies without interference.

     
  42. iamthwee

    iamthwee

    Joined:
    Nov 27, 2015
    Posts:
    2,149
    Yeah I'm getting gorgeous lighting with my lightbox in enlighten with bake time 1-2 minutes
     
  43. frosted

    frosted

    Joined:
    Jan 17, 2014
    Posts:
    4,044
    This is done with massively cranked bounce settings?

    The indirect color reflection is really intense here, wondering what conditions/settings you used.

    Is the AO baked or screen space?

    Looking carefully, I can't help but think that this has quite a lot of color correction. If not, I'd really love to see the setup used here.
     
    Last edited: May 25, 2017
  44. Deleted User

    Deleted User

    Guest

    It was highest resolution settings with as many bounces as it could do, just like I had it setup in UE.. I'd love to see this "gorgeous lighting" you get with Enlighten.. I've yet to see an example, even from Enlighten themselves :)..!

    It's great for some cheap GI that can be used in near enough any game though.! So can't fault it.
     
  45. Martin_H

    Martin_H

    Joined:
    Jul 11, 2015
    Posts:
    4,436
    "Cranked to max" doesn't seem like the best setting for a fair performance comparison to me. It should rather be tweaked for visually comparable Quality, and then compare the times. The max settings might be capped at more reasonable values in UE, maybe. Just speaking in general, I don't doubt UE bakes faster and better.
     
  46. Deleted User

    Deleted User

    Guest

    Actually no, Unity was capped at 4 bounces 2K... UE was set to 100 bounces / 2K, anyway It's been fun but no matter how it gets spun nothing else is going to get done with it. Looking forward to seeing what you guys come up with..
     
    Martin_H likes this.
  47. Adam-Bailey

    Adam-Bailey

    Joined:
    Feb 17, 2015
    Posts:
    232
    While you are working turn down the direct and indirect quality. With lightmap filtering in it still looks clean and is so much quicker than Enlighten.
     
    Deleted User likes this.
  48. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    6,014
    Looking forward to seeing plenty of results from the progressive lightmapper posted here :)
     
  49. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,750
    I use a lot of small emmisive materials, which are kind of progressive's weakness at the moment. The noise from that doesn't clean up, at all.

    And I hate the filtering. It's only good for while you're working (as you said), but other than that, it looks much worse than any enlighten result.
     
    Adam-Bailey likes this.
  50. frosted

    frosted

    Joined:
    Jan 17, 2014
    Posts:
    4,044
    Unity_2017-05-25_22-55-38.png
    Any thoughts on lighting here? I have real problems with dark scenes. I just cannot bring myself to just make everything teal.



    Last time I redid this scene it looked like this:
    The colors here are extremely dark, but overall like this one more, even if its too dark. I love the colors, they're cold and harsh... but not.



    2017-05-25_20-52-29.png
    Here's a warmer, friendlier version. This is a tavern that says "sit down, take a load off, have a glass of meade on me, friend".


    I'm shooting for something harsher, but I thought I would include a warm, bright version.

    Any thoughts? No GI, everything realtime. I think the lighting is quite good considering.