Set BaseShader as shader links on Read method
-
On 26/06/2018 at 06:43, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R18
Platform: Windows ;
Language(s) : C++ ;---------
Hello.I have a MaterialData with a couple of ShaderLink parameters.
In Read method of MaterialData, I need to make some checks.
In some cases, I need to create specific BaseShader objects and set them in the ShaderLink parameters.
The problem is that the newly created shaders don't appear in the material.Is this the correct workflow ?
I can see that if the shader links already contain shaders, I can replace them correcly, but if they are empty, I cannot create new to set them as links.
I have to do the whole procedure on Material Load after version checking. In read method I can check the level parameter and see if the material is old.Thank you.
-
On 27/06/2018 at 09:19, xxxxxxxx wrote:
Hi,
it's a bit strange, that it seems to work, when replacing, but not when just creating a new shader. Can you please check, InsertShader() is called correctly in both cases?
Another issue might be, that during Read() there's no document (or rather the node isn't inserted), yet (see the note in NodeData::Read() / NodeData::Write() Manual). Not sure, why this should cause an issue with a link on first set, only, but we can't rule out this possibility, yet.
Another option is to just set a flag during Read() and then do the needed stuff in a SceneHook on MSG_DOCUMENTINFO with MSG_DOCUMENTINFO_TYPE_LOAD and MSG_DOCUMENTINFO_TYPE_MERGE.
-
On 28/06/2018 at 00:48, xxxxxxxx wrote:
Hello Andreas.
I have checked InsertShader and indeed it doesn't work in Read method of the MaterialData.
I set a member flag in Read and I insert the shader in the Message method listening to MSG_DOCUMENTINFO_TYPE_LOAD/MERGE and it works fine.Why do I have to use a SceneHook ?
Is there something else that I also have to take into consideration ?Thank you for your time Andreas !