diff options
author | Maurice Raybaud <mauriceraybaud@hotmail.fr> | 2019-05-19 22:22:57 +0300 |
---|---|---|
committer | Maurice Raybaud <mauriceraybaud@hotmail.fr> | 2019-05-19 22:22:57 +0300 |
commit | 53e11f6552dfd2defbf2b5c4fd1621d3dfdb6129 (patch) | |
tree | 251494d97342a2978147df91257542292dcab8c2 | |
parent | b539bd244926c83d1b57a3b6ee1098f4af775ab2 (diff) |
pre 2.8 API changes Pass 7
-rw-r--r-- | render_povray/__init__.py | 385 | ||||
-rw-r--r-- | render_povray/render.py | 14 | ||||
-rw-r--r-- | render_povray/shading.py | 16 | ||||
-rw-r--r-- | render_povray/ui.py | 60 |
4 files changed, 439 insertions, 36 deletions
diff --git a/render_povray/__init__.py b/render_povray/__init__.py index d3b95b34..932d0501 100644 --- a/render_povray/__init__.py +++ b/render_povray/__init__.py @@ -556,6 +556,379 @@ class RenderPovSettingsScene(PropertyGroup): ############################################################################### # Material POV properties. ############################################################################### +class MaterialTextureSlot(PropertyGroup): + + alpha_factor: FloatProperty( + name="Alpha", + description="Amount texture affects alpha", + default = 0.0) + + ambient_factor: FloatProperty( + name="", + description="Amount texture affects ambient", + default = 0.0) + + bump_method: EnumProperty( + name="", + description="Method to use for bump mapping", + items=(("BUMP_ORIGINAL", "Bump Original", ""), + ("BUMP_COMPATIBLE", "Bump Compatible", ""), + ("BUMP_DEFAULT", "Bump Default", ""), + ("BUMP_BEST_QUALITY", "Bump Best Quality", "")), + default="BUMP_ORIGINAL") + + bump_objectspace: EnumProperty( + name="", + description="Space to apply bump mapping in", + items=(("BUMP_VIEWSPACE", "Bump Viewspace", ""), + ("BUMP_OBJECTSPACE", "Bump Objectspace", ""), + ("BUMP_TEXTURESPACE", "Bump Texturespace", "")), + default="BUMP_VIEWSPACE") + + density_factor: FloatProperty( + name="", + description="Amount texture affects density", + default = 0.0) + + diffuse_color_factor: FloatProperty( + name="", + description="Amount texture affects diffuse color", + default = 0.0) + + diffuse_factor: FloatProperty( + name="", + description="Amount texture affects diffuse reflectivity", + default = 0.0) + + displacement_factor: FloatProperty( + name="", + description="Amount texture displaces the surface", + default = 0.0) + + emission_color_factor: FloatProperty( + name="", + description="Amount texture affects emission color", + default = 0.0) + + emission_factor: FloatProperty( + name="", + description="Amount texture affects emission", + default = 0.0) + + emit_factor: FloatProperty( + name="", + description="Amount texture affects emission", + default = 0.0) + + hardness_factor: FloatProperty( + name="", + description="Amount texture affects hardness", + default = 0.0) + + mapping: EnumProperty( + name="", + description="", + items=(("FLAT", "Flat", ""), + ("CUBE", "Cube", ""), + ("TUBE", "Tube", ""), + ("SPHERE", "Sphere", "")), + default="FLAT") + + mapping_x: EnumProperty( + name="", + description="", + items=(("NONE", "", ""), + ("X", "", ""), + ("Y", "", ""), + ("Z", "", "")), + default="NONE") + + mapping_y: EnumProperty( + name="", + description="", + items=(("NONE", "", ""), + ("X", "", ""), + ("Y", "", ""), + ("Z", "", "")), + default="NONE") + + mapping_z: EnumProperty( + name="", + description="", + items=(("NONE", "", ""), + ("X", "", ""), + ("Y", "", ""), + ("Z", "", "")), + default="NONE") + + mirror_factor: FloatProperty( + name="", + description="Amount texture affects mirror color", + default = 0.0) + + normal_factor: FloatProperty( + name="", + description="Amount texture affects normal values", + default = 0.0) + + normal_map_space: EnumProperty( + name="", + description="Sets space of normal map image", + items=(("CAMERA", "Camera", ""), + ("WORLD", "World", ""), + ("OBJECT", "Object", ""), + ("TANGENT", "Tangent", "")), + default="CAMERA") + + object: StringProperty( + name="Object", + description="Object to use for mapping with Object texture coordinates", + default ="") + + raymir_factor: FloatProperty( + name="", + description="Amount texture affects ray mirror", + default = 0.0) + + reflection_color_factor: FloatProperty( + name="", + description="Amount texture affects color of out-scattered light", + default = 0.0) + + reflection_factor: FloatProperty( + name="", + description="Amount texture affects brightness of out-scattered light", + default = 0.0) + + scattering_factor: FloatProperty( + name="", + description="Amount texture affects scattering", + default = 0.0) + + specular_color_factor: FloatProperty( + name="", + description="Amount texture affects specular color", + default = 0.0) + + specular_factor: FloatProperty( + name="", + description="Amount texture affects specular reflectivity", + default = 0.0) + + texture_coords: EnumProperty( + name="", + description="", + items=(("GLOBAL", "Global", ""), + ("OBJECT", "Object", ""), + ("UV", "UV", ""), + ("ORCO", "Original Coordinates", ""), + ("STRAND", "Strand", ""), + ("STICKY", "Sticky", ""), + ("WINDOW", "Window", ""), + ("NORMAL", "Normal", ""), + ("REFLECTION", "Reflection", ""), + ("STRESS", "Stress", ""), + ("TANGENT", "Tangent", "")), + default="GLOBAL") + + translucency_factor: FloatProperty( + name="", + description="Amount texture affects translucency", + default = 0.0) + + transmission_color_factor: FloatProperty( + name="", + description="Amount texture affects result color after light has been scattered/absorbed", + default = 0.0) + + use: BoolProperty( + name="", + description="Enable this material texture slot", + default = False) + + use_from_dupli: BoolProperty( + name="", + description="Dupli’s instanced from verts, faces or particles, inherit texture coordinate from their parent", + default = False) + + use_from_original: BoolProperty( + name="", + description="Dupli’s derive their object coordinates from the original objects transformation", + default = False) + + use_map_alpha: BoolProperty( + name="", + description="Causes the texture to affect the alpha value", + default = False) + + use_map_ambient: BoolProperty( + name="", + description="Causes the texture to affect the value of ambient", + default = False) + + use_map_color_diffuse: BoolProperty( + name="", + description="Causes the texture to affect basic color of the material", + default = False) + + use_map_color_emission: BoolProperty( + name="", + description="Causes the texture to affect the color of emission", + default = False) + + use_map_color_reflection: BoolProperty( + name="", + description="Causes the texture to affect the color of scattered light", + default = False) + + use_map_color_spec: BoolProperty( + name="", + description="Causes the texture to affect the specularity color", + default = False) + + use_map_color_transmission: BoolProperty( + name="", + description="Causes the texture to affect the result color after other light has been scattered/absorbed", + default = False) + + use_map_density: BoolProperty( + name="", + description="Causes the texture to affect the volume’s density", + default = False) + + use_map_diffuse: BoolProperty( + name="", + description="Causes the texture to affect the value of the materials diffuse reflectivity", + default = False) + + use_map_displacement: BoolProperty( + name="", + description="Let the texture displace the surface", + default = False) + + use_map_emission: BoolProperty( + name="", + description="Causes the texture to affect the volume’s emission", + default = False) + + use_map_emit: BoolProperty( + name="", + description="Causes the texture to affect the emit value", + default = False) + + use_map_hardness: BoolProperty( + name="", + description="Causes the texture to affect the hardness value", + default = False) + + use_map_mirror: BoolProperty( + name="", + description="Causes the texture to affect the mirror color", + default = False) + + use_map_normal: BoolProperty( + name="", + description="Causes the texture to affect the rendered normal", + default = False) + + use_map_raymir: BoolProperty( + name="", + description="Causes the texture to affect the ray-mirror value", + default = False) + + use_map_reflect: BoolProperty( + name="", + description="Causes the texture to affect the reflected light’s brightness", + default = False) + + use_map_scatter: BoolProperty( + name="", + description="Causes the texture to affect the volume’s scattering", + default = False) + + use_map_specular: BoolProperty( + name="", + description="Causes the texture to affect the value of specular reflectivity", + default = False) + + use_map_translucency: BoolProperty( + name="", + description="Causes the texture to affect the translucency value", + default = False) + + use_map_warp: BoolProperty( + name="", + description="Let the texture warp texture coordinates of next channels", + default = False) + + uv_layer: StringProperty( + name="", + description="UV layer to use for mapping with UV texture coordinates", + default = "") + + warp_factor: FloatProperty( + name="", + description="Amount texture affects texture coordinates of next channels", + default = 0.0) + + +#######################################" + + blend_factor: FloatProperty( + name="Blend", + description="Amount texture affects color progression of the " + "background", + soft_min=0.0, soft_max=1.0, default=1.0) + + horizon_factor: FloatProperty( + name="Horizon", + description="Amount texture affects color of the horizon" + "", + soft_min=0.0, soft_max=1.0, default=1.0) + + object: StringProperty( + name="Object", + description="Object to use for mapping with Object texture coordinates", + default="") + + texture_coords: EnumProperty( + name="Coordinates", + description="Texture coordinates used to map the texture onto the background", + items=(("VIEW", "View", "Use view vector for the texture coordinates"), + ("GLOBAL", "Global", "Use global coordinates for the texture coordinates (interior mist)"), + ("ANGMAP", "AngMap", "Use 360 degree angular coordinates, e.g. for spherical light probes"), + ("SPHERE", "Sphere", "For 360 degree panorama sky, spherical mapped, only top half"), + ("EQUIRECT", "Equirectangular", "For 360 degree panorama sky, equirectangular mapping"), + ("TUBE", "Tube", "For 360 degree panorama sky, cylindrical mapped, only top half"), + ("OBJECT", "Object", "Use linked object’s coordinates for texture coordinates")), + default="VIEW") + + use_map_blend: BoolProperty( + name="Blend Map", description="Affect the color progression of the background", + default=True) + + use_map_horizon: BoolProperty( + name="Horizon Map", description="Affect the color of the horizon", + default=False) + + use_map_zenith_down: BoolProperty( + name="", description="Affect the color of the zenith below", + default=False) + + use_map_zenith_up: BoolProperty( + name="Zenith Up Map", description="Affect the color of the zenith above", + default=False) + + zenith_down_factor: FloatProperty( + name="Zenith Down", + description="Amount texture affects color of the zenith below", + soft_min=0.0, soft_max=1.0, default=1.0) + + zenith_up_factor: FloatProperty( + name="Zenith Up", + description="Amount texture affects color of the zenith above", + soft_min=0.0, soft_max=1.0, default=1.0) + class RenderPovSettingsMaterial(PropertyGroup): ######################Begin Old Blender Internal Props######################### @@ -720,10 +1093,10 @@ class RenderPovSettingsMaterial(PropertyGroup): 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", - # description="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", + description="Index of refraction", + min=-10.0, max=10.0, soft_min=0.0, soft_max=10.0, default=1.0, precision=3) specular_shader: EnumProperty( name="Specular Shader Model", @@ -1098,6 +1471,8 @@ class RenderPovSettingsMaterial(PropertyGroup): object_preview_scale: FloatProperty(name="XYZ", min=0.5, max=2.0, default=1.0) object_preview_rotate: FloatVectorProperty(name="Rotate", description="", min=-180.0, max=180.0,default=(0.0,0.0,0.0), subtype='XYZ') object_preview_bgcontrast: FloatProperty(name="Contrast", min=0.0, max=1.0, default=0.5) + +#TODO?: class MaterialRaytraceTransparency(PropertyGroup): class MaterialRaytraceMirror(PropertyGroup): bl_description = "Raytraced reflection settings for the Material", @@ -3735,6 +4110,7 @@ classes = ( RenderPovSettingsCamera, RenderPovSettingsLight, RenderPovSettingsWorld, + MaterialTextureSlot, WorldTextureSlot, RenderPovSettingsMaterial, MaterialRaytraceMirror, @@ -3783,6 +4159,7 @@ def register(): bpy.types.Camera.pov = PointerProperty(type=RenderPovSettingsCamera) bpy.types.Light.pov = PointerProperty(type=RenderPovSettingsLight) bpy.types.World.pov = PointerProperty(type=RenderPovSettingsWorld) + bpy.types.Material.texture_slots = CollectionProperty(type = MaterialTextureSlot) bpy.types.World.texture_slots = CollectionProperty(type = WorldTextureSlot) bpy.types.Text.pov = PointerProperty(type=RenderPovSettingsText) diff --git a/render_povray/render.py b/render_povray/render.py index 56e3f8ec..f4c72cca 100644 --- a/render_povray/render.py +++ b/render_povray/render.py @@ -451,10 +451,10 @@ def write_pov(filename, scene=None, info_callback=None): # reflections if IOR Mirror option is checked. elif material.pov.mirror_use_IOR: tabWrite("interior {\n") - tabWrite("ior %.6f\n" % material.raytrace_transparency.ior) + tabWrite("ior %.6f\n" % material.pov.ior) else: tabWrite("interior {\n") - tabWrite("ior %.6f\n" % material.raytrace_transparency.ior) + tabWrite("ior %.6f\n" % material.pov.ior) pov_fake_caustics = False pov_photons_refraction = False @@ -519,7 +519,7 @@ def write_pov(filename, scene=None, info_callback=None): # DH disabled for now, this isn't the correct context active_object = None # bpy.context.active_object # does not always work MR matrix = global_matrix @ camera.matrix_world - focal_point = camera.data.dof_distance + focal_point = camera.data.dof.focus_distance # compute resolution Qsize = render.resolution_x / render.resolution_y @@ -546,8 +546,8 @@ def write_pov(filename, scene=None, info_callback=None): tabWrite("rotate <%.6f, %.6f, %.6f>\n" % \ tuple([degrees(e) for e in matrix.to_3x3().to_euler()])) tabWrite("translate <%.6f, %.6f, %.6f>\n" % matrix.translation[:]) - if camera.data.pov.dof_enable and (focal_point != 0 or camera.data.dof_object): - tabWrite("aperture %.3g\n" % camera.data.pov.dof_aperture) + if camera.data.dof.use_dof and (focal_point != 0 or camera.data.dof.focus_object): + tabWrite("aperture %.3g\n" % 1/camera.data.dof.aperture_fstop*1000) tabWrite("blur_samples %d %d\n" % \ (camera.data.pov.dof_samples_min, camera.data.pov.dof_samples_max)) tabWrite("variance 1/%d\n" % camera.data.pov.dof_variance) @@ -2693,6 +2693,7 @@ def write_pov(filename, scene=None, info_callback=None): importance = ob.pov.importance_value if me: + me.calc_loop_triangles() me_materials = me.materials me_faces = me.loop_triangles[:] #if len(me_faces)==0: @@ -2777,7 +2778,7 @@ def write_pov(filename, scene=None, info_callback=None): # Generate unique UV's uniqueUVs = {} #n = 0 - for f in me.faces: + for f in me_faces: # me.faces in 2.7 uvs = [uv_layer[l].uv[:] for l in f.loops] for uv in uvs: @@ -3841,6 +3842,7 @@ class PovrayRender(bpy.types.RenderEngine): else: pass def _render(self, depsgraph): + scene = bpy.context.scene try: os.remove(self._temp_file_out) # so as not to load the old file except OSError: diff --git a/render_povray/shading.py b/render_povray/shading.py index 65fcaab1..8bffda6f 100644 --- a/render_povray/shading.py +++ b/render_povray/shading.py @@ -744,17 +744,17 @@ def writeTextureInfluence(mater, materialNames, LocalMaterialNames, path_image, imageFormat, imgMap, imgMapTransforms, tabWrite, comments, string_strip_hyphen, safety, col, os, preview_dir, unpacked_images): material_finish = materialNames[mater.name] - if mater.use_transparency: + if mater.pov.use_transparency: trans = 1.0 - mater.alpha else: trans = 0.0 - if ((mater.specular_color.s == 0.0) or (mater.diffuse_shader == 'MINNAERT')): + if ((mater.specular_color.s == 0.0) or (mater.pov.diffuse_shader == 'MINNAERT')): # No layered texture because of aoi pattern used for minnaert and pov can't layer patterned colored_specular_found = False else: colored_specular_found = True - if mater.use_transparency and mater.transparency_method == 'RAYTRACE': + 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 else: @@ -866,7 +866,7 @@ def writeTextureInfluence(mater, materialNames, LocalMaterialNames, path_image, if mater.pov.replacement_text != "": tabWrite("%s\n" % mater.pov.replacement_text) ################################################################################# - if mater.diffuse_shader == 'MINNAERT': + if mater.pov.diffuse_shader == 'MINNAERT': tabWrite("\n") tabWrite("aoi\n") tabWrite("texture_map {\n") @@ -874,7 +874,7 @@ def writeTextureInfluence(mater, materialNames, LocalMaterialNames, path_image, (mater.darkness / 2.0, 2.0 - mater.darkness)) tabWrite("[%.3g\n" % (1.0 - (mater.darkness / 2.0))) - if mater.diffuse_shader == 'FRESNEL': + if mater.pov.diffuse_shader == 'FRESNEL': # For FRESNEL diffuse in POV, we'll layer slope patterned textures # with lamp vector as the slope vector and nest one slope per lamp # into each texture map's entry. @@ -1130,10 +1130,10 @@ def writeTextureInfluence(mater, materialNames, LocalMaterialNames, path_image, tabWrite("}\n") #End of slope/ior texture_map - if mater.diffuse_shader == 'MINNAERT' and mater.pov.replacement_text == "": + if mater.pov.diffuse_shader == 'MINNAERT' and mater.pov.replacement_text == "": tabWrite("]\n") tabWrite("}\n") - if mater.diffuse_shader == 'FRESNEL' and mater.pov.replacement_text == "": + if mater.pov.diffuse_shader == 'FRESNEL' and mater.pov.replacement_text == "": c = 1 while (c <= lampCount): tabWrite("]\n") @@ -1145,7 +1145,7 @@ def writeTextureInfluence(mater, materialNames, LocalMaterialNames, path_image, # Close first layer of POV "texture" (Blender material) tabWrite("}\n") - if ((mater.specular_color.s > 0.0) and (mater.diffuse_shader != 'MINNAERT')): + if ((mater.specular_color.s > 0.0) and (mater.pov.diffuse_shader != 'MINNAERT')): colored_specular_found = True else: diff --git a/render_povray/ui.py b/render_povray/ui.py index 44e83681..365dc064 100644 --- a/render_povray/ui.py +++ b/render_povray/ui.py @@ -1424,7 +1424,7 @@ class MATERIAL_PT_povray_reflection(MaterialButtonsPanel, bpy.types.Panel): 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.label(text="Transparency IOR is: " + str(mat.pov.ior)) col2.prop(mat.pov, "mirror_metallic") @@ -1517,6 +1517,28 @@ class MATERIAL_PT_povray_replacement_text(MaterialButtonsPanel, bpy.types.Panel) col.label(text="Replace properties with:") col.prop(mat.pov, "replacement_text", text="") +class MATERIAL_TEXTURE_SLOTS_UL_List(UIList): + """Texture Slots UIList.""" + + + def draw_item(self, context, layout, material, item, icon, active_data, + material_texture_list_index, index): + material = context.material#.pov + active_data = material + #tex = context.texture #may be needed later? + + + # We could write some code to decide which icon to use here... + custom_icon = 'TEXTURE' + + # Make sure your code supports all 3 layout types + if self.layout_type in {'DEFAULT', 'COMPACT'}: + layout.label(item.name, icon = custom_icon) + + elif self.layout_type in {'GRID'}: + layout.alignment = 'CENTER' + layout.label("", icon = custom_icon) + class WORLD_TEXTURE_SLOTS_UL_List(UIList): """Texture Slots UIList.""" @@ -1546,16 +1568,16 @@ class TEXTURE_PT_povray_type(TextureButtonsPanel, bpy.types.Panel): def draw(self, context): layout = self.layout - + world = context.world tex = context.texture split = layout.split(factor=0.2) split.label(text="POV:") split.prop(tex.pov, "tex_pattern_type", text="") - row = layout.row() - row.template_list("WORLD_TEXTURE_SLOTS_UL_List", "The_List", world, - "texture_slots", world, "world_texture_list_index") + # row = layout.row() + # row.template_list("WORLD_TEXTURE_SLOTS_UL_List", "texture_slots", world, + # world.texture_slots, world, "world_texture_list_index") class TEXTURE_PT_povray_preview(TextureButtonsPanel, bpy.types.Panel): @@ -2307,31 +2329,33 @@ def menu_func_nodes(self, context): # Camera Povray Settings ############################################################################### class CAMERA_PT_povray_cam_dof(CameraDataButtonsPanel, bpy.types.Panel): - bl_label = "POV-Ray Depth Of Field" + bl_label = "POV-Ray Aperture" COMPAT_ENGINES = {'POVRAY_RENDER'} + bl_parent_id = "DATA_PT_camera_dof_aperture" + bl_options = {'HIDE_HEADER'} + #def draw_header(self, context): + #cam = context.camera - def draw_header(self, context): - cam = context.camera - - self.layout.prop(cam.pov, "dof_enable", text="") + #self.layout.prop(cam.pov, "dof_enable", text="") def draw(self, context): layout = self.layout cam = context.camera - layout.active = cam.pov.dof_enable - - layout.prop(cam.pov, "dof_aperture") + layout.active = cam.dof.use_dof + layout.use_property_split = True # Active single-column layout - split = layout.split() + flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=False) - col = split.column() + col = flow.column() + col.label(text="F-Stop value will export as") + col.label(text="POV-Ray aperture : " + "%.3f" % (1/cam.dof.aperture_fstop*1000)) + + col = flow.column() col.prop(cam.pov, "dof_samples_min") - col.prop(cam.pov, "dof_variance") - - col = split.column() col.prop(cam.pov, "dof_samples_max") + col.prop(cam.pov, "dof_variance") col.prop(cam.pov, "dof_confidence") |