Skip to main content
added material image
Source Link
iamkhush
  • 305
  • 2
  • 12

I have a blender object , a chair specifically. Below is the image of the chair -

A rendered chair

Now I use the following script to change the texture of one of the component -

def createMaterial(material):
    tex = bpy.data.textures.new('ColorTex', type = 'IMAGE')
    tex.image = bpy.data.images.load(realpath_of_image)
    tex.use_alpha = True
    # Create shadeless material and MTex
    mat = bpy.data.materials.new('TexMat')
    mat.use_shadeless = True
    mtex = mat.texture_slots.add()
    mtex.texture = tex
    mtex.texture_coords = 'UV'
    mtex.use_map_color_diffuse = True 
    return mat

def make_chnges(components, randomno):
    ob = bpy.data.objects[0]
    mat = createMaterial(material)
    ob.data.materials.append(mat)
    ob.active_material = mat

Now the output image that I get is -

output image

As you can see the rendered texture looks like a flat surface. What changes should be there to show up a similar surface?

Edit 1

This is the blender screenshot of what I see when I add a new material to the polygon. object screenshot

Here the object component looks allright(doesnt look like a flat surface), except that the new material doesnt show up. Just the white color is seen.

Edit 2

The material I am applying is - enter image description here

I have a blender object , a chair specifically. Below is the image of the chair -

A rendered chair

Now I use the following script to change the texture of one of the component -

def createMaterial(material):
    tex = bpy.data.textures.new('ColorTex', type = 'IMAGE')
    tex.image = bpy.data.images.load(realpath_of_image)
    tex.use_alpha = True
    # Create shadeless material and MTex
    mat = bpy.data.materials.new('TexMat')
    mat.use_shadeless = True
    mtex = mat.texture_slots.add()
    mtex.texture = tex
    mtex.texture_coords = 'UV'
    mtex.use_map_color_diffuse = True 
    return mat

def make_chnges(components, randomno):
    ob = bpy.data.objects[0]
    mat = createMaterial(material)
    ob.data.materials.append(mat)
    ob.active_material = mat

Now the output image that I get is -

output image

As you can see the rendered texture looks like a flat surface. What changes should be there to show up a similar surface?

Edit 1

This is the blender screenshot of what I see when I add a new material to the polygon. object screenshot

Here the object component looks allright(doesnt look like a flat surface), except that the new material doesnt show up. Just the white color is seen.

I have a blender object , a chair specifically. Below is the image of the chair -

A rendered chair

Now I use the following script to change the texture of one of the component -

def createMaterial(material):
    tex = bpy.data.textures.new('ColorTex', type = 'IMAGE')
    tex.image = bpy.data.images.load(realpath_of_image)
    tex.use_alpha = True
    # Create shadeless material and MTex
    mat = bpy.data.materials.new('TexMat')
    mat.use_shadeless = True
    mtex = mat.texture_slots.add()
    mtex.texture = tex
    mtex.texture_coords = 'UV'
    mtex.use_map_color_diffuse = True 
    return mat

def make_chnges(components, randomno):
    ob = bpy.data.objects[0]
    mat = createMaterial(material)
    ob.data.materials.append(mat)
    ob.active_material = mat

Now the output image that I get is -

output image

As you can see the rendered texture looks like a flat surface. What changes should be there to show up a similar surface?

Edit 1

This is the blender screenshot of what I see when I add a new material to the polygon. object screenshot

Here the object component looks allright(doesnt look like a flat surface), except that the new material doesnt show up. Just the white color is seen.

Edit 2

The material I am applying is - enter image description here

edited title
Link
iamkhush
  • 305
  • 2
  • 12

Correctly applying new materials to the object part

Added a new image - a screenshot of end of the process of adding new material
Source Link
iamkhush
  • 305
  • 2
  • 12

I have a blender object , a chair specifically. Below is the image of the chair -

A rendered chair

Now I use the following script to change the texture of one of the component -

def createMaterial(material):
    tex = bpy.data.textures.new('ColorTex', type = 'IMAGE')
    tex.image = bpy.data.images.load(realpath_of_image)
    tex.use_alpha = True
    # Create shadeless material and MTex
    mat = bpy.data.materials.new('TexMat')
    mat.use_shadeless = True
    mtex = mat.texture_slots.add()
    mtex.texture = tex
    mtex.texture_coords = 'UV'
    mtex.use_map_color_diffuse = True 
    return mat

def make_chnges(components, randomno):
    ob = bpy.data.objects[0]
    mat = createMaterial(material)
    ob.data.materials.append(mat)
    ob.active_material = mat

Now the output image that I get is -

output image

As you can see the rendered texture looks like a flat surface. What changes should be there to show up a similar surface?

Edit 1

This is the blender screenshot of what I see when I add a new material to the polygon. object screenshot

Here the object component looks allright(doesnt look like a flat surface), except that the new material doesnt show up. Just the white color is seen.

I have a blender object , a chair specifically. Below is the image of the chair -

A rendered chair

Now I use the following script to change the texture of one of the component -

def createMaterial(material):
    tex = bpy.data.textures.new('ColorTex', type = 'IMAGE')
    tex.image = bpy.data.images.load(realpath_of_image)
    tex.use_alpha = True
    # Create shadeless material and MTex
    mat = bpy.data.materials.new('TexMat')
    mat.use_shadeless = True
    mtex = mat.texture_slots.add()
    mtex.texture = tex
    mtex.texture_coords = 'UV'
    mtex.use_map_color_diffuse = True 
    return mat

def make_chnges(components, randomno):
    ob = bpy.data.objects[0]
    mat = createMaterial(material)
    ob.data.materials.append(mat)
    ob.active_material = mat

Now the output image that I get is -

output image

As you can see the rendered texture looks like a flat surface. What changes should be there to show up a similar surface?

I have a blender object , a chair specifically. Below is the image of the chair -

A rendered chair

Now I use the following script to change the texture of one of the component -

def createMaterial(material):
    tex = bpy.data.textures.new('ColorTex', type = 'IMAGE')
    tex.image = bpy.data.images.load(realpath_of_image)
    tex.use_alpha = True
    # Create shadeless material and MTex
    mat = bpy.data.materials.new('TexMat')
    mat.use_shadeless = True
    mtex = mat.texture_slots.add()
    mtex.texture = tex
    mtex.texture_coords = 'UV'
    mtex.use_map_color_diffuse = True 
    return mat

def make_chnges(components, randomno):
    ob = bpy.data.objects[0]
    mat = createMaterial(material)
    ob.data.materials.append(mat)
    ob.active_material = mat

Now the output image that I get is -

output image

As you can see the rendered texture looks like a flat surface. What changes should be there to show up a similar surface?

Edit 1

This is the blender screenshot of what I see when I add a new material to the polygon. object screenshot

Here the object component looks allright(doesnt look like a flat surface), except that the new material doesnt show up. Just the white color is seen.

Source Link
iamkhush
  • 305
  • 2
  • 12
Loading