diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-02-18 05:20:39 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-02-23 20:57:58 +0300 |
commit | a963c7d48dade70474ec3b40bea5e99ebdbbc5d4 (patch) | |
tree | 7df66a8c09dec4f9bd1f9eb1f9d390339213c21d /intern/cycles/render/osl.cpp | |
parent | 4448ed6c5e6d321c9f0822ca2d969f7e7041fe27 (diff) |
Code refactor: improve attribute handling for optional volume attributes.
A volume shader should be able to request attributes, and still be rendered
as homogeneous if no volume attributes are available for the object.
Diffstat (limited to 'intern/cycles/render/osl.cpp')
-rw-r--r-- | intern/cycles/render/osl.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/intern/cycles/render/osl.cpp b/intern/cycles/render/osl.cpp index 4d066c89b76..9e931280691 100644 --- a/intern/cycles/render/osl.cpp +++ b/intern/cycles/render/osl.cpp @@ -744,6 +744,10 @@ void OSLCompiler::add(ShaderNode *node, const char *name, bool isfilepath) current_shader->has_object_dependency = true; } + if(node->has_attribute_dependency()) { + current_shader->has_attribute_dependency = true; + } + if(node->has_integrator_dependency()) { current_shader->has_integrator_dependency = true; } @@ -991,6 +995,14 @@ void OSLCompiler::parameter_color_array(const char *name, const array<float3>& f ss->Parameter(name, type, table.data()); } +void OSLCompiler::parameter_attribute(const char *name, ustring s) +{ + if(Attribute::name_standard(s.c_str())) + parameter(name, (string("geom:") + s.c_str()).c_str()); + else + parameter(name, s.c_str()); +} + void OSLCompiler::find_dependencies(ShaderNodeSet& dependencies, ShaderInput *input) { ShaderNode *node = (input->link)? input->link->parent: NULL; @@ -1124,6 +1136,7 @@ void OSLCompiler::compile(Scene *scene, OSLGlobals *og, Shader *shader) shader->has_surface_spatial_varying = false; shader->has_volume_spatial_varying = false; shader->has_object_dependency = false; + shader->has_attribute_dependency = false; shader->has_integrator_dependency = false; /* generate surface shader */ |