blender - how do I add a color to an object?
- Select an object.
- In Button window (at bottom) select 'Shading' (a gray ball) and then 'Material buttons' (red ball)
- In 'Link and pipeline', press 'Add new'.
- Edit material color ('Col').
See it http://s3.amazonaws.com/twitpic/photos/large/222981727.png?AWSAccessKeyId=0ZRYP5X5F6FSMBCCSE82&Expires=1294658484&Signature=jDJpFXu7QI/7vGbW9BwBgL0trBU%3D
Assign different colors for instanced Blender objects automatically
I belive this does the desired action
it was quite tricky as like described in here you need to set up input and output shaders and link it up correctly
import bpy
import random
mat = bpy.data.materials.new(name="test")
mat.use_nodes = True
if mat.node_tree:
mat.node_tree.links.clear()
mat.node_tree.nodes.clear()
nodes = mat.node_tree.nodes
links = mat.node_tree.links
output = nodes.new(type='ShaderNodeOutputMaterial')
#shader = nodes.new(type='ShaderNodeBsdfDiffuse')
shader = nodes.new(type='ShaderNodeBsdfPrincipled')
r,g,b = random.randint(0,255),random.randint(0,255),random.randint(0,255)
nodes["Principled BSDF"].inputs[0].default_value = (r/255, g/255, b/255, 1)
links.new(shader.outputs[0], output.inputs[0])
bpy.ops.mesh.primitive_cube_add(size=2, align='WORLD', location=(0, 0, 0))
bpy.context.active_object.data.materials.append(mat)
How can I give a single object multiple colors in cycles?
While you can assign a different material to each face on your model, I don't think that will give the result you want. I expect you want to use some noise to get colour variations, one way is to feed the noise into a colour ramp node.
There are other noise textures such as wave, voronoi, musgrave or magic that can give varying results, you may even want to mix a couple together. Just experiment with the scale, distortion and detail values to get a variation that you like.
Changing object's color in Blender
You can use a python script to change the colour. Most likely you want to adjust the diffuse_color
property of the material, which is an array of three numbers - [0]=red [1]=green [2]=blue
.
While they don't show up in the action editor you can add keyframes to the colour components to create material actions and they will show up in action actuators list to play. To animate a colour you add a keyframe by right-clicking on the colour swatch and selecting Insert keyframe or press I while the mouse is over the colour swatch. Then move to another frame adjust the colour and set another keyframe.
Related Topics
Reading Columns of a Txt File on Python
Python How to Remove Escape Characters from a String
Python Not Working in the Command Line of Git Bash
Iterating Over Every Two Elements in a List
Formal and Actual Parameters in a Function in Python
How to Pad a String With Leading Zeros in Python 3
Python - How to Separate Paragraphs from Text
Swapping Columns in a Numpy Array
How to Block Comment Code in the Ipython Notebook
How to Print Superscript in Python
Python Pandas Count the Number of Occurances Inside Lists in a Column
How to Find the Average of Particular Numbers in a CSV File
Google Chrome Closes Immediately After Being Launched With Selenium
How to Skip Blank Line While Reading CSV File Using Python
How to Use Installed Packages in Pycharm