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