Fix ADD accumulation in testrender closure walkers - #2152
Open
tdavidovicNV wants to merge 1 commit into
Open
Conversation
Assisted-by: OpenAI Codex / GPT-5 Signed-off-by: Tomas Davidovic <tdavidovic@nvidia.com>
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Assisted-by: OpenAI Codex / GPT-5
Description
Fixes #2151.
The non-recursive closure traversal introduced in #1897 stopped combining
completed
ADDbranches in two places:evaluate_layer_opacityprocess_background_closureBoth functions still visit the full closure tree, but return only the final
branch contribution. This can make a weighted sum of opaque closures appear
partially transparent when used as the top of a MaterialX layer, and makes an
added pair of background closures return only the second color.
This change tracks the active
branch_weightseparately from theaccumulated_weightof completed branches. At anADD, the second branch andits incoming weight are saved on the stack. When a branch completes, its final
weight is accumulated before traversal resumes from the stack. The traversal
remains non-recursive for OptiX.
This is an internal testrender bug fix and does not change the OSL language or
public APIs, so no documentation update is needed.
Tests
render-mx-layerrenders these expressions side by side, using opaque red andblue top closures and a green base:
They should match, with no contribution from the green base. Before the fix,
the first expression is assigned a top opacity of 0.5.
render-backgroundexpresses the existing environment result as twocomplementary background branches:
Their sum is the previous
Kb * c * background()result, so the existingreference remains valid. Before the fix, only the blue branch is returned.
Local validation on Windows:
testrenderandoslccompleted successfully.idiffcomparisons.testrender, showing the expectedgreen base leak and missing background branch.
Codex was used to compare the recursive and non-recursive traversals, prepare
the reproducers, and draft the fix and regression tests. I reviewed the
resulting changes and test output.
Checklist
and if I used AI coding assistants, I have an
Assisted-by: TOOL / MODELline in the pull request description above.
behavior.
PR, by pushing the changes to my fork and seeing that the automated CI
passed there. (Exceptions: If most tests pass and you can't figure out why
the remaining ones fail, it's ok to submit the PR and ask for help. Or if
any failures seem entirely unrelated to your change; sometimes things break
on the GitHub runners.)
fixed any problems reported by the clang-format CI test.