Cycles Refactor: Replace fixed Tangent input with custom input #119042

Merged
Brecht Van Lommel merged 8 commits from Alaska/blender:tangent-to-param5 into main 2024-04-26 15:25:25 +02:00
4 changed files with 14 additions and 8 deletions
Showing only changes of commit 26d9cda92c - Show all commits

View File

@ -2392,7 +2392,7 @@ void GlossyBsdfNode::compile(SVMCompiler &compiler)
closure = distribution;
ShaderInput *tangent = input("Tangent");
tangent = tangent->link || tangent->constant_folded_in ? tangent : NULL;
tangent = compiler.is_linked(tangent) ? tangent : nullptr;
/* TODO: Just use weight for legacy MultiGGX? Would also simplify OSL. */
if (closure == CLOSURE_BSDF_MICROFACET_MULTI_GGX_ID) {
@ -2405,7 +2405,7 @@ void GlossyBsdfNode::compile(SVMCompiler &compiler)
}
else {
BsdfNode::compile(
compiler, input("Roughness"), input("Anisotropy"), input("Rotation"), NULL, tangent);
compiler, input("Roughness"), input("Anisotropy"), input("Rotation"), nullptr, tangent);
}
}
@ -3543,10 +3543,10 @@ void HairBsdfNode::compile(SVMCompiler &compiler)
closure = component;
ShaderInput *tangent = input("Tangent");
tangent = tangent->link || tangent->constant_folded_in ? tangent : NULL;
tangent = compiler.is_linked(tangent) ? tangent : nullptr;
BsdfNode::compile(
compiler, input("RoughnessU"), input("RoughnessV"), input("Offset"), NULL, tangent);
compiler, input("RoughnessU"), input("RoughnessV"), input("Offset"), nullptr, tangent);
}
void HairBsdfNode::compile(OSLCompiler &compiler)

View File

@ -481,9 +481,9 @@ class BsdfNode : public BsdfBaseNode {
void compile(SVMCompiler &compiler,
ShaderInput *param1,
ShaderInput *param2,
ShaderInput *param3 = NULL,
ShaderInput *param4 = NULL,
ShaderInput *param5 = NULL);
ShaderInput *param3 = nullptr,
ShaderInput *param4 = nullptr,
ShaderInput *param5 = nullptr);
NODE_SOCKET_API(float3, color)
NODE_SOCKET_API(float3, normal)

View File

@ -294,9 +294,14 @@ int SVMCompiler::stack_assign(ShaderOutput *output)
return output->stack_offset;
}
bool SVMCompiler::is_linked(ShaderInput *input)
{
return (input->link || input->constant_folded_in);
}
int SVMCompiler::stack_assign_if_linked(ShaderInput *input)
{
if (input->link || input->constant_folded_in) {
if (is_linked(input)) {
return stack_assign(input);
}

View File

@ -87,6 +87,7 @@ class SVMCompiler {
int stack_assign(ShaderOutput *output);
int stack_assign(ShaderInput *input);
bool is_linked(ShaderInput *input);
int stack_assign_if_linked(ShaderInput *input);
int stack_assign_if_linked(ShaderOutput *output);
int stack_find_offset(int size);