OSL Cross Platform Compatibility

After looking throught the PDF linked on Thomas’ site, I tried a few examples but it seems that OSL is not entirely compatible.

  • Ci seems to be reserved rather than automatically creating an output when used
  • reflection closure does not have IOR (eta variable)
  • ui hints are not yet supported

See page 15:

surface
example_shader_3
[[ string help = “Simple dielectric material” ]]
(
color Cs = 1
    [[ string help = “Base Color”, 
    float min = 0, float max = 1 ]],
  float eta = 1.5
    [[ string help = “Index of refraction” ]],
){
  if( backfacing() )
  {
    Ci = refraction(N, 1.0 / eta) + reflection(N, 1.0 / eta);
  } else {
    Ci = refraction(N, eta) + reflection(N, eta);
  }
  Ci *= Cs;
}

http://www.openshading.com/osl/
http://blog.selfshadow.com/publications/s2012-shading-course/martinez/s2012_pbs_osl_notes_v3.pdf

I might post a little late, but you can check out here to see how it might be done in Cycles. In my understanding, the OSL shaders that are exposed in this paper are for closures used in Arnold, which are different to the ones used in Blender. I’ve tried them, by using the cycles available closures and they work.

One example : in the code you have “refraction(N, eta)”, in Cycles it would be “refraction(N, ior)”

Hi,
some notes about this.

  • We use “Ci”, inside the Output node, so the Surface/Volume/Displacement we connect there is passed to Ci. This is probably not really according to the specification but not a real problem either, a OSL shader from another program can be changed in 2 seconds, by changing the variable name.
  • Closures are not part of the OSL specification and therefore they can be different in every engine.
  • UI Hints are indeed not supported yet, but this is a UI “bonus”, not something that prevents the usage of the shader.

Danke DingTo. It might be worth adding these notes to the documentation if you get a chance.

After reading this, http://help.chaosgroup.com/vray/help/200R1/vrayosl.htm, it seems that closures are going to be fairly renderer specific.

Although, it would be very convenient to be able to use Ci in a node and have the node automatically create a closure output socket.