[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [60325] trunk/blender/intern/cycles/render /nodes.cpp: Fix #36790, OSL point parameters of shader nodes not initialized correctly from UI inputs .

Lukas Toenne lukas.toenne at googlemail.com
Mon Sep 23 10:57:02 CEST 2013


Revision: 60325
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=60325
Author:   lukastoenne
Date:     2013-09-23 08:57:02 +0000 (Mon, 23 Sep 2013)
Log Message:
-----------
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).

Modified Paths:
--------------
    trunk/blender/intern/cycles/render/nodes.cpp

Modified: trunk/blender/intern/cycles/render/nodes.cpp
===================================================================
--- trunk/blender/intern/cycles/render/nodes.cpp	2013-09-23 08:20:16 UTC (rev 60324)
+++ trunk/blender/intern/cycles/render/nodes.cpp	2013-09-23 08:57:02 UTC (rev 60325)
@@ -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(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




More information about the Bf-blender-cvs mailing list