I'm working with an old python script that renders three spheres in Blender using the
Each of these spheres has a unique material (they're simply red, blue, and green spheres, respectively). I want the red sphere to be slightly transparent. Below, I have my function for creating this transparent material:
def create_material(r, g, b, alpha=None): ''' Creates a new material with optionally specified alpha vals. So far, I only use this on the red sphere. The green and blue spheres have mats assigned from bpy.materials.get() which I don' know how to use anymore nor where those materials are "coming from". ''' new_material = data.materials.new(name="MyNewMaterial") if alpha: new_material.diffuse_color = (r, g, b) # setting the color new_material.alpha = alpha # Setting what I believe to be the value for transparency # Here, I simply copy/pasted what I found related to my problem on StackExchange # but it does not work. new_material.transparency_method = 'Z_TRANSPARENCY' new_material.use_transparency = True bpy.context.object.show_transparent = True # Return this new material return new_material new_material.diffuse_color = (r, g, b) return new_material
Even with the above function, I can't seem to create a transparent sphere in the scene. It always shows up as though the alpha value doesn't matter. To me, that implies either the alpha value I'm setting isn't being used or the material is being overwritten somewhere but I don't know where and am having difficulty debugging since I've forgotten most of Blender (this script is about two years old).
How can I make an object transparent?