Arnold for Cinema 4D Forum
Rendering with Arnold in CINEMA 4D using the C4DtoA plug-in.
Showing results for 
Show  only  | Search instead for 
Did you mean: 

OSL Shader & file button

Message 1 of 20
625 Views, 19 Replies

OSL Shader & file button

Was hoping to try out the OSL shaders for Arnold. I downloaded the 3ds max shipping osl's and they compile fine, but the image fields are missing the button to select a file. Piping in an image node didn't work either.


Am I missing something?


C4D R26 on Mac.

Message 2 of 20

You have to specify the path as a string in those fields. Unfortunately the osl metadata (which defines that this is actually a filename field, not a string) is not supported by c4dtoa yet, it's planned in a future release.


As a workaround you can:

  • Copy the osl file to the C4DtoA/shaders folder (or add its folder to the ARNOLD_PLUGIN_PATH environment variable). As described here:
  • Create a metadata file next to the osl file with the same name (e.g. myshader.mtd)
  • Add these lines to the metadata file:
[node mynode]
 [attr myattr1]
     c4d.gui_type  INT  0
 [attr myattr2]
     c4d.gui_type  INT  0

where mynode is the name of the shader in the osl file, and myattr1, myattr2, etc, is the name of the parameters (e.g. filename0, filename1, etc.).

// Peter Horvath
// C4DtoA developer
Message 3 of 20

thanks Peter.


If I've done it correctly and file selector should be visible?

Message 4 of 20

@mckenzie2VER2 wrote:

thanks Peter.


If I've done it correctly and file selector should be visible?

Yes. Attached is a very simple test.



// Peter Horvath
// C4DtoA developer
Message 5 of 20

Somewhat confused here 🙂


I added RandomBitmaps2.osl to C4DToA/shaders, created a file called RandomBitmaps2.mtd in the same directory and added to it:


[node RandomBitmaps2]
[attr filename0]
c4d.gui_type INT 0
[attr filename1]
c4d.gui_type INT 0


No change.

Message 6 of 20

Hmm, that looks good to me. And the shader is loaded fine? You should see the shader RandomBitmaps2 listed in the shader tree. (Not the inline osl shader.) Do you see any warnings or errors in the console when you start a render?

// Peter Horvath
// C4DtoA developer
Message 7 of 20

I can't find a node for it if that's what you mean. No errors in the console. 


And just to confirm I don't need to add anything in the Arnold sys preferences if I've coped the OSL's to the shader folder?

Message 8 of 20

That's right, no settings needed, just copying the osl files to C4DtoA/shaders. If you run a render with Debug verbosity (Arnold Render Settings > Diagnostics tab), then you should see something like this in the console log:

[c4dtoa] 00:00:00  2586MB         | loading plugins from C:\Program Files\Maxon Cinema 4D R25\plugins\C4DtoA\shaders ...
[c4dtoa] 00:00:00  2586MB         |  filename_test.osl: filename_test
[c4dtoa] 00:00:00  2586MB         |  [metadata] loading metadata file: C:\Program Files\Maxon Cinema 4D R25\plugins\C4DtoA\shaders\filename_test.mtd
[c4dtoa] 00:00:00  2586MB         | loaded 9 plugins from 1 lib(s) and 1 OSL shaders in 0:00.01

// Peter Horvath
// C4DtoA developer
Message 9 of 20

Ok, so it is loading the shaders but erroring on the .mtd I created.


WARNING |  [metadata] (/Applications/Maxon Cinema 4D R26/plugins/C4DtoA/shaders/RandomBitmap2.mtd:1) Node entry does not exist
00:00:00  5329MB WARNING |  [metadata] (/Applications/Maxon Cinema 4D R26/plugins/C4DtoA/shaders/RandomBitmap2.mtd:2) Found attribute outside a node
00:00:00  5329MB WARNING |  [metadata] (/Applications/Maxon Cinema 4D R26/plugins/C4DtoA/shaders/RandomBitmap2.mtd:4) Found attribute outside a node
Message 10 of 20

Are you sure, the shader is called RandomBitmaps2? You can open the osl file in a text editor to check. Look for the shader definition, something like this:

shader filename_test

Or if the shader is loaded, it should be listed in the node editor under the 'Undefined' group. 

// Peter Horvath
// C4DtoA developer
Message 11 of 20



shader RandomBitmaps2
[[ string help  = "Randomly place (and alpha blend) a set of<br>bitmaps on top of something else",
   string version = "2.0.0",
   string label = "Randomized Bitmaps" ]]
