Fix T63415: no Cycles displacement update when updating OSL code
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Sun, 21 Apr 2019 00:18:19 +0000 (02:18 +0200)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Sun, 21 Apr 2019 00:20:02 +0000 (02:20 +0200)
intern/cycles/blender/blender_shader.cpp
intern/cycles/render/graph.cpp
intern/cycles/render/graph.h
intern/cycles/render/nodes.cpp

index 5fd60ff..d1f823b 100644 (file)
@@ -908,7 +908,7 @@ static ShaderNode *add_node(Scene *scene,
 
 static bool node_use_modified_socket_name(ShaderNode *node)
 {
-  if (node->special_type == SHADER_SPECIAL_TYPE_SCRIPT)
+  if (node->special_type == SHADER_SPECIAL_TYPE_OSL)
     return false;
 
   return true;
index c284c64..e5fd39f 100644 (file)
@@ -721,6 +721,13 @@ void ShaderGraph::compute_displacement_hash()
       int link_id = (input->link) ? input->link->parent->id : 0;
       md5.append((uint8_t *)&link_id, sizeof(link_id));
     }
+
+    if (node->special_type == SHADER_SPECIAL_TYPE_OSL) {
+      /* Hash takes into account socket values, to detect changes
+       * in the code of the node we need an exception. */
+      OSLNode *oslnode = static_cast<OSLNode *>(node);
+      md5.append(oslnode->bytecode_hash);
+    }
   }
 
   displacement_hash = md5.get_hex();
index a2c030f..b1aa5cf 100644 (file)
@@ -61,7 +61,7 @@ enum ShaderNodeSpecialType {
   SHADER_SPECIAL_TYPE_PROXY,
   SHADER_SPECIAL_TYPE_AUTOCONVERT,
   SHADER_SPECIAL_TYPE_GEOMETRY,
-  SHADER_SPECIAL_TYPE_SCRIPT,
+  SHADER_SPECIAL_TYPE_OSL,
   SHADER_SPECIAL_TYPE_IMAGE_SLOT,
   SHADER_SPECIAL_TYPE_CLOSURE,
   SHADER_SPECIAL_TYPE_COMBINE_CLOSURE,
index 30968ab..16416a9 100644 (file)
@@ -5718,7 +5718,7 @@ void SetNormalNode::compile(OSLCompiler &compiler)
 
 OSLNode::OSLNode() : ShaderNode(new NodeType(NodeType::SHADER))
 {
-  special_type = SHADER_SPECIAL_TYPE_SCRIPT;
+  special_type = SHADER_SPECIAL_TYPE_OSL;
 }
 
 OSLNode::~OSLNode()