[Bf-extensions-cvs] [063caacf] master: pre 2.8 API changes Pass 6

Maurice Raybaud noreply at git.blender.org
Wed May 8 21:30:14 CEST 2019


Commit: 063caacf6e5d069cd7dc77db23ecf5e9c6d50522
Author: Maurice Raybaud
Date:   Wed May 8 21:30:06 2019 +0200
Branches: master
https://developer.blender.org/rBA063caacf6e5d069cd7dc77db23ecf5e9c6d50522

pre 2.8 API changes Pass 6

===================================================================

M	render_povray/__init__.py
M	render_povray/render.py
M	render_povray/shading.py
M	render_povray/ui.py

===================================================================

diff --git a/render_povray/__init__.py b/render_povray/__init__.py
index b7ceb5ef..d3b95b34 100644
--- a/render_povray/__init__.py
+++ b/render_povray/__init__.py
@@ -68,8 +68,6 @@ else:
 
 def string_strip_hyphen(name):
     return name.replace("-", "")
-
-
 ###############################################################################
 # Scene POV properties.
 ###############################################################################
@@ -296,6 +294,18 @@ class RenderPovSettingsScene(PropertyGroup):
                         "comparison",
             min=0.0, max=5.0, soft_min=0.01, soft_max=2.5, default=2.5)
 
+    alpha_mode: EnumProperty(
+            name="Alpha",
+            description="Representation of alpha information in the RGBA pixels",
+            items=(("SKY", "Sky", "Transparent pixels are filled with sky color"),
+                   ("TRANSPARENT", "Transparent", "Transparent, World background is transparent with premultiplied alpha")),
+            default="SKY")
+
+    use_shadows: BoolProperty(
+            name="Shadows",
+            description="Calculate shadows while rendering",
+            default=True)
+
     max_trace_level: IntProperty(
             name="Max Trace Level",
             description="Number of reflections/refractions allowed on ray "
@@ -705,10 +715,10 @@ class RenderPovSettingsMaterial(PropertyGroup):
             description="How intense (bright) the specular reflection is",
             min=0.0, max=1.0, soft_min=0.0, soft_max=1.0, default=0.5, precision=3)
 
-    # specular_ior: FloatProperty(
-            # name="IOR",
-            # description="Specular index of refraction",
-            # min=-10.0, max=10.0, soft_min=0.0, soft_max=10.0, default=1.0, precision=3)
+    specular_ior: FloatProperty(
+            name="IOR",
+            description="Specular index of refraction",
+            min=-10.0, max=10.0, soft_min=0.0, soft_max=10.0, default=1.0, precision=3)
             
     # ior: FloatProperty(
             # name="IOR",
@@ -3559,7 +3569,16 @@ class RenderPovSettingsCamera(PropertyGroup):
             description="Type the declared name in custom POV code or an external .inc "
                         "it points at. camera {} expected",
             default="")
-
+###############################################################################
+# Light POV properties.
+###############################################################################
+class RenderPovSettingsLight(PropertyGroup):
+    shadow_method: EnumProperty(
+                name="Shadow",
+                description="",
+                items=(("NOSHADOW", "No Shadow", "No Shadow"),
+                       ("RAY_SHADOW", "Ray Shadow", "Ray Shadow, Use ray tracing for shadow")),
+                default="RAY_SHADOW")
 ###############################################################################
 # World POV properties.
 ###############################################################################
