[Bf-cycles] Cycles standalone and OSL

John Haddon thehaddonyoof at gmail.com
Thu Feb 13 09:50:36 CET 2014


Hi,

Thanks very much for your work towards making Cycles into a standalone
renderer. I've made a small start on an experimental exporter for it
in Gaffer, a procedural scene assembly tool I've been working on. So
far it's been very straightforward, and basic mesh and camera export
seems to be working fine.

https://github.com/johnhaddon/gafferCycles

I'm now looking at exporting shaders and I'm hitting a few hurdles.
Gaffer already loads OSL shaders and can build networks from them, so
I had hoped it would be fairly straightforward to export them to
Cycles. Unfortunately as far as I can tell, OSL shaders aren't really
properly supported in Cycles XML. As I understand it, the problem is
that OSLScriptNodes start out with no input or output sockets, so the
code to transfer parameter values from the XML to the shader has
nothing to transfer them onto. The output socket seems to be specified
manually with the "output" and "output_type" XML attributes, but there
is no equivalent for input sockets.

Assuming that is correct, I wonder what you think is the best approach
to fixing this? Perhaps the OSLScriptNode could be extended with a
load_shader() method which uses OSL::OSLQuery to build the sockets
automatically, and then the existing parameter loading code in the XML
loader would work? Or do you think it would be best to support
additional arbitrary XML attributes to manually describe the sockets
using some sort of in_* in_type_* syntax? My preference would be for
the former, but I have no real understanding of the codebase on which
to base my opinion.

>From the examples, I'm also not clear as to how full the OSL support
is in terms of using OSL surface shaders (rather than just pattern
generators). Am I right in thinking that the scene_osl_stripes.xml
example file connects an OSL pattern generator into a built-in shader
node rather than using an OSL closure to perform the final shading? If
so, is it possible to actually use an OSL surface shader with closures
to do the entire render? My main interest in Cycles at present is for
the OSL support, so before I go any further it'd be great to know if
there are any other gotchas awaiting...

Thanks once again for your work on Cycles, and for any assistance you
might be able to offer...

Cheers...
John


More information about the Bf-cycles mailing list