Community
Arnold General Rendering Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Custom Closure Development

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
682 Views, 3 Replies

Custom Closure Development

Hello, everyone.

Is there any documentation on how to create a custom closure? Once I create such closure, what would I need to do to "expose" it to OSL?

Thanks so much

Tags (1)
Labels (1)
3 REPLIES 3
Message 2 of 4
Mike_Farnsworth
in reply to: Anonymous

You can create custom BSDFs in Arnold using the C++ API in ai_shader_bsdf.h by filling in the callbacks for your specific BSDF. You can wrap it in a closure like so:

AtBSDF* bsdf = AiBSDF(sg, rgb_weight, my_bsdf_methods, my_bsdf_data_size);
sg->out.CLOSURE() = AtClosure(my_color, bsdf);

This will work from within C++ shaders, but obviously not OSL shaders. Unfortunately, I don't think it's possible at this time to exposure arbitrary closures to OSL code directly. However, you should be able to create a C++ shader that outputs a closure that can be connected as an input closure color to an OSL shader (and vice-versa) in the shader network.

Message 3 of 4
Anonymous
in reply to: Anonymous

Thanks a lot Mike.

Message 4 of 4
zhyh3721
in reply to: Mike_Farnsworth

Is this something that is planned? Having the ability to write BxDFs and expose them as OSL closures would be great.

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

Post to forums  

Technology Administrators