[Bf-blender-cvs] [12109dd] master: Cycles Standalone: Basic support for external OSL shaders.
Thomas Dinges
noreply at git.blender.org
Sun Jan 26 16:23:21 CET 2014
Commit: 12109dd18e622a5c469c4fb5b802edfee0d2b2de
Author: Thomas Dinges
Date: Sun Jan 26 16:22:19 2014 +0100
https://developer.blender.org/rB12109dd18e622a5c469c4fb5b802edfee0d2b2de
Cycles Standalone: Basic support for external OSL shaders.
* Very simple implementation, only allows for 1 output socket. As we haven't decided yet whether we keep the XML API, rather not spend more time on this now.
* To use an external osl shader, put the .osl file next to the xml file.
* Parameters: "output" is the output socket name, "output_type" the variable type (float, color and closure color are supported).
Example:
<osl_shader name="tex" src="ramp_closure.osl" output="Phong" output_type="closure color" />
<connect from="tex Phong" to="output surface" />
===================================================================
M intern/cycles/app/cycles_xml.cpp
===================================================================
diff --git a/intern/cycles/app/cycles_xml.cpp b/intern/cycles/app/cycles_xml.cpp
index 1e41525..ac8d1c1 100644
--- a/intern/cycles/app/cycles_xml.cpp
+++ b/intern/cycles/app/cycles_xml.cpp
@@ -379,6 +379,32 @@ static void xml_read_shader_graph(const XMLReadState& state, Shader *shader, pug
snode = env;
}
+ else if(string_iequals(node.name(), "osl_shader")) {
+ OSLScriptNode *osl = new OSLScriptNode();
+
+ /* Source */
+ xml_read_string(&osl->filepath, node, "src");
+ osl->filepath = path_join(state.base, osl->filepath);
+
+ /* Outputs */
+ string output = "", output_type = "";
+ ShaderSocketType type = SHADER_SOCKET_FLOAT;
+
+ xml_read_string(&output, node, "output");
+ xml_read_string(&output_type, node, "output_type");
+
+ if(output_type == "float")
+ type = SHADER_SOCKET_FLOAT;
+ else if(output_type == "closure color")
+ type = SHADER_SOCKET_CLOSURE;
+ else if(output_type == "color")
+ type = SHADER_SOCKET_COLOR;
+
+ osl->output_names.push_back(ustring(output));
+ osl->add_output(osl->output_names.back().c_str(), type);
+
+ snode = osl;
+ }
else if(string_iequals(node.name(), "sky_texture")) {
SkyTextureNode *sky = new SkyTextureNode();
More information about the Bf-blender-cvs
mailing list