Materials and BaseShader

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 13/09/2012 at 15:59, xxxxxxxx wrote:

Hello again, sorry about all the posts, I've been trying a bunch of new stuff recently.

I'm trying to copy a bitmap texture  from the color channel and apply it  to other channels.  This works if it's directly into one of the default channels, but if I'm doing a nested channel(Filter Shader) I get a black preview image instead of the correct bitmap image.

To test it out add a bitmap channel and then run the code, then check the diffusion channel and click on filter.

  
import c4d  
from c4d import gui  
  
def main() :  
  mat = doc.GetActiveMaterial()#Get the active material  
    
  bsbit = c4d.BaseShader(c4d.Xbitmap)  #create a bitmap baseshader  
  bsbit[c4d.BITMAPSHADER_FILENAME] =mat[c4d.MATERIAL_COLOR_SHADER][c4d.BITMAPSHADER_FILENAME]  
  #get the bitmap name from the color channel and apply it to this one  
    
    
  bsdiffusion = c4d.BaseShader(c4d.Xfilter)#Create a filter baseshader  
  bsdiffusion[c4d.SLA_FILTER_TEXTURE] =bsbit#assign the bsbit shader as this ones texture  
  mat[c4d.MATERIAL_DIFFUSION_SHADER]= bsdiffusion #set this shader as the materials diffusion shader  
    
  mat.InsertShader(bsbit)#insert the shaders  
  mat.InsertShader(bsdiffusion)  
    
  mat.Message(c4d.MSG_UPDATE)#update  
  mat.Update(True, True)  
  c4d.EventAdd()  
if __name__=='__main__':  
  main()  
  

I'm not sure what I'm missing.  
Thanks in advance for any help! I've been learning so much from all of the answers.

Dan

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 13/09/2012 at 23:11, xxxxxxxx wrote:

i guess you want to insert the bitmap shader under the fusion shader and not under the material. So use bsdiffusion.InsertShader(bsbit) instead of mat.InsertShader(bsbit)

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 14/09/2012 at 08:42, xxxxxxxx wrote:

Thanks a bunch, affa! It's all working perfectly now.

  
  
import c4d  
from c4d import gui  
  
def main() :  
  mat = doc.GetActiveMaterial()#Get the active material  
    
  bsbit = c4d.BaseShader(c4d.Xbitmap)  #create a bitmap baseshader  
  bsbit[c4d.BITMAPSHADER_FILENAME] =mat[c4d.MATERIAL_COLOR_SHADER][c4d.BITMAPSHADER_FILENAME]  
  #get the bitmap name from the color channel and apply it to this one  
    
    
  bsdiffusion = c4d.BaseShader(c4d.Xfilter)#Create a filter baseshader  
  bsdiffusion[c4d.SLA_FILTER_TEXTURE] =bsbit#assign the bsbit shader as this ones texture  
  mat[c4d.MATERIAL_DIFFUSION_SHADER]= bsdiffusion #set this shader as the materials diffusion shader  
    
  bsdiffusion.InsertShader(bsbit)#insert the shaders under the shader that uses then  
  mat.InsertShader(bsdiffusion)  
    
  mat.Message(c4d.MSG_UPDATE)#update  
  mat.Update(True, True)  
  c4d.EventAdd()  
if __name__=='__main__':  
  main()  
  

Dan

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 17/09/2012 at 14:54, xxxxxxxx wrote:

Now I 'm trying to create a Layer shader for a material and I'm running into trouble.  How do I insert new shaders into it?  I saw this thread, https://plugincafe.maxon.net/topic/5480/5499_how-to-access-in-the-layer-shader&KW=layer+shader, about reading what's in it, but I want to create the material.

Dan