Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaurice Raybaud <mauriceraybaud@hotmail.fr>2019-12-01 23:24:45 +0300
committerMaurice Raybaud <mauriceraybaud@hotmail.fr>2019-12-08 23:42:14 +0300
commit90d3e69f6597f9d0a3b670b41441cb5ae5ebabe2 (patch)
tree4fa0681b5628e5d5d70827a60556100c2c852f69 /render_povray
parent41d06336af87fee59a5dae767aa4315152f49222 (diff)
pov: more api fix
texture slot steps further
Diffstat (limited to 'render_povray')
-rw-r--r--render_povray/__init__.py2
-rw-r--r--render_povray/shading.py79
-rw-r--r--render_povray/ui.py10
3 files changed, 58 insertions, 33 deletions
diff --git a/render_povray/__init__.py b/render_povray/__init__.py
index d172d1d5..96d1319c 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 1e92f9b0..b63443c2 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 7fb9c27a..c397053d 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)