Thank you for cgkit, and thank you all in advance for any assistance.
I am using the Renderman/ri portion of cgkit 2.0.0 within PoserPython 2.7 (Poser Pro 2014) to pass the shader tree for each material in the scene. Each material collapses down to one universal surface shared by all polygonal/subdivision surfaces.
Even though it is open-ended in possibilities (as node networks are), there are always only two possible results:
It is in case 2 that I run into trouble. Right now, I am generating a shader for each material group that has a unique network. Everything is the same, even the constructor, except a few lines in the middle of each one. Is there no way to optionally compile the custom section, and then modify the main shader (once and for all) to look for a flag and a string? The flag would notify the shader to read in and use the custom bit, and the string would be the filepath to said custom bit.
Or, is there an easier way to do this? I have all of the possible nodes in a header file right now, and I'm just including it with each shader I compile. Can I somehow integrate these functions into the nested network tree with the standard shader using RiSurface, RiShader or somesuch?
I realize this is a lot to process at once, and I am not sure how clearly I communicated the question. Thank you in advance for any help, and I will monitor the thread to clarify/elaborate if need be.
I'm not entirely sure if I understand your question correctly. Is this a question how to do something with cgkit or is it a general shader writing question? (it seems to be the latter)
From what I understand you are generating shader source code and want to customize the source code based on the material in Poser? (but if you generate it yourself, then I suppose it's up to you what you generate anyway...?)
What renderer is this anyway? Have you looked into coshaders?
Hi Matthias, thank you for replying. I am using cgkit 2.0.0 under Python 2.7 and 3Delight 10. What I am asking is how to translate a nested shader tree. There is one base shader that would call multiple coshaders that may in turn call other coshaders. What is the best way to implement this using cgkit 2.0.0 and coshaders? These coshaders are each of one fixed type (float, color, etc) and will always have the same return type and set of parameters. I have looked into coshaders but don't exactly (or anywhere close to) understand how to use them, having spent my entire Renderman life using the classic shader structure with helper functions embedded in a header file.
I have attached an example of a network I might export with the tool. the left, tall node is the main surface shader, and each of the nodes on the right would be coshaders if I understand the cgkit and 3Delight documentation correctly. My issue is that I am not sure how to nest these, or where to call this in cgkit while generating my RIB file.
Well, as you are in control of creating the shader, you can just use whatever approach that suits you best. If you are more familiar with the classic shader style, then why not start wit that one? You could create a function for every node and call those in your main shader.
I don't think there's anything special you need to take into account related to cgkit. You just pass all required parameters to the RiSurface() call, this is the same is would be in C or using any other language binding.
As your question is more geared towards generic shader writing, you would probably get more and better answers if you posted your question to a forum that's more about RenderMan shader writing. I don't think there are many people following this discussion board here.