I am looking for a few C++ code samples of shaders. Can you direct me to a location where I can download the code?
What kind of shader code are you looking for? You can find some examples of OSL shaders here:
SItoA is now open source, you can check that code.
https://github.com/Autodesk/sitoa
Thank you Stephen. I use a text editor called Cutter, that I have written in Java, for all my teaching. I have adapted it to help my students write and compile shaders written in C++. It handles the writing of make files for OSX and Linux and .bat files on Windows. It avoids the necessity of using Visual Studio.
Despite what I am accomplishing with the added features of my "Cutter" text editor I'm still very new to writing shaders or what I would normally call pattern plugins in RenderMan. For example, I don't know how to assign a color to the transparency output of a node. I am looking for examples of C++ code that would help me gain a better understanding of writing Arnold shaders. At this stage I'm not interested in writing full-on materials (closures). I'm pretty comfortable with writing OSL shaders but I am new to writing C++ shaders.
Since I'm also affected by this https://answers.arnoldrenderer.com/questions/20999/problem-logging-to-forum.html I'll post it here instead of creating a new thread because it's at least a little bit related.
The question is: How can I separate direct and indirect results I get from functions like AiOrenNayarBSDF()?
As described in the conversion notes (https://docs.arnoldrenderer.com/display/A5ARP/Converting+to+Closures) with Arnold 4 I got two functions. One for direct AiDirectDiffuse() and one for indirect AiIndirectDiffuse(). That way i can treat the results further.
With closures now however that seems to be more difficult. I found this:
https://forums.autodesk.com/t5/maya-programming/how-to-ignore-indirect-specular-with-aimicrofacetbsd...
but that only kicks in in advance. What I'm looking for are the different results of functions like AiOrenNayarBSDF() which I want to use further down the road in my shader.
You can implement your own eval/sample routines and ..
AtRGB diffuse, diffuse_direct, diffuse_indirect; [...] AtBSDF *diffuse_brdf = AiOrenNayarBSDF(state, diffuse_weight, state->Nf, roughness); AiBSDFIntegrate(state, &diffuse_direct, &diffuse_indirect, diffuse_brdf); diffuse = diffuse_direct + diffuse_indirect; [...]
However then you're alone supporting for example transparency etc.
Okay great that works like a charm. The catch is that Maya doesn't let me assign this to an object if I have out.RGB() instead of out.CLOSURE() and have node->output_type set accordingly.
I thought about using an AiClosureMatte() as sort of a fake closure and use my result as weight but I don't want any additional unnecessary processing of course. However I assume there's a better way. So what's the official way in such cases?
No problems here I can use out.RGB() stuff in Maya with latest and also previous Arnold. Checked latest API changes and it seems nothing changed on this regard.
Sorry never mind. For my quick test I didn't throw in an mtd file. Everything is working fine.
BTW I spottet your Power Metal and it's amazing. The freedom STD allows is ideal. Are you going to release that at some point?