-
Notifications
You must be signed in to change notification settings - Fork 353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Codegen improvements to surfaceshader mix operator #1104
Codegen improvements to surfaceshader mix operator #1104
Conversation
"}\n\n"; | ||
|
||
const ShaderGenerator& shadergen = context.getShaderGenerator(); | ||
shadergen.emitBlock(FUNCTION_DEFINITION, FilePath(), context, stage); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Material node is now responsible for composing the surfaceshader
components into a single closure.
const bool isBsdfOutput = singleOutput && singleOutput->getType() == Type::BSDF; | ||
#endif | ||
|
||
if (isSurfaceShaderOutput) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic added here is a bit hacky with hard coded handling of surfaceshader
and BSDF
as output types. The reason for this is to keep supporting output of nodegraphs / documents that does not have a material node as the final output terminal (there are many exampels of this in out test suite).
For now this is hard coded here for surfaceshader
and BSDF
types. I have a plan for how to improve and generalize this, but it includes change to our Syntax
and TypeSyntax
classes that I think is too intrusive for 1.38.6. So I'll hold on this until 1.39.
{"alpha", 1.0f}, | ||
{"transmission", 0.0f} }; | ||
|
||
if (node->getCategory() == MIX_CATEGORY) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New logic for transparency detection of mixed surface shaders.
Results for running the whole render testsuite: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a really worthwhile change, thanks @niklasharrysson!
…undation#1104) This change list improves the handling of surfaceshader mix operator in code generation. One notable change is for OSL shader generation, which now implements the surfaceshader type as a struct of separate BSDF, EDF and Opacity components, in order to simplify operations like mixing. Also adds new logic to HW transparency detection to support generations of GLSL shaders with transparency when mixing surface shaders.
This change list improves the handling of surfaceshader mix operator in code generation. One notable change is for OSL shader generation, which now implements the surfaceshader type as a struct of separate BSDF, EDF and Opacity components, in order to simplify operations like mixing.
Also adds new logic to HW transparency detection to support generations of GLSL shaders with transparency when mixing surface shaders.
Attached are some results of mixing surface shaders. There may be some additional changes need on GLSL side to match transparency results better with OSL when mixing shaders. This is left for a future change list to keep this reasonably small.
mix_shader.pdf