Community
Arnold General Rendering Forum
abbrechen
Suchergebnisse werden angezeigt für 
Anzeigen  nur  | Stattdessen suchen nach 
Meintest du: 

Sample C++ shader code

9 ANTWORTEN 9
Antworten
Nachricht 1 von 10
Anonymous
1316 Aufrufe, 9 Antworten

Sample C++ shader code

I am looking for a few C++ code samples of shaders. Can you direct me to a location where I can download the code?

9 ANTWORTEN 9
Nachricht 2 von 10
valerio_viperino
als Antwort auf: Anonymous

What kind of shader code are you looking for? You can find some examples of OSL shaders here:

https://thhube.github.io/tutorials/osl/osl.html

Nachricht 3 von 10
Stephen.Blair
als Antwort auf: Anonymous

SItoA is now open source, you can check that code.

https://github.com/Autodesk/sitoa



// Stephen Blair
// Arnold Renderer Support
Nachricht 4 von 10
Anonymous
als Antwort auf: Anonymous

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.

Nachricht 5 von 10
Anonymous
als Antwort auf: Anonymous

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.

Nachricht 6 von 10
maxtarpini
als Antwort auf: Anonymous

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.


Nachricht 7 von 10
Anonymous
als Antwort auf: Anonymous

Oh I see, integrate as an independent function. Not like the previous AiOrenNayarIntegrate(). That's handy for custom brdfs as well. Thanks!
Nachricht 8 von 10
Anonymous
als Antwort auf: Anonymous

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?

Nachricht 9 von 10
maxtarpini
als Antwort auf: Anonymous

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.

Nachricht 10 von 10
Anonymous
als Antwort auf: Anonymous

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?

Sie finden nicht, was Sie suchen? Fragen Sie die Community oder teilen Sie Ihr Wissen mit anderen.

In Foren veröffentlichen  

Autodesk Design & Make Report