Search Unity

Lighting noise and custom light wrap

Discussion in 'General Graphics' started by andyz, Jan 13, 2020.

  1. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,276
    I am still using a deferred legacy graphics pipeline and forward on mobile with custom shaders as the built in pipelines seem to miss out on some important features. Not sure that LWRP covers these but using the new SRP may work.

    1. Lighting noise - without the addition of noise you get gradient effects and things do not look good if you have certain lighting! I do not think it expensive and use it with replaced shader cginc file.

    2. Normal lighting affects half of a sphere which is ok and correct if no light bounced around! But a cheap way to brighten the whole scene, particularly with 1 or few lights, is to use wrap-lighting to spread the lighting around 360 degrees and almost simulate bounced light. As done by valve many years ago. We only get standard lighting calculations now deep in Unity.cginc files.
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,348
    This is explicitly not done by the SRPs because the expectation is to render with an HDR render target and apply noise during post processing when converting back to the final low dynamic range output. It might make sense to add for some mobile or VR projects where HDR or post processing isn't an option. The issue is with overlapping lights if you're not careful the noise will be accentuated unless you can randomize it per-light. There are also problems with adding the noise too early as most rendering these days is done in linear space, but you want the noise to be in gamma (sRGB) space. If you do the noise while doing the lighting, you can't always know the final brightness of the pixel and thus the noise might not properly match the sRGB ideal.

    Half lambert is great for certain looks and faking subsurface scattering or bounced lighting, and used even today in AAA titles for certain effects. Notably the moss in Uncharted 4 is using half lambert shading*. But it's not something supported by default in either of the SRPs. Especially not the HDRP since it has more robust subsurface scattering and GI stuff built in, so it doesn't need to fake it. For the LWRP/URP it'd certainly be a nice to have, and some of the toon shader examples actually implement it (then slap a toon ramp on top).

    * It's also doing a lot more than that. http://advances.realtimerendering.com/other/2016/naughty_dog/NaughtyDog_TechArt_Final.pdf
     
  3. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,276
    Useful info thanks. I am a bit behind with no hdr and gamma still, based on low spec, vr and mobile. But noise and half lambert make all the difference here.

    Sometimes it's hard to tell if Unity has a good target pipeline for this level, especially if runtime procedural level gen.
     
  4. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,348
    There's no reason not to keep using the built in pipelines if they meet your needs. The LWRP/URP has the benefit of doing multiple lights in a single pass, which is better for VR (specifically w/ MSAA), and which means you can know the final surface color (ignoring post and any transparencies) for the noise to be optimally calculated.