I am new to Blender, and I am stuck with a problem in texture mapping.
I have got a series of model files (*.obj) that represents a non-rigid, deforming object. Each of the model file, represents an incremental deformation of the object and has been generated externally, using another software. These model files are textureless.
Here is an example:
I want to import these models into Blender sequentially (using Python), overlay a texture on them, add a background (and some lights) and export the complete animation. The texture that gets wrapped around the object is an image of 6000x4000 pixels.
However, the texture mapping is not working properly. It seems as if the texture is loosely overlaid on the object and the deformation makes the surface smoothly glide and slide beneath the texture. It is not what one would expect from a real world object.
If you look at the following images carefully, you might be able to notice the discrepancy:
Here is the script I am using to assign the texture:
realpath = os.path.expanduser("/path/to/some/image.jpg") try: img = bpy.data.images.load(realpath) except: raise NameError("Cannot load image %s" % realpath) # Create image texture from image cTex = bpy.data.textures.new('material1', type='IMAGE') cTex.image = img # Create material mat = bpy.data.materials.new('material1') # Add texture slot for color texture mtex = mat.texture_slots.add() mtex.texture = cTex mtex.texture_coords = 'OBJECT' mtex.bump_method = 'BUMP_BEST_QUALITY' mtex.reflection_factor = 0.8 mtex.use_map_diffuse = True mtex.use_map_color_diffuse = True mtex.use_map_color_emission = True mtex.emission_color_factor = 0.0 mtex.use_map_density = True mtex.mapping = 'FLAT' mat.diffuse_intensity = 0.8 mat.diffuse_shader = 'OREN_NAYAR'
mtex.texture_coords = 'GLOBAL'
instead of 'OBJECT' helps a little, but the stretching and distortion of the texture looks unrealistic in the 'global' mode.
Please help me in figuring out the root cause behind the problem and how, if at all, can this be remedied.