diff options
author | Lukas Toenne <lukas.toenne@googlemail.com> | 2013-09-23 12:57:02 +0400 |
---|---|---|
committer | Lukas Toenne <lukas.toenne@googlemail.com> | 2013-09-23 12:57:02 +0400 |
commit | a18d89e14f6498e2733be6d7a06f6371b6e26c91 (patch) | |
tree | 6f2b9736257bcf11e0c6bd3fe9b48e10cfff3488 /intern | |
parent | 826a7db5c06c809defe8108d2532c7290cda7fef (diff) |
Fix #36790, OSL point parameters of shader nodes not initialized correctly from UI inputs.
normal and point parameter types of OSL shaders are creating SOCK_VECTOR sockets in the script node. When these sockets are in turn used to define the fixed input values for these parameters they get
converted as OSL vector always, losing the distinction of vector/normal/point. To prevent OSL rejecting the value due to type mismatch, explicitly define the parameter defaults in the OSL script node
compiler function as vector, normal and point (unused types will simply be ignored).
Diffstat (limited to 'intern')
-rw-r--r-- | intern/cycles/render/nodes.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp index 70cb5613e61..455ee69899b 100644 --- a/intern/cycles/render/nodes.cpp +++ b/intern/cycles/render/nodes.cpp @@ -20,6 +20,7 @@ #include "osl.h" #include "sky_model.h" +#include "util_foreach.h" #include "util_transform.h" CCL_NAMESPACE_BEGIN @@ -3677,6 +3678,27 @@ void OSLScriptNode::compile(SVMCompiler& compiler) void OSLScriptNode::compile(OSLCompiler& compiler) { + /* XXX fix for #36790: + * point and normal parameters are reflected as generic SOCK_VECTOR sockets + * on the node. Socket fixed input values need to be copied explicitly here for + * vector sockets, otherwise OSL will reject the value due to mismatching type. + */ + foreach(ShaderInput *input, this->inputs) { + if(!input->link) { + /* no need for compatible_name here, OSL parameter names are always unique */ + string param_name(input->name); + switch(input->type) { + case SHADER_SOCKET_VECTOR: + /*parameter_vector(param_name.c_str(), input->value);*/ + compiler.parameter_point(param_name.c_str(), input->value); + compiler.parameter_normal(param_name.c_str(), input->value); + break; + default: + break; + } + } + } + if(!filepath.empty()) compiler.add(this, filepath.c_str(), true); else |