Improvements to closure addition in HW shading#2351
Improvements to closure addition in HW shading#2351jstone-lucasfilm merged 3 commits intoAcademySoftwareFoundation:mainfrom jstone-lucasfilm:main
Conversation
This changelist proposes improvements to the computation of throughput in the GLSL implementation of closure addition, deriving the math from our implementation of albedo scaling in vertical layering. I'm very interested in feedback and review on this proposal, in order to make sure the assumptions I'm making here are correct.
|
@lkerley @niklasharrysson @fpsunflower In thinking through this proposal, I found it helpful to work through a few concrete examples, and I'll share them here: The sum of two light-admitting lobes is a light-admitting lobe: The sum of two light-blocking lobes is a light-blocking lobe: The sum of a light-admitting and light-blocking lobe is a light-blocking lobe: The sum of two partially-blocking lobes is a more strongly-blocking lobe: |
|
My sense is that this is a good step forward, but let me know if you have additional thoughts or recommendations on the change. |
|
I think this could be an improvement, but Its a little hard for my head to wrap itself around - I'm slammed with other things right now, but I'd love to make some pictures and compare them to some sort of reference. I did find a concrete example that felt like it might not be the most optimal - so its something I think we should look at pictures for (I'll make them when I get a chance if someone else doesn't first). The sum of two lobes that block exactly half, end up blocking everything. I think this is where my brain is trying to bring this back to some sort of physical material construction, but for I'm not opposed to making this improvement, if we can make some pictures and demonstrate it does improve things (meaning bring them closer to a reference implementation). But I do wonder if we should revisit Niklas suggestion of retiring |
|
I don't exactly follow the derivation, but the final formula doesn't "feel" right to me either. Have you tried comparing with how layering is implemented in OSL's testrender? |
|
Keep in mind that this logic is for closure addition via @fpsunflower If you have a good reference for closure addition in OSL that we could use, I'd be more than happy to refine our logic based on this. |
|
@ld-kerley @fpsunflower In order to provide better framing for this proposal, it's worthwhile to highlight that closure addition is a deeply non-physical operator. In contrast to physically based operators such as closure Although one might propose that non-physical operators ought to be disallowed entirely in MaterialX and OSL, many industry shading models actually require this level of control, including public models such as PxrSurface and UnrealDefaultLit, as well as internal shading models used within film and game studios. And although the math for combining reflection responses in closure addition is straightforward -- it's simple addition, after all -- the math for combining throughputs is less so, and it likely falls more in the domain of plausibility and intuition than the domain of physics. It's important that the sum of two closures have a throughput that is no greater than that of either of its two inputs, otherwise adding more and more specular layers would have the illogical effect of increasing the reflectivity of any diffuse layer beneath them in the stack. This proposal represents one straightforward solution that meets this hard requirement, while providing more intuitive behavior than any of our previous implementations for the cases highlighted above, but I'm certainly open to other proposals that achieve this goal using different math. |
|
I see what you mean. In looking at how testrender handles this -- it may have gotten broken by the recent refactor we did to get testrender running on the GPU. But previously the logic would have just added the throughputs AFAICT. I think our newer code is not handling this case correctly (although maybe I'm missing something subtle). I think the best course of action would be to come up with concrete unit tests so we can debug the behavior visually. |
|
That makes sense, @fpsunflower, and I'll bet many renderers are in the same camp as Although closure addition by itself is commonly used, I suspect it's very rare that a shading model would sum two closures and then perform a physically based Since this proposal represents one plausible solution to the problem, and it handles edge cases better than any of our previous implementations, my thinking is that we should move forward with this for now. As we learn more about how other renderers handle this unusual case, we will likely find an even better solution, but I don't see a good reason to hold off on this improvement until we've fully completed that deep dive. |
|
I also have problems wrapping my head around what the physical meaning of throughput would be when doing unbounded addition of two BSDF's. But since this is a non-physical operation anyway, it's probably not too important as long as the result looks feasible and doesn't explode in the edge case that someone would try to combine this with physical layering. Your derivation seems logical to me - If two lobe reflectances are added unbounded their directional albedo could also be added (in the same unphysical anyway), so But it would be interesting to see results, comparing this to a path traced reference of the case where an unbounded mix of two BSDFs are layered over a third BSDF. |
|
I wonder if perhaps we should consider moving |
|
@ld-kerley That's a very principled suggestion, and certainly worth considering. The main holdup is that closure addition in MaterialX has inputs and outputs of type Another option would be to clearly document that closure Here's our current, very minimal documentation for closure |
|
Let's move forward for now, in the interest of not making the perfect the enemy of the good, but I'm very interested in ideas for improving this math in the future. If we ultimately decide that closure addition should be replaced by a better concept in MaterialX and OSL, I'm very open to that as well, but that sounds like a much deeper research topic for our two teams. |
f9c3862
into
AcademySoftwareFoundation:main
This changelist proposes improvements to the computation of throughput in the GLSL implementation of closure addition, deriving the math from our implementation of albedo scaling in vertical layering.
I'm very interested in feedback and review on this proposal, in order to make sure the assumptions I'm making here are correct.