remove old shader
-
On 25/05/2017 at 22:34, xxxxxxxx wrote:
For the material, I create a shader.
mat = doc.GetActiveMaterial()
shd1 = c4d.BaseShader(c4d.Xbitmap)
shd1[c4d.BITMAPSHADER_FILENAME]= FILE_NAME1
mat.InsertShader(shd1)
mat[c4d.MATERIAL_DIFFUSION_SHADER] = shd1shd1 after I overwrite shd2.
shd2 = c4d.BaseShader(c4d.Xbitmap)
shd2[c4d.BITMAPSHADER_FILENAME]= FILE_NAME2
mat.InsertShader(shd1)
mat[c4d.MATERIAL_DIFFUSION_SHADER] = shd2Is the shd1 removed or is it in memory?
-
On 26/05/2017 at 03:08, xxxxxxxx wrote:
Hi,
shd1 is still in memory. To remove it from the material's shader list after it's been overwriten, call shd1.Remove().
Assigning a shader to MATERIAL_DIFFUSION_SHADER only set a link to the shader. -
On 26/05/2017 at 03:14, xxxxxxxx wrote:
How can I remove all unused shaders?
mat.GetFirstShader()
while(shd) :
shd.Remove()
shd = mat.GetFirstShader()But this will remove all the shaders of the material including the required ones
-
On 30/05/2017 at 02:48, xxxxxxxx wrote:
Originally posted by xxxxxxxx
How can I remove all unused shaders?
What do you mean by "unused shaders"? The shaders that you have inserted yourself into the material and that are no longer linked?
To find such unused shaders, you can check the used and assigned channels of the material for each shader in its shader list (returned by GetFirstShader()). If a shader is found then it is used, otherwise it can be removed.