Blender - How to Add a Color to an Object

blender - how do I add a color to an object?

  1. Select an object.
  2. In Button window (at bottom) select 'Shading' (a gray ball) and then 'Material buttons' (red ball)
  3. In 'Link and pipeline', press 'Add new'.
  4. 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.

enter image description here

enter image description here

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



Leave a reply



Submit