Search Unity

Bug Path Tracing - Light size affects other lights

Discussion in 'High Definition Render Pipeline' started by OlavAketun, May 5, 2022.

  1. OlavAketun

    OlavAketun

    Joined:
    Aug 4, 2021
    Posts:
    47
    Hi

    I've found this very strange artifacting with Path Tracing when having multiple lights in a scene that have varying sizes.
    When they "intersect" with each others range, and have a wide size, shadow artifacts will show themselves.

    Wide size example:
    1_WideLightSize.PNG

    Narrower size example:
    2_NarrowLightSize.PNG

    Since emissive surfaces don't really cut it when trying to light up a scene, we'd have to use lights. This makes it near impossible to work with interior scene where we rely on lights. Using lights help the noise of the PT but when you get artifacts like that it's hard to justify it.
    While it might look like it's gone when using a smaller size, but only slightly.
    In these examples the lights have a size of 0.025 or 0.05, which is pretty much the size of the lights they are representing. And the issue is still present as you can see.
    3_RealExample1.PNG
    3_RealExample2.PNG
    3_RealExample3.PNG

    These are not shadows of anything but artifacting caused by light intersecting with each others range it seems.
     
  2. OlavAketun

    OlavAketun

    Joined:
    Aug 4, 2021
    Posts:
    47
    Perhaps an unsolveable issue?
    This has been there since I first looked at the pathtracer in unity, and that was last august.
    I know they are updating the pathtracer with each version, but this issue seems to not be solved yet.
     
  3. OlavAketun

    OlavAketun

    Joined:
    Aug 4, 2021
    Posts:
    47
    Been a while, but I can post an update on my findings.
    This is related to a hardcoded limit of how many lights the pathtracer can handle.

    PathTracerLights snippet.png

    Setting this to anything higher will fix the issue.
    Why was it set to 16 in the first place? Seems like a number chosen by random rather than anything else.
    In our projects we use many, and I mean MANY lights per scene. Leaving it to default will cause those ugly shadow artifacting everywhere each light intersect. Setting it to 64 (random number but a higher random number), now those artifacts are gone. With more or less no impact to performance why not increase the number, or better yet actually use a value that can be exposed in the Post Processing volume.
     
    imblue4d likes this.
  4. vlastan

    vlastan

    Joined:
    Nov 15, 2015
    Posts:
    49
    Hi, i am facing this problem while rendering many light in HDRP path tracing mode. Can you please provide an explaination on how and where to edit the max light count ? Thanks a lot
     
  5. OlavAketun

    OlavAketun

    Joined:
    Aug 4, 2021
    Posts:
    47
    You will have to copy the HDRP package from 'Library/PackageCache' to 'Packages', then navigate to '\Runtime\RenderPipeline\PathTracing\Shaders' and open the 'PathTracingLight.hlsl' in a text editor.
    In that shader file find the MAX_LOCAL_LIGHT_COUNT and set its value from 16 to something much higher.
    Save and go back to Unity, it will now compile and the ugly shadow artifacts are gone.

    You had to make a local copy of the HDRP package because Unity will re-download the package and overwrite any changes you make.
     
    JGroxz, esgnn and vlastan like this.