Community
Arnold for Katana Forum
Rendering with Arnold in Katana using the KtoA plug-in.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to setup OSL shader?

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
andrey.babak
1644 Views, 5 Replies

How to setup OSL shader?

Can you show how to use OSL shaders in KtoA? Either I am doing something wrong or there's a bug that prevents using OSL on Windows. The log shows that KtoA can't find the shader in search path and can't find include file "stdosl.h" (the reason for that is that it loses a leading slash in its path).

Thank you.

Tags (2)
Labels (2)
5 REPLIES 5
Message 2 of 6

On Linux at least, you have to set the environment variable ARNOLD_PLUGIN_PATH to include the directory containing OSL code (any combination of .osl or already-compiled .oso files). Arnold will attempt to auto-compile .osl files for you. If it can't find it's own stdosl.h, then that is indeed a bug.

A workaround is to compile your own .oso files. Using oslc (in the same directory as kick) you should be able to manually compile your .osl files to .oso and tell it where to find stdosl.h, along with any other headers you need for your OSL code. Place your .oso files in another directory, and set ARNOLD_PLUGIN_PATH to point to that directory, and they should load.

One final hint: Arnold will refuse to use any OSL shaders that don't have an output parameter. For example, this shader will be rejected:

surface
metal
    [[ string help = "Shiny metallic material" ]]
(
    float Ks = 1
        [[  string help = "Specular scaling",
            float min = 0, float max = 1 ]],
    float eta = 10
        [[  string help = "Index of refraction (controls fresnel effect)",
            float min = 1, float max = 100 ]],
    color Cs = 1
        [[  string help = "Base color",
            float min = 0, float max = 1 ]]
  )
{
    Ci = Ks * Cs * reflection (N, eta);
}

But this will be accepted:

surface
metal
    [[ string help = "Shiny metallic material" ]]
(
    float Ks = 1
        [[  string help = "Specular scaling",
            float min = 0, float max = 1 ]],
    float eta = 10
        [[  string help = "Index of refraction (controls fresnel effect)",
            float min = 1, float max = 100 ]],
    color Cs = 1
        [[  string help = "Base color",
            float min = 0, float max = 1 ]],
    // NOTE the explicit output parameter!
    output closure color Cout = 0
  )
{
    Cout = Ks * Cs * reflection (N, eta);
}
Message 3 of 6

Hi Mike,

Thank you for posting this information!

May I ask you to show the complete setup in Katana? I am not sure what result should I get. Currently, I've copied the latter script into "metal.osl" and added the folder to ARNOLD_PLUGIN_PATH. I tried adding the full path to "osl" node's "code" attribute. Finally, I was able to compile "metal.oso" and tried with its path. Should I get some controls in Katana?

Thank you.

Cheers,
Andrey

Message 4 of 6

Hello @Mike Farnsworth,

Sorry, forgot to mention your username in my previous post to issue a notification.

Andrey

Message 5 of 6

So, if you're trying to use the osl_shader node, it won't work (it's not yet supported, in that KtoA won't create the UI once you paste your code in there). All you should need to do is have the .oso file in ARNOLD_PLUGIN_PATH, and the metal shader should automatically show up in the list of available shaders.

I am going to try to reproduce the .osl compilation failure, and if I can get that fixed I plan on releasing a bugfix version of KtoA that should make this easier. I will also put up a tutorial on support.solidangle.com in the KtoA area showing how it's done.

Message 6 of 6

Ah, I see. I was expecting the UI to show up right inside the osl node. Thank you.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report