*converted all calls to file.write of .shading.py to tabWrite function to no longer pass the file variable

*added a conversion of all image paths to forward slashes, preferred by POV, sending less warning.

*repaired basic handling of packed textures

*rearranged Material UI
This commit is contained in:
Maurice Raybaud 2016-05-23 21:20:39 +02:00
parent 4eafe3195c
commit 7e05091168
4 changed files with 71 additions and 109 deletions

View File

@ -351,7 +351,7 @@ class RenderPovSettingsScene(PropertyGroup):
###############################################################################
class RenderPovSettingsMaterial(PropertyGroup):
irid_enable = BoolProperty(
name="Enable Iridescence",
name="Iridescence coating",
description="Newton's thin film interference (like an oil slick on a puddle of "
"water or the rainbow hues of a soap bubble.)",
default=False)
@ -392,7 +392,7 @@ class RenderPovSettingsMaterial(PropertyGroup):
min=0.0, max=10.0, soft_min=0.000, soft_max=1.0, default=0)
interior_fade_color = FloatVectorProperty(
name="Fade Color", description="Color of filtered attenuation for transparent "
name="Interior Fade Color", description="Color of filtered attenuation for transparent "
"materials",
precision=4, step=0.01, min=0.0, soft_max=1.0,
default=(0, 0, 0), options={'ANIMATABLE'}, subtype='COLOR')
@ -412,11 +412,11 @@ class RenderPovSettingsMaterial(PropertyGroup):
description="Values typically range from 0.0 to 1.0 or higher. Zero is no caustics. "
"Low, non-zero values give broad hot-spots while higher values give "
"tighter, smaller simulated focal points",
min=0.00, max=10.0, soft_min=0.00, soft_max=1.10, default=0.5)
min=0.00, max=10.0, soft_min=0.00, soft_max=5.0, default=0.07)
photons_refraction = BoolProperty(
name="Refractive Photon Caustics", description="more physically correct",
default=False)
refraction_caustics = BoolProperty(
name="Refractive Caustics", description="hotspots of light focused when going through the material",
default=True)
photons_dispersion = FloatProperty(
name="Chromatic Dispersion",
@ -435,10 +435,10 @@ class RenderPovSettingsMaterial(PropertyGroup):
default=False)
refraction_type = EnumProperty(
items=[("0", "None", "use only reflective caustics"),
items=[
("1", "Fake Caustics", "use fake caustics"),
("2", "Photons Caustics", "use photons for refractive caustics")],
name="Refractive",
name="Refraction Type:",
description="use fake caustics (fast) or true photons for refractive Caustics",
default="1")

View File

@ -142,8 +142,9 @@ def imgMapBG(wts):
def path_image(image):
return bpy.path.abspath(image.filepath, library=image.library)
return bpy.path.abspath(image.filepath, library=image.library).replace("\\","/")
# .replace("\\","/") to get only forward slashes as it's what POV prefers,
# even on windows
# end find image texture
# -----------------------------------------------------------------------------
@ -425,7 +426,7 @@ def write_pov(filename, scene=None, info_callback=None):
if material.pov.photons_reflection:
pov_photons_reflection = True
if material.pov.refraction_type == "0":
if not material.pov.refraction_caustics:
pov_fake_caustics = False
pov_photons_refraction = False
elif material.pov.refraction_type == "1":
@ -2709,9 +2710,9 @@ def write_pov(filename, scene=None, info_callback=None):
LocalMaterialNames,
path_image, imageFormat,
imgMap, imgMapTransforms,
file, tabWrite,
tabWrite,
string_strip_hyphen,
safety, col)
safety, col, os, preview_dir, unpacked_images)
###################################################################
index[0] = idx
idx += 1
@ -3153,7 +3154,8 @@ def write_pov(filename, scene=None, info_callback=None):
#string_strip_hyphen(patternNames[texture.name]) #maybe instead of the above
LocalPatternNames.append(currentPatName)
#use above list to prevent writing texture instances several times and assign in mats?
file.write("\n#declare PAT_%s = \n" % currentPatName)
if (texture.type!='NONE' and texture.pov.tex_pattern_type == 'emulator')or(texture.type =='NONE' and texture.pov.tex_pattern_type != 'emulator'):
file.write("\n#declare PAT_%s = \n" % currentPatName)
file.write(shading.exportPattern(texture, string_strip_hyphen))
file.write("\n")
if comments:

View File

