diff --git a/render_povray/__init__.py b/render_povray/__init__.py index d172d1d59ca89eb4bed51b7c07acb45503e269d4..96d1319cee1f02d59457aefcb42c25be4c7d251d 100644 --- a/render_povray/__init__.py +++ b/render_povray/__init__.py @@ -775,7 +775,7 @@ class MaterialTextureSlot(PropertyGroup): use: BoolProperty( name="", description="Enable this material texture slot", - default = False) + default = True) use_from_dupli: BoolProperty( name="", diff --git a/render_povray/shading.py b/render_povray/shading.py index 1e92f9b0eb7306570c5679c0e5544642fcca6b46..b63443c25af8f115cabaa70bc7f0b1258334cd8c 100644 --- a/render_povray/shading.py +++ b/render_povray/shading.py @@ -242,9 +242,18 @@ def writeMaterial(using_uberpov, DEF_MAT_NAME, scene, tabWrite, safety, comments if material: special_texture_found = False + idx = -1 for t in material.pov_texture_slots: - if t and t.use and t.texture is not None: - if (t.texture.type == 'IMAGE' and t.texture.image) or t.texture.type != 'IMAGE': + idx += 1 + # index = material.pov.active_texture_index + slot = material.pov_texture_slots[idx] # [index] + povtex = slot.name + tex = bpy.data.textures[povtex] + + if t and t.use and tex is not None: + + + if (tex.type == 'IMAGE' and tex.image) or tex.type != 'IMAGE': #validPath if(t and t.use and (t.use_map_specular or t.use_map_raymir or t.use_map_normal or t.use_map_alpha)): @@ -767,14 +776,22 @@ def writeTextureInfluence(mater, materialNames, LocalMaterialNames, path_image, texturesAlpha = "" #proceduralFlag=False for t in mater.pov_texture_slots: - if t and (t.use and (t.texture is not None)): + idx = -1 + for t in mater.pov_texture_slots: + idx += 1 + # index = mater.pov.active_texture_index + slot = mater.pov_texture_slots[idx] # [index] + povtex = slot.name + tex = bpy.data.textures[povtex] + + if t and (t.use and (tex is not None)): # 'NONE' ('NONE' type texture is different from no texture covered above) - if (t.texture.type == 'NONE' and t.texture.pov.tex_pattern_type == 'emulator'): + if (tex.type == 'NONE' and tex.pov.tex_pattern_type == 'emulator'): continue # move to next slot # PROCEDURAL - elif (t.texture.type != 'IMAGE' and t.texture.type != 'NONE'): + elif (tex.type != 'IMAGE' and tex.type != 'NONE'): proceduralFlag=True - image_filename = "PAT_%s"%string_strip_hyphen(bpy.path.clean_name(t.texture.name)) + image_filename = "PAT_%s"%string_strip_hyphen(bpy.path.clean_name(tex.name)) if image_filename: if t.use_map_color_diffuse: texturesDif = image_filename @@ -789,40 +806,40 @@ def writeTextureInfluence(mater, materialNames, LocalMaterialNames, path_image, if t.use_map_normal: texturesNorm = image_filename # colvalue = t.normal_factor/10 # UNUSED - #textNormName=t.texture.image.name + ".normal" + #textNormName=tex.image.name + ".normal" #was the above used? --MR t_nor = t if t.use_map_alpha: texturesAlpha = image_filename # colvalue = t.alpha_factor * 10.0 # UNUSED - #textDispName=t.texture.image.name + ".displ" + #textDispName=tex.image.name + ".displ" #was the above used? --MR t_alpha = t # RASTER IMAGE - elif (t.texture.type == 'IMAGE' and t.texture.image and t.texture.pov.tex_pattern_type == 'emulator'): + elif (tex.type == 'IMAGE' and tex.image and tex.pov.tex_pattern_type == 'emulator'): proceduralFlag=False #PACKED - if t.texture.image.packed_file: - orig_image_filename=t.texture.image.filepath_raw - unpackedfilename= os.path.join(preview_dir,("unpacked_img_"+(string_strip_hyphen(bpy.path.clean_name(t.texture.name))))) + if tex.image.packed_file: + orig_image_filename=tex.image.filepath_raw + unpackedfilename= os.path.join(preview_dir,("unpacked_img_"+(string_strip_hyphen(bpy.path.clean_name(tex.name))))) if not os.path.exists(unpackedfilename): # record which images that were newly copied and can be safely # cleaned up unpacked_images.append(unpackedfilename) - t.texture.image.filepath_raw=unpackedfilename - t.texture.image.save() + tex.image.filepath_raw=unpackedfilename + tex.image.save() image_filename = unpackedfilename.replace("\\","/") # .replace("\\","/") to get only forward slashes as it's what POV prefers, # even on windows - t.texture.image.filepath_raw=orig_image_filename + tex.image.filepath_raw=orig_image_filename #FILE else: - image_filename = path_image(t.texture.image) + image_filename = path_image(tex.image) # IMAGE SEQUENCE BEGINS if image_filename: - if bpy.data.images[t.texture.image.name].source == 'SEQUENCE': - korvaa = "." + str(t.texture.image_user.frame_offset + 1).zfill(3) + "." + if bpy.data.images[tex.image.name].source == 'SEQUENCE': + korvaa = "." + str(tex.image_user.frame_offset + 1).zfill(3) + "." image_filename = image_filename.replace(".001.", korvaa) print(" seq debug ") print(image_filename) @@ -842,13 +859,13 @@ def writeTextureInfluence(mater, materialNames, LocalMaterialNames, path_image, if t.use_map_normal: texturesNorm = image_filename # colvalue = t.normal_factor/10 # UNUSED - #textNormName=t.texture.image.name + ".normal" + #textNormName=tex.image.name + ".normal" #was the above used? --MR t_nor = t if t.use_map_alpha: texturesAlpha = image_filename # colvalue = t.alpha_factor * 10.0 # UNUSED - #textDispName=t.texture.image.name + ".displ" + #textDispName=tex.image.name + ".displ" #was the above used? --MR t_alpha = t @@ -1154,8 +1171,14 @@ def writeTextureInfluence(mater, materialNames, LocalMaterialNames, path_image, # Write another layered texture using invisible diffuse and metallic trick # to emulate colored specular highlights special_texture_found = False + idx = -1 for t in mater.pov_texture_slots: - if(t and t.use and ((t.texture.type == 'IMAGE' and t.texture.image) or t.texture.type != 'IMAGE') and + idx += 1 + # index = mater.pov.active_texture_index + slot = mater.pov_texture_slots[idx] # [index] + povtex = slot.name + tex = bpy.data.textures[povtex] + if(t and t.use and ((tex.type == 'IMAGE' and tex.image) or tex.type != 'IMAGE') and (t.use_map_specular or t.use_map_raymir)): # Specular mapped textures would conflict with colored specular # because POV can't layer over or under pigment patterned textures @@ -1175,20 +1198,20 @@ def writeTextureInfluence(mater, materialNames, LocalMaterialNames, path_image, texturesNorm = "" for t in mater.pov_texture_slots: - if t and t.texture.pov.tex_pattern_type != 'emulator': + if t and tex.pov.tex_pattern_type != 'emulator': proceduralFlag=True - image_filename = string_strip_hyphen(bpy.path.clean_name(t.texture.name)) - if (t and t.texture.type == 'IMAGE' and - t.use and t.texture.image and - t.texture.pov.tex_pattern_type == 'emulator'): + image_filename = string_strip_hyphen(bpy.path.clean_name(tex.name)) + if (t and tex.type == 'IMAGE' and + t.use and tex.image and + tex.pov.tex_pattern_type == 'emulator'): proceduralFlag=False - image_filename = path_image(t.texture.image) + image_filename = path_image(tex.image) imgGamma = "" if image_filename: if t.use_map_normal: texturesNorm = image_filename # colvalue = t.normal_factor/10 # UNUSED - #textNormName=t.texture.image.name + ".normal" + #textNormName=tex.image.name + ".normal" #was the above used? --MR t_nor = t if proceduralFlag: diff --git a/render_povray/ui.py b/render_povray/ui.py index 7fb9c27a692045a1d485436436d55f67226bb991..c397053decc98123e1c78bb0ec923a4da6ff865a 100644 --- a/render_povray/ui.py +++ b/render_povray/ui.py @@ -192,7 +192,9 @@ for member in dir(properties_material): subclass = getattr(properties_material, member) try: mat=bpy.context.active_object.active_material - if mat and mat.pov.type == "SURFACE" and (engine in cls.COMPAT_ENGINES) and not (mat.pov.material_use_nodes or mat.use_nodes): + if (mat and mat.pov.type == "SURFACE" + and not (mat.pov.material_use_nodes or mat.use_nodes)): + # and (engine in cls.COMPAT_ENGINES)) if subclasses were sorted subclass.COMPAT_ENGINES.add('POVRAY_RENDER') except: pass @@ -326,7 +328,7 @@ def locate_docpath(): def pov_context_tex_datablock(context): idblock = context.brush - if idblock: + if idblock and bpy.context.scene.texture_context == 'OTHER': return idblock # idblock = bpy.context.active_object.active_material @@ -2388,8 +2390,8 @@ class TEXTURE_PT_POV_influence(TextureSlotPanel, Panel): if (isinstance(idblock, Brush) and bpy.context.scene.texture_context == 'OTHER'): #XXX replace by bpy.types.Brush? return False - if not getattr(context, "pov_texture_slot", None): - return False + # if not getattr(context, "pov_texture_slot", None): + # return False engine = context.scene.render.engine return (engine in cls.COMPAT_ENGINES)