Copying a material channel
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 10/09/2007 at 02:48, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 10.102
Platform: Windows ;
Language(s) : C++ ;---------
Hi there again and sry for starting another thread so soon.My last thread's title ("Problems baking textures") doesn't fit my problem too good and I want to rephrase my question, as it has become a rather simple issue:
I need to copy a material's channel to another channel of another material.My current method (just getting the source BaseChannel and copy its data to the destination BaseChannel of the destination material) only results in the top-most level of information being copied (i.e. the color, blend mode, blend factor and the used shader, but _not_ the settings for the shader). I need a copy of the whole hierarchy (for example the settings for a Noise shader should be copied, too, or a whole hierarchy of Fusion shaders and so on).
What I want to do is the "Copy channel" / "Paste channel" functions that C4D got, but programmatically.
Can anyone shed some light on this? -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 11/09/2007 at 09:58, xxxxxxxx wrote:
just wanted to post I finally solved my problem.
First I copy the source channel's data to the destination channel, then I get the matching shader from the source material and copy that to the destination material's respective shader parameter://sourceMat is a Material*, sourceChannel is a LONG //same for destMat and destChannel destMat->GetChannel(destChannel)->SetData(sourceMat->GetChannel(sourceChannel)->GetData()); GeData shaderData; Bool result; switch(sourceChannel) { case CHANNEL_COLOR: result = sourceMat->GetParameter(DescID(MATERIAL_COLOR_SHADER), shaderData, 0); break; //same for all other channels where possible } if(!result) return; switch(destChannel) { case CHANNEL_COLOR: result = destMat->SetParameter(DescID(MATERIAL_COLOR_SHADER), shaderData, 0); break; //same for all other channels where possible }
So far that worked quite well for me, but if you want to use the destination material afterwards you probably should do something more, the material preview seems to be screwed with my method. Since I don't need the material for other things than baking the copied channel and destroy it afterwards anyway, I'm fine with that.
Thanks to everybody who read and thought about my problem. Just thought it would be nice to post my solution for others with the same problem.