Different shaders with same settings

On 16/06/2018 at 03:04, xxxxxxxx wrote:

User Information:
Cinema 4D Version:   R18.057 
Platform:   Windows  ; Mac  ;  
Language(s) :     C++  ;  XPRESSO  ;  PYTHON  ;

Hello PluginCafe,

I have been developing a plugin for a client where I have two different shaders but with the same settings. Internally I have a Class wich does (relatively heavy) computations and the shaders are different represantations of the computed data.

What I currently have are two seperately working shaders, the problem is, that they are intended to be used together. They way it is now it is doing the same computation twice. Also for them to work together one would have to change the same settings in both shaders to the same value.

So my question(s) essentially is(are) : 
Is there a way to store my computed data in some kind of buffer object, which the two shaders can access? Also moving the settings to one shader/object instead of two different shaders?

Would this be possible with an object data plugin?
The shaders do animate, so I am not shure how this would work with recalculating each frame if I would use an object data plugin.

Hope everything is clear. 
Best regards and thanks in advance,

On 18/06/2018 at 09:00, xxxxxxxx wrote:

Hi Florian,

the proper way to hold additional data (your computed data) inside of a document is in a branch (GetBranchInfo()) of a SceneHookData. Then both of your shaders would retrieve the data from the SceneHook.
Maybe not the easiest topic, but we can get you there.
Depending on your specific needs and use-case it can be more or less complicated. Instead of trying to explain everything (and most likely writing more than needed), I'd rather like to support you while you go, answering more specific questions.

On 19/06/2018 at 03:05, xxxxxxxx wrote:

Hi Andreas,

thank you for this information! 
I will take a look, and try it. 
If a question arises, I will go ahead an ask it :)

best regards,