forked from bartvdbraak/blender
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" />
This commit is contained in:
parent
bb83bdf891
commit
12109dd18e
@ -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();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user