@@ -3714,6 +3733,7 @@ class PovrayPreferences(AddonPreferences):
 classes = (
     PovrayPreferences,
     RenderPovSettingsCamera,
+    RenderPovSettingsLight,    
     RenderPovSettingsWorld,
     WorldTextureSlot,
     RenderPovSettingsMaterial,
@@ -3761,6 +3781,7 @@ def register():
     bpy.types.Texture.pov = PointerProperty(type=RenderPovSettingsTexture)
     bpy.types.Object.pov = PointerProperty(type=RenderPovSettingsObject)
     bpy.types.Camera.pov = PointerProperty(type=RenderPovSettingsCamera)
+    bpy.types.Light.pov = PointerProperty(type=RenderPovSettingsLight)
     bpy.types.World.pov = PointerProperty(type=RenderPovSettingsWorld)
     bpy.types.World.texture_slots = CollectionProperty(type = WorldTextureSlot)
     bpy.types.Text.pov = PointerProperty(type=RenderPovSettingsText)
@@ -3776,6 +3797,7 @@ def unregister():
     del bpy.types.Texture.pov
     del bpy.types.Object.pov
     del bpy.types.Camera.pov
+    del bpy.types.Light.pov
     del bpy.types.World.pov    
     del bpy.types.Text.pov
     nodeitems_utils.unregister_node_categories("POVRAYNODES")
diff --git a/render_povray/render.py b/render_povray/render.py
index 033013b8..fb80f2a2 100644
--- a/render_povray/render.py
+++ b/render_povray/render.py
@@ -654,8 +654,8 @@ def write_pov(filename, scene=None, info_callback=None):
                     tabWrite("jitter\n")
 
             # No shadow checked either at global or light level:
-            if(not scene.render.use_shadows or
-               (lamp.shadow_method == 'NOSHADOW')):
+            if(not scene.pov.use_shadows or
+               (lamp.pov.shadow_method == 'NOSHADOW')):
                 tabWrite("shadowless\n")
 
             # Sun shouldn't be attenuated. Area lights have no falloff attribute so they
@@ -3278,7 +3278,7 @@ def write_pov(filename, scene=None, info_callback=None):
                                 tabWrite("}\n")
 
     def exportWorld(world):
-        render = scene.render
+        render = scene.pov
         camera = scene.camera
         matrix = global_matrix @ camera.matrix_world
         if not world:
diff --git a/render_povray/shading.py b/render_povray/shading.py
index 03a63a9d..65fcaab1 100644
--- a/render_povray/shading.py
+++ b/render_povray/shading.py
@@ -12,7 +12,7 @@ def writeMaterial(using_uberpov, DEF_MAT_NAME, scene, tabWrite, safety, comments
 
     if material:
         # If saturation(.s) is not zero, then color is not grey, and has a tint
-        colored_specular_found = ((material.specular_color.s > 0.0) and (material.diffuse_shader != 'MINNAERT'))
+        colored_specular_found = ((material.pov.specular_color.s > 0.0) and (material.pov.diffuse_shader != 'MINNAERT'))
 
     ##################
     # Several versions of the finish: Level conditions are variations for specular/Mirror
@@ -46,8 +46,8 @@ def writeMaterial(using_uberpov, DEF_MAT_NAME, scene, tabWrite, safety, comments
         if material:
             # POV-Ray 3.7 now uses two diffuse values respectively for front and back shading
             # (the back diffuse is like blender translucency)
-            frontDiffuse = material.diffuse_intensity
-            backDiffuse = material.translucency
+            frontDiffuse = material.pov.diffuse_intensity
+            backDiffuse = material.pov.translucency
 
             if material.pov.conserve_energy:
 
@@ -66,7 +66,7 @@ def writeMaterial(using_uberpov, DEF_MAT_NAME, scene, tabWrite, safety, comments
                     frontDiffuse = min(frontDiffuse, (1.0 - backDiffuse))
 
             # map hardness between 0.0 and 1.0
-            roughness = ((1.0 - ((material.specular_hardness - 1.0) / 510.0)))
+            roughness = ((1.0 - ((material.pov.specular_hardness - 1.0) / 510.0)))
             ## scale from 0.0 to 0.1
             roughness *= 0.1
             # add a small value because 0.0 is invalid.
@@ -74,101 +74,101 @@ def writeMaterial(using_uberpov, DEF_MAT_NAME, scene, tabWrite, safety, comments
 
             ################################Diffuse Shader######################################
             # Not used for Full spec (Level=3) of the shader.
-            if material.diffuse_shader == 'OREN_NAYAR' and Level != 3:
+            if material.pov.diffuse_shader == 'OREN_NAYAR' and Level != 3:
                 # Blender roughness is what is generally called oren nayar Sigma,
                 # and brilliance in POV-Ray.
                 tabWrite("brilliance %.3g\n" % (0.9 + material.roughness))
 
-            if material.diffuse_shader == 'TOON' and Level != 3:
+            if material.pov.diffuse_shader == 'TOON' and Level != 3:
                 tabWrite("brilliance %.3g\n" % (0.01 + material.diffuse_toon_smooth * 0.25))
                 # Lower diffuse and increase specular for toon effect seems to look better
                 # in POV-Ray.
                 frontDiffuse *= 0.5
 
-            if material.diffuse_shader == 'MINNAERT' and Level != 3:
+            if material.pov.diffuse_shader == 'MINNAERT' and Level != 3:
                 #tabWrite("aoi %.3g\n" % material.darkness)
                 pass  # let's keep things simple for now
-            if material.diffuse_shader == 'FRESNEL' and Level != 3:
+            if material.pov.diffuse_shader == 'FRESNEL' and Level != 3:
                 #tabWrite("aoi %.3g\n" % material.diffuse_fresnel_factor)
                 pass  # let's keep things simple for now
-            if material.diffuse_shader == 'LAMBERT' and Level != 3:
+            if material.pov.diffuse_shader == 'LAMBERT' and Level != 3:
                 # trying to best match lambert attenuation by that constant brilliance value
                 tabWrite("brilliance 1\n")
 
             if Level == 2:
                 ###########################Specular Shader######################################
                 # No difference between phong and cook torrence in blender HaHa!
-                if (material.specular_shader == 'COOKTORR' or
-                    material.specular_shader == 'PHONG'):
-                    tabWrite("phong %.3g\n" % (material.specular_intensity))
-                    tabWrite("phong_size %.3g\n" % (material.specular_hardness /3.14))
+                if (material.pov.specular_shader == 'COOKTORR' or
+                    material.pov.specular_shader == 'PHONG'):
+                    tabWrite("phong %.3g\n" % (material.pov.specular_intensity))
+                    tabWrite("phong_size %.3g\n" % (material.pov.specular_hardness /3.14))
 
                 # POV-Ray 'specular' keyword corresponds to a Blinn model, without the ior.
-                elif material.specular_shader == 'BLINN':
+                elif material.pov.specular_shader == 'BLINN':
                     # Use blender Blinn's IOR just as some factor for spec intensity
-                    tabWrite("specular %.3g\n" % (material.specular_intensity *
-                                                  (material.specular_ior / 4.0)))
+                    tabWrite("specular %.3g\n" % (material.pov.specular_intensity *
+                                                  (material.pov.specular_ior / 4.0)))
                     tabWrite("roughness %.3g\n" % roughness)
                     #Could use brilliance 2(or 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list