diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-01-21 20:19:31 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-01-27 11:36:30 +0300 |
commit | df07a25d2811c43648af3e9bf4cc44d255218d65 (patch) | |
tree | 9d2aa5889b536f3e5c706b57f4fd2b551e3bb66d /intern/cycles/blender | |
parent | ddc0d280311a442bb90790e7421d64ed60136d0d (diff) |
Cycles: Support texture coordinate from another object
This is the same as blender internal's texture mapping from another object,
so this way it's possible to control texture space of one object by another.
Quite straightforward change apart from the workaround for the stupidness of
the dependency graph. Now shader has flag telling that it depends on object
transform. This is the simplest way to know which shaders needs to be tagged
for update when object changes. This might give some false-positive tags now
but reducing them should not be priority for Cycles and rather be a priority
to bring new dependency graph.
Also GLSL preview does not support using other object for mapping.
This is actually correct for BI shading as well and to be addressed as
a part of general GLSL viewport improvements since it's not really clear
how to support this in GLSL.
Reviewers: brecht, juicyfruit
Subscribers: eyecandy, venomgfx
Differential Revision: https://developer.blender.org/D1021
Diffstat (limited to 'intern/cycles/blender')
-rw-r--r-- | intern/cycles/blender/blender_shader.cpp | 4 | ||||
-rw-r--r-- | intern/cycles/blender/blender_sync.cpp | 14 |
2 files changed, 15 insertions, 3 deletions
diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp index 806eae72b23..baf79a78987 100644 --- a/intern/cycles/blender/blender_shader.cpp +++ b/intern/cycles/blender/blender_shader.cpp @@ -687,6 +687,10 @@ static ShaderNode *add_node(Scene *scene, BL::BlendData b_data, BL::Scene b_scen BL::ShaderNodeTexCoord b_tex_coord_node(b_node); TextureCoordinateNode *tex_coord = new TextureCoordinateNode(); tex_coord->from_dupli = b_tex_coord_node.from_dupli(); + if(b_tex_coord_node.object()) { + tex_coord->use_transform = true; + tex_coord->ob_tfm = get_transform(b_tex_coord_node.object().matrix_world()); + } node = tex_coord; } else if (b_node.is_a(&RNA_ShaderNodeTexSky)) { diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index 97ceae7237b..79ee6d51196 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -70,10 +70,18 @@ bool BlenderSync::sync_recalc() * so we can do it later on if doing it immediate is not suitable */ BL::BlendData::materials_iterator b_mat; - - for(b_data.materials.begin(b_mat); b_mat != b_data.materials.end(); ++b_mat) - if(b_mat->is_updated() || (b_mat->node_tree() && b_mat->node_tree().is_updated())) + bool has_updated_objects = b_data.objects.is_updated(); + for(b_data.materials.begin(b_mat); b_mat != b_data.materials.end(); ++b_mat) { + if(b_mat->is_updated() || (b_mat->node_tree() && b_mat->node_tree().is_updated())) { shader_map.set_recalc(*b_mat); + } + else { + Shader *shader = shader_map.find(*b_mat); + if(has_updated_objects && shader != NULL && shader->has_object_dependency) { + shader_map.set_recalc(*b_mat); + } + } + } BL::BlendData::lamps_iterator b_lamp; |