diff options
author | Thomas Dinges <blender@dingto.org> | 2014-01-26 19:22:19 +0400 |
---|---|---|
committer | Thomas Dinges <blender@dingto.org> | 2014-01-26 19:23:07 +0400 |
commit | 12109dd18e622a5c469c4fb5b802edfee0d2b2de (patch) | |
tree | 2e2e116f51186791021ae2955fd6091af9187f49 | |
parent | bb83bdf89123690e99ef36afd24a93246685dc68 (diff) |
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" />
-rw-r--r-- | intern/cycles/app/cycles_xml.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/intern/cycles/app/cycles_xml.cpp b/intern/cycles/app/cycles_xml.cpp index 1e41525a70e..ac8d1c1ce73 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(); |