Fix bug in BSDF code gen for HW languages#1399
Fix bug in BSDF code gen for HW languages#1399jstone-lucasfilm merged 3 commits intoAcademySoftwareFoundation:mainfrom
Conversation
jstone-lucasfilm
left a comment
There was a problem hiding this comment.
This looks like a great improvement, thanks @niklasharrysson, and I had just one question about a remaining comment in the graph definition.
| @@ -148,11 +148,6 @@ | |||
| <!-- Thin-film + Dielectric | |||
| Note: Due to limitations in codegen, the base layer BSDF is duplicated (#1035). --> | |||
There was a problem hiding this comment.
Can this comment now be removed as well?
There was a problem hiding this comment.
Hey Jonathan! I think this comment is meant for the dielectric base layer under thin-film layering. The specular reflection and transmission BSDF's below are also duplicated, in order to have the dielectric layer both with and without thin-film, to blend between. That duplication is needed for another code gen limitation. You can't have the same BSDF node both with and without thin-film (even if it's possible to create such a graph).
However, I have another PR coming up after this one, with the change to thin-film handling that we discussed, where thin-film is set by parameters instead of an extra layer operator. That change will modify this graph as well, and I will remove the comment since it's then no longer valid.
…1399) This change list fixes a bug in code gen for HW languages, where under certain conditions the function call for a BSDF node could be generated multiple times in the same scope. For example, if a pure reflection BSDF node, like oren_nayar_bsdf, where referenced multiple times in a graph. Then during generation of the transmission section of a GLSL surface shader the node's output variable would be emitted multiple times, giving erroneous code. A workaround was previously to duplicate the node in the graph, as for example done in the GltfPbr graph. With this fix duplication is no longer needed.
This change list fixes a bug in code gen for HW languages, where under certain conditions the function call for a BSDF node could be generated multiple times in the same scope.
For example, if a pure reflection BSDF node, like oren_nayar_bsdf, where referenced multiple times in a graph. Then during generation of the transmission section of a GLSL surface shader the node's output variable would be emitted multiple times, giving erroneous code.
A workaround was previously to duplicate the node in the graph, as for example done in the GlftPbr graph. With this fix duplication is no longer needed.