diff options
author | Maurice Raybaud <mauriceraybaud@hotmail.fr> | 2019-09-01 01:08:30 +0300 |
---|---|---|
committer | Maurice Raybaud <mauriceraybaud@hotmail.fr> | 2019-09-01 01:09:26 +0300 |
commit | 9780527eeed6523684327a6fc6a149a938ebd933 (patch) | |
tree | f3c82f33bd417a4e1ab93b7d488c550c68f72118 | |
parent | dcd48a616b220966163c4f15dfc133ea9de64469 (diff) |
render_povray: fixed material alpha transparency broken by 2.8 changes
-rw-r--r-- | render_povray/__init__.py | 13 | ||||
-rw-r--r-- | render_povray/render.py | 8 | ||||
-rw-r--r-- | render_povray/shading.py | 8 | ||||
-rw-r--r-- | render_povray/ui.py | 70 |
4 files changed, 83 insertions, 16 deletions
diff --git a/render_povray/__init__.py b/render_povray/__init__.py index 0551e2eb..5b7b332e 100644 --- a/render_povray/__init__.py +++ b/render_povray/__init__.py @@ -990,6 +990,11 @@ class RenderPovSettingsMaterial(PropertyGroup): name="Alpha", description="Alpha transparency of the material", min=0.0, max=1.0, soft_min=0.0, soft_max=1.0, default=1.0, precision=3) + + specular_alpha: FloatProperty( + name="Specular alpha", + description="Alpha transparency for specular areas", + min=0.0, max=1.0, soft_min=0.0, soft_max=1.0, default=1.0, precision=3) ambient: FloatProperty( name="Ambient", @@ -1714,10 +1719,6 @@ class MaterialSubsurfaceScattering(PropertyGroup): # Halo settings for the material # Type: MaterialHalo, (readonly, never None) - # alpha¶ - - # Alpha transparency of the material - # Type: float in [0, 1], default 0.0 # ambient @@ -1912,10 +1913,6 @@ class MaterialSubsurfaceScattering(PropertyGroup): # Shadow raytracing bias to prevent terminator problems on shadow boundary # Type: float in [0, 0.25], default 0.0 - # specular_alpha - - # Alpha transparency for specular areas - # Type: float in [0, 1], default 0.0 # specular_color diff --git a/render_povray/render.py b/render_povray/render.py index 69a6b56a..6fb2db80 100644 --- a/render_povray/render.py +++ b/render_povray/render.py @@ -1697,10 +1697,10 @@ def write_pov(filename, scene=None, info_callback=None): material = None if material: diffuse_color = material.diffuse_color - trans = 1.0 - material.alpha + trans = 1.0 - material.pov.alpha if material.use_transparency and material.transparency_method == 'RAYTRACE': povFilter = material.pov_raytrace_transparency.filter * (1.0 - material.alpha) - trans = (1.0 - material.alpha) - povFilter + trans = (1.0 - material.pov.alpha) - povFilter else: povFilter = 0.0 material_finish = materialNames[material.name] @@ -1762,10 +1762,10 @@ def write_pov(filename, scene=None, info_callback=None): if material: diffuse_color = material.diffuse_color - trans = 1.0 - material.alpha + trans = 1.0 - material.pov.alpha if material.use_transparency and material.transparency_method == 'RAYTRACE': povFilter = material.pov_raytrace_transparency.filter * (1.0 - material.alpha) - trans = (1.0 - material.alpha) - povFilter + trans = (1.0 - material.pov.alpha) - povFilter else: povFilter = 0.0 diff --git a/render_povray/shading.py b/render_povray/shading.py index 8bffda6f..07e867b7 100644 --- a/render_povray/shading.py +++ b/render_povray/shading.py @@ -745,7 +745,7 @@ def writeTextureInfluence(mater, materialNames, LocalMaterialNames, path_image, string_strip_hyphen, safety, col, os, preview_dir, unpacked_images): material_finish = materialNames[mater.name] if mater.pov.use_transparency: - trans = 1.0 - mater.alpha + trans = 1.0 - mater.pov.alpha else: trans = 0.0 if ((mater.specular_color.s == 0.0) or (mater.pov.diffuse_shader == 'MINNAERT')): @@ -754,9 +754,9 @@ def writeTextureInfluence(mater, materialNames, LocalMaterialNames, path_image, else: colored_specular_found = True - if mater.pov.use_transparency and mater.transparency_method == 'RAYTRACE': - povFilter = mater.raytrace_transparency.filter * (1.0 - mater.alpha) - trans = (1.0 - mater.alpha) - povFilter + if mater.pov.use_transparency and mater.pov.transparency_method == 'RAYTRACE': + povFilter = mater.pov_raytrace_transparency.filter * (1.0 - mater.pov.alpha) + trans = (1.0 - mater.pov.alpha) - povFilter else: povFilter = 0.0 diff --git a/render_povray/ui.py b/render_povray/ui.py index 1ffb0140..fa24955b 100644 --- a/render_povray/ui.py +++ b/render_povray/ui.py @@ -265,6 +265,11 @@ def check_material(mat): return True return False +def simple_material(mat): + if (mat is not None) and (not mat.use_nodes): + return True + return False + def check_add_mesh_extra_objects(): if "add_mesh_extra_objects" in bpy.context.preferences.addons.keys(): return True @@ -1517,6 +1522,70 @@ class MATERIAL_PT_POV_mirror(MaterialButtonsPanel, Panel): sub.prop(raym, "gloss_threshold", text="Threshold") sub.prop(raym, "gloss_samples", text="Samples") sub.prop(raym, "gloss_anisotropic", text="Anisotropic") + +class MATERIAL_PT_POV_transp(MaterialButtonsPanel, Panel): + bl_label = "Transparency" + COMPAT_ENGINES = {'POVRAY_RENDER'} + + @classmethod + def poll(cls, context): + mat = context.material + engine = context.scene.render.engine + return check_material(mat) and (mat.pov.type in {'SURFACE', 'WIRE'}) and (engine in cls.COMPAT_ENGINES) + + def draw_header(self, context): + mat = context.material + + if simple_material(mat): + self.layout.prop(mat.pov, "use_transparency", text="") + + def draw(self, context): + layout = self.layout + + base_mat = context.material + mat = context.material#FORMERLY active_node_mat(context.material) + rayt = mat.pov_raytrace_transparency + + if simple_material(base_mat): + row = layout.row() + row.active = mat.pov.use_transparency + row.prop(mat.pov, "transparency_method", expand=True) + + split = layout.split() + split.active = base_mat.pov.use_transparency + + col = split.column() + col.prop(mat.pov, "alpha") + row = col.row() + row.active = (base_mat.pov.transparency_method != 'MASK') and (not mat.pov.use_shadeless) + row.prop(mat.pov, "specular_alpha", text="Specular") + + col = split.column() + col.active = (not mat.pov.use_shadeless) + col.prop(rayt, "fresnel") + sub = col.column() + sub.active = (rayt.fresnel > 0.0) + sub.prop(rayt, "fresnel_factor", text="Blend") + + if base_mat.pov.transparency_method == 'RAYTRACE': + layout.separator() + split = layout.split() + split.active = base_mat.pov.use_transparency + + col = split.column() + col.prop(rayt, "ior") + col.prop(rayt, "filter") + col.prop(rayt, "falloff") + col.prop(rayt, "depth_max") + col.prop(rayt, "depth") + + col = split.column() + col.label(text="Gloss:") + col.prop(rayt, "gloss_factor", text="Amount") + sub = col.column() + sub.active = rayt.gloss_factor < 1.0 + sub.prop(rayt, "gloss_threshold", text="Threshold") + sub.prop(rayt, "gloss_samples", text="Samples") class MATERIAL_PT_povray_reflection(MaterialButtonsPanel, Panel): bl_label = "POV-Ray Reflection" @@ -3088,6 +3157,7 @@ classes = ( MATERIAL_PT_povray_activate_node, MATERIAL_PT_povray_active_node, MATERIAL_PT_POV_mirror, + MATERIAL_PT_POV_transp, MATERIAL_PT_povray_reflection, #MATERIAL_PT_POV_interior, MATERIAL_PT_povray_fade_color, |