Message 12 of 20

Ok, I see what's going on. I was wrong, the name of the Arnold shader node comes from the file name actually, which is RandomBitmap2.osl. Therefore the meta data file should look like this:

[node RandomBitmap2]
 [attr Filename0]
     c4d.gui_type  INT  0
 [attr Filename1]
     c4d.gui_type  INT  0
 [attr Filename2]
     c4d.gui_type  INT  0
 [attr Filename3]
     c4d.gui_type  INT  0
 [attr Filename4]
     c4d.gui_type  INT  0

I suppose the next problem will be the dynamic layer count. You won't be able to add and remove file inputs from the UI. As far as I see, this is Max specific and not supported in c4dtoa. If you need more layers, you have to manually edit the osl source code.

// Peter Horvath
// C4DtoA developer
Message 13 of 20

So the shader loads now but the file button is still missing - from the console:


[c4dtoa] ERROR   |    [texturesys] OSL get_texture_info(): Invalid image file "": ImageInput::create() called with no filename
Message 14 of 20

Here are my files, and this is my UI:


You have to set all file inputs, otherwise you get the Invalid image file "" error. Empty file name is not allowed.

As I said before, you won't be able to control the number of inputs from the UI. You have to edit the osl file manually if you need a different number of inputs (layers).

// Peter Horvath
// C4DtoA developer
Message 15 of 20
in reply to: peter_horvath

Interesting that you keep getting texture missing when there is no file loaded.

That is what this if state should handle in the color TextureFetch function


if (!strlen(filename))

return 0.0;


This, at least in 3ds max, closes down the false warning, verbose is cancled out, so it should also in theory work the same way in this host.

Message 16 of 20
in reply to: mckenzie2VER2


1-create a folder somwhere in your hardisk (C:>) something like
2-Put the 02 files: RandomBitmap2.osl & RandomBitmap2.mtd inside that folder
3-Add this variable to your OS



Message 17 of 20
in reply to: rachid_1

Tried that - not difference.. Nothing in the console.

Message 18 of 20
in reply to: mckenzie2VER2



I'm trying to get this shader working using your example above @peter_horvath, but it's not appearing in the shader tree and C4DtoA on C4D 2024.1.0 is throwing the following errors:

[c4dtoa] ERROR   |   [osl] error: Could not open "C:\Program Files\Maxon Cinema 4D 2024\plugins\C4DtoA\shaders/RandomBitmap2.oso.49dc-dfde-0600-49d1.tmp"
[c4dtoa] ERROR   |   [osl] error: Could not open "C:\Program Files\Maxon Cinema 4D 2024\plugins\C4DtoA\shaders/RandomBitmap2.oso.f611-13ce-024b-68b5.tmp"
[c4dtoa] ERROR   |      [osl] error: Could not open "C:\Program Files\Maxon Cinema 4D 2024\plugins\C4DtoA\shaders/RandomBitmap2.oso.0db1-cdc3-0740-cf9b.tmp"
[c4dtoa] ERROR   |      [osl] error: Could not open "C:\Program Files\Maxon Cinema 4D 2024\plugins\C4DtoA\shaders/RandomBitmap2.oso.26e5-6207-d207-fe58.tmp"
[c4dtoa] ERROR   |      [osl] error: Could not open "C:\Program Files\Maxon Cinema 4D 2024\plugins\C4DtoA\shaders/RandomBitmap2.oso.8520-78a8-d644-3587.tmp"

 Any chance you know why this is? Maybe something changed in the latest version of C4D?

Message 19 of 20
in reply to: dagmanson

My apologies, I had simply missed that I needed to allow write permissions for the shaders folder so Arnold can write an .oso file there.


But it now throws the same error as mentioned above, even when I have populated all file slots. Did you ever figure this out @mckenzie2VER2 ?


[texturesys] OSL get_texture_info(): Invalid image file "": ImageInput::create() called with no filename
Message 20 of 20

Right, you need write permission on the folder where the osl file is. Instead of the Program Files folder, you can also add the file to a custom folder and set the ARNOLD_PLUGIN_PATH environment variable as mentioned below or the plugin search path in the Arnold render settings.


I've got the Invalid image file "" error only if any of the file input fields are empty. When all are populated (with the same path for instance), the message is gone.


You can also try adding an osl shader and copy & paste the shader code there. In this case you can edit the shader code and change the number of file inputs.

// Peter Horvath
// C4DtoA developer

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

Post to forums