@ -266,7 +266,7 @@ def exportPattern(texture, string_strip_hyphen):
return colRampStrg
#much work to be done here only defaults translated for now:
#pov noise_generator 3 means perlin noise
if pat.tex_pattern_type == 'emulator':
if tex.type!='NONE' and pat.tex_pattern_type == 'emulator':
texStrg+="pigment {\n"
####################### EMULATE BLENDER VORONOI TEXTURE ####################
if tex.type == 'VORONOI':
@ -547,7 +547,7 @@ def exportPattern(texture, string_strip_hyphen):
texStrg+="function{pigment{%s}}\n"%PATname
texStrg+="\n"
else:
elif pat.tex_pattern_type != 'emulator':
texStrg+="pigment {\n"
texStrg+="%s\n"%pat.tex_pattern_type
if pat.tex_pattern_type == 'agate':
@ -706,8 +706,8 @@ def exportPattern(texture, string_strip_hyphen):
def writeTextureInfluence(mater, materialNames, LocalMaterialNames, path_image,
imageFormat, imgMap, imgMapTransforms, file,
tabWrite, string_strip_hyphen, safety, col):
imageFormat, imgMap, imgMapTransforms, tabWrite,
string_strip_hyphen, safety, col, os, preview_dir, unpacked_images):
material_finish = materialNames[mater.name]
if mater.use_transparency:
trans = 1.0 - mater.alpha
@ -809,17 +809,17 @@ def writeTextureInfluence(mater, materialNames, LocalMaterialNames, path_image,
####################################################################################
file.write("\n")
tabWrite("\n")
# THIS AREA NEEDS TO LEAVE THE TEXTURE OPEN UNTIL ALL MAPS ARE WRITTEN DOWN.
# --MR
currentMatName = string_strip_hyphen(materialNames[mater.name])
LocalMaterialNames.append(currentMatName)
file.write("\n#declare MAT_%s = \ntexture{\n" % currentMatName)
tabWrite("\n#declare MAT_%s = \ntexture{\n" % currentMatName)
################################################################################
if mater.pov.replacement_text != "":
file.write("%s\n" % mater.pov.replacement_text)
tabWrite("%s\n" % mater.pov.replacement_text)
#################################################################################
if mater.diffuse_shader == 'MINNAERT':
tabWrite("\n")
@ -1107,9 +1107,9 @@ def writeTextureInfluence(mater, materialNames, LocalMaterialNames, path_image,
## scale 1 rotate y*0
#imageMap = ("{image_map {%s \"%s\" %s }" % \
# (imageFormat(textures), textures,imgMap(t_dif)))
#file.write("\n\t\t\tuv_mapping pigment %s} %s finish {%s}" % \
#tabWrite("\n\t\t\tuv_mapping pigment %s} %s finish {%s}" % \
# (imageMap, mapping, safety(material_finish)))
#file.write("\n\t\t\tpigment {uv_mapping image_map " \
#tabWrite("\n\t\t\tpigment {uv_mapping image_map " \
# "{%s \"%s\" %s}%s} finish {%s}" % \
# (imageFormat(texturesDif), texturesDif,imgMap(t_dif),
# mappingDif, safety(material_finish)))
@ -1170,7 +1170,7 @@ def writeTextureInfluence(mater, materialNames, LocalMaterialNames, path_image,
if colored_specular_found and not special_texture_found:
if comments:
file.write(" // colored highlights with a stransparent metallic layer\n")
tabWrite(" // colored highlights with a stransparent metallic layer\n")
else:
tabWrite("\n")

View File

@ -612,46 +612,36 @@ class RENDER_PT_povray_media(WorldButtonsPanel, bpy.types.Panel):
## layout.active = scene.pov.baking_enable
class MATERIAL_PT_povray_mirrorIOR(MaterialButtonsPanel, bpy.types.Panel):
bl_label = "IOR Mirror"
class MATERIAL_PT_povray_reflection(MaterialButtonsPanel, bpy.types.Panel):
bl_label = "POV-Ray Reflection"
COMPAT_ENGINES = {'POVRAY_RENDER'}
def draw_header(self, context):
scene = context.material
self.layout.prop(scene.pov, "mirror_use_IOR", text="")
def draw(self, context):
layout = self.layout
mat = context.material
layout.active = mat.pov.mirror_use_IOR
if mat.pov.mirror_use_IOR:
col = layout.column()
col.prop(mat.pov, "irid_enable")
if mat.pov.irid_enable:
col = layout.column()
col.alignment = 'CENTER'
col.label(text="The current Raytrace ")
col.label(text="Transparency IOR is: " + str(mat.raytrace_transparency.ior))
class MATERIAL_PT_povray_metallic(MaterialButtonsPanel, bpy.types.Panel):
bl_label = "metallic Mirror"
COMPAT_ENGINES = {'POVRAY_RENDER'}
def draw_header(self, context):
scene = context.material
self.layout.prop(scene.pov, "mirror_metallic", text="")
def draw(self, context):
layout = self.layout
mat = context.material
layout.active = mat.pov.mirror_metallic
col.prop(mat.pov, "irid_amount", slider=True)
col.prop(mat.pov, "irid_thickness", slider=True)
col.prop(mat.pov, "irid_turbulence", slider=True)
col.prop(mat.pov, "conserve_energy")
col2=col.split().column()
if not mat.raytrace_mirror.use:
col2.label(text="Please Check Mirror settings :")
col2.active = mat.raytrace_mirror.use
col2.prop(mat.pov, "mirror_use_IOR")
if mat.pov.mirror_use_IOR:
col2.alignment = 'CENTER'
col2.label(text="The current Raytrace ")
col2.label(text="Transparency IOR is: " + str(mat.raytrace_transparency.ior))
col2.prop(mat.pov, "mirror_metallic")
class MATERIAL_PT_povray_fade_color(MaterialButtonsPanel, bpy.types.Panel):
bl_label = "Interior Fade Color"
bl_label = "POV-Ray Absorption"
COMPAT_ENGINES = {'POVRAY_RENDER'}
def draw_header(self, context):
@ -660,78 +650,48 @@ class MATERIAL_PT_povray_fade_color(MaterialButtonsPanel, bpy.types.Panel):
self.layout.prop(mat.pov, "interior_fade_color", text="")
def draw(self, context):
# layout = self.layout
# mat = context.material
layout = self.layout
mat = context.material
# layout.active = mat.pov.interior_fade_color
if mat.pov.interior_fade_color != (0.0, 0.0, 0.0):
layout.label(text="Raytrace transparency")
layout.label(text="depth max Limit needs")
layout.label(text="to be non zero to fade")
pass
class MATERIAL_PT_povray_conserve_energy(MaterialButtonsPanel, bpy.types.Panel):
bl_label = "conserve energy"
COMPAT_ENGINES = {'POVRAY_RENDER'}
def draw_header(self, context):
mat = context.material
self.layout.prop(mat.pov, "conserve_energy", text="")
def draw(self, context):
layout = self.layout
mat = context.material
layout.active = mat.pov.conserve_energy
class MATERIAL_PT_povray_iridescence(MaterialButtonsPanel, bpy.types.Panel):
bl_label = "iridescence"
COMPAT_ENGINES = {'POVRAY_RENDER'}
def draw_header(self, context):
mat = context.material
self.layout.prop(mat.pov, "irid_enable", text="")
def draw(self, context):
layout = self.layout
mat = context.material
layout.active = mat.pov.irid_enable
if mat.pov.irid_enable:
col = layout.column()
col.prop(mat.pov, "irid_amount", slider=True)
col.prop(mat.pov, "irid_thickness", slider=True)
col.prop(mat.pov, "irid_turbulence", slider=True)
class MATERIAL_PT_povray_caustics(MaterialButtonsPanel, bpy.types.Panel):
bl_label = "Caustics"
COMPAT_ENGINES = {'POVRAY_RENDER'}
def draw_header(self, context):
mat = context.material
self.layout.prop(mat.pov, "caustics_enable", text="")
if mat.pov.caustics_enable:
self.layout.prop(mat.pov, "caustics_enable", text="", icon="PMARKER_SEL" )
else:
self.layout.prop(mat.pov, "caustics_enable", text="", icon="PMARKER" )
def draw(self, context):
layout = self.layout
mat = context.material
layout.active = mat.pov.caustics_enable
col = layout.column()
if mat.pov.caustics_enable:
col = layout.column()
col.prop(mat.pov, "refraction_type")
col.prop(mat.pov, "refraction_caustics")
if mat.pov.refraction_caustics:
if mat.pov.refraction_type == "1":
col.prop(mat.pov, "fake_caustics_power", slider=True)
elif mat.pov.refraction_type == "2":
col.prop(mat.pov, "photons_dispersion", slider=True)
col.prop(mat.pov, "photons_dispersion_samples", slider=True)
col.prop(mat.pov, "refraction_type", text="")
if mat.pov.refraction_type == "1":
col.prop(mat.pov, "fake_caustics_power", slider=True)
elif mat.pov.refraction_type == "2":
col.prop(mat.pov, "photons_dispersion", slider=True)
col.prop(mat.pov, "photons_dispersion_samples", slider=True)
col.prop(mat.pov, "photons_reflection")
if mat.pov.refraction_type == "0" and not mat.pov.photons_reflection:
if not mat.pov.refraction_caustics and not mat.pov.photons_reflection:
col = layout.column()
col.alignment = 'CENTER'
col.label(text="Caustics override is on, ")