Second pass to update properties for 2.8... To be continued

This commit is contained in:
Maurice Raybaud 2019-04-14 22:10:50 +02:00
parent 5fdd91c09e
commit 7340921481
4 changed files with 1497 additions and 76 deletions

File diff suppressed because it is too large Load Diff

View File

@ -342,17 +342,17 @@ class PovrayMultiplyNode(Node, ObjectNodeTree):
bl_label = 'Multiply'
bl_icon = 'SOUND'
amount_x = FloatProperty(
amount_x : FloatProperty(
name="X",
description="Number of repeats",
min=1.0, max=10000.0, default=1.0)
amount_y = FloatProperty(
amount_y : FloatProperty(
name="Y",
description="Number of repeats",
min=1.0, max=10000.0, default=1.0)
amount_z = FloatProperty(
amount_z : FloatProperty(
name="Z",
description="Number of repeats",
min=1.0, max=10000.0, default=1.0)
@ -552,7 +552,7 @@ class PovrayBumpMapNode(Node, ObjectNodeTree):
bl_label = 'Bump map'
bl_icon = 'SOUND'
map_type = bpy.props.EnumProperty(
map_type : bpy.props.EnumProperty(
name="Map type",
description="",
items=(
@ -563,8 +563,8 @@ class PovrayBumpMapNode(Node, ObjectNodeTree):
('5', "Torroidal", "Torus or donut shaped mapping")
),
default='0')
image = StringProperty(maxlen=1024) # , subtype="FILE_PATH"
interpolate = EnumProperty(
image : StringProperty(maxlen=1024) # , subtype="FILE_PATH"
interpolate : EnumProperty(
name="Interpolate",
description="Adding the interpolate keyword can smooth the jagged look of a bitmap",
items=(
@ -572,7 +572,7 @@ class PovrayBumpMapNode(Node, ObjectNodeTree):
('4', "Normalized", "Gives normalized distance"),
),
default='2')
once = BoolProperty(description="Not to repeat", default=False)
once : BoolProperty(description="Not to repeat", default=False)
def init(self, context):
@ -703,7 +703,7 @@ class ShaderPatternNode(Node, ObjectNodeTree):
bl_idname = 'ShaderPatternNode'
bl_label = 'Other patterns'
pattern = EnumProperty(
pattern : EnumProperty(
name="Pattern",
description="Agate, Crackle, Gradient, Pavement, Spiral, Tiling",
items=(('agate', "Agate", ""),('crackle', "Crackle", ""),('gradient', "Gradient", ""),
@ -713,47 +713,47 @@ class ShaderPatternNode(Node, ObjectNodeTree):
('tiling', "Tiling", "")),
default='agate')
agate_turb = FloatProperty(
agate_turb : FloatProperty(
name="Agate turb",
description="Agate turbulence",
min=0.0, max=100.0, default=0.5)
crackle_form_x = FloatProperty(
crackle_form_x : FloatProperty(
name="X",
description="Form vector X",
min=-150.0, max=150.0, default=-1)
crackle_form_y = FloatProperty(
crackle_form_y : FloatProperty(
name="Y",
description="Form vector Y",
min=-150.0, max=150.0, default=1)
crackle_form_z = FloatProperty(
crackle_form_z : FloatProperty(
name="Z",
description="Form vector Z",
min=-150.0, max=150.0, default=0)
crackle_metric = FloatProperty(
crackle_metric : FloatProperty(
name="Metric",
description="Crackle metric",
min=0.0, max=150.0, default=1)
crackle_solid = BoolProperty(
crackle_solid : BoolProperty(
name="Solid",
description="Crackle solid",
default=False)
spiral_arms = FloatProperty(
spiral_arms : FloatProperty(
name="Number",
description="",
min=0.0, max=256.0, default=2.0)
tiling_number = IntProperty(
tiling_number : IntProperty(
name="Number",
description="",
min=1, max=27, default=1)
gradient_orient = EnumProperty(
gradient_orient : EnumProperty(
name="Orient",
description="",
items=(('x', "X", ""),
@ -856,22 +856,22 @@ class ShaderNormalMapNode(Node, ObjectNodeTree):
bl_idname = 'ShaderNormalMapNode'
bl_label = 'Normal map'
brick_size_x = FloatProperty(
brick_size_x : FloatProperty(
name="X",
description="",
min=0.0000, max=1.0000, default=0.2500)
brick_size_y = FloatProperty(
brick_size_y : FloatProperty(
name="Y",
description="",
min=0.0000, max=1.0000, default=0.0525)
brick_size_z = FloatProperty(
brick_size_z : FloatProperty(
name="Z",
description="",
min=0.0000, max=1.0000, default=0.1250)
brick_mortar = FloatProperty(
brick_mortar : FloatProperty(
name="Mortar",
description="Mortar",
min=0.000, max=1.500, default=0.01)
@ -922,7 +922,7 @@ class IsoPropsNode(Node, CompositorNodeTree):
'''ISO Props'''
bl_idname = 'IsoPropsNode'
bl_label = 'Iso'
node_label = StringProperty(maxlen=1024)
node_label : StringProperty(maxlen=1024)
def init(self, context):
ob = bpy.context.object
self.node_label = ob.name

View File

@ -444,9 +444,9 @@ def write_pov(filename, scene=None, info_callback=None):
#if material and material.transparency_method == 'RAYTRACE':
if material:
# But there can be only one!
if material.subsurface_scattering.use: # SSS IOR get highest priority
if material.pov_subsurface_scattering.use: # SSS IOR get highest priority
tabWrite("interior {\n")
tabWrite("ior %.6f\n" % material.subsurface_scattering.ior)
tabWrite("ior %.6f\n" % material.pov_subsurface_scattering.ior)
# Then the raytrace IOR taken from raytrace transparency properties and used for
# reflections if IOR Mirror option is checked.
elif material.pov.mirror_use_IOR:
@ -2678,7 +2678,7 @@ def write_pov(filename, scene=None, info_callback=None):
tabWrite("#declare %s =sphere {<0, 0, 0>,0 pigment{rgbt 1} no_image no_reflection no_radiosity photons{pass_through collect off} hollow}\n" % povdataname)
try:
me = ob.to_mesh(scene, True, 'RENDER')
me = ob.to_mesh(bpy.context.depsgraph, True, 'RENDER')
#XXX Here? identify the specific exception for mesh object with no data
#XXX So that we can write something for the dataname !
@ -2832,8 +2832,8 @@ def write_pov(filename, scene=None, info_callback=None):
else:
if material:
# Multiply diffuse with SSS Color
if material.subsurface_scattering.use:
diffuse_color = [i * j for i, j in zip(material.subsurface_scattering.color[:], material.diffuse_color[:])]
if material.pov_subsurface_scattering.use:
diffuse_color = [i * j for i, j in zip(material.pov_subsurface_scattering.color[:], material.diffuse_color[:])]
key = diffuse_color[0], diffuse_color[1], diffuse_color[2], \
material_index
vertCols[key] = [-1]
@ -2878,8 +2878,8 @@ def write_pov(filename, scene=None, info_callback=None):
ci3 = vertCols[col3[0], col3[1], col3[2], material_index][0]
else:
# Color per material - flat material color
if material.subsurface_scattering.use:
diffuse_color = [i * j for i, j in zip(material.subsurface_scattering.color[:], material.diffuse_color[:])]
if material.pov_subsurface_scattering.use:
diffuse_color = [i * j for i, j in zip(material.pov_subsurface_scattering.color[:], material.diffuse_color[:])]
else:
diffuse_color = material.diffuse_color[:]
ci1 = ci2 = ci3 = vertCols[diffuse_color[0], diffuse_color[1], \
@ -2992,8 +2992,8 @@ def write_pov(filename, scene=None, info_callback=None):
if material and material.pov.material_use_nodes == False: # WARNING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# Multiply diffuse with SSS Color
if material.subsurface_scattering.use:
diffuse_color = [i * j for i, j in zip(material.subsurface_scattering.color[:], material.diffuse_color[:])]
if material.pov_subsurface_scattering.use:
diffuse_color = [i * j for i, j in zip(material.pov_subsurface_scattering.color[:], material.diffuse_color[:])]
key = diffuse_color[0], diffuse_color[1], diffuse_color[2], i # i == f.mat
vertCols[key] = [-1]
else:
@ -3104,9 +3104,9 @@ def write_pov(filename, scene=None, info_callback=None):
ci1 = ci2 = ci3 = 0
else:
# Color per material - flat material color
if material.subsurface_scattering.use:
if material.pov_subsurface_scattering.use:
diffuse_color = [i * j for i, j in
zip(material.subsurface_scattering.color[:],
zip(material.pov_subsurface_scattering.color[:],
material.diffuse_color[:])]
else:
diffuse_color = material.diffuse_color[:]
@ -3480,17 +3480,17 @@ def write_pov(filename, scene=None, info_callback=None):
onceAmbient = 1
oncePhotons = 1
for material in bpy.data.materials:
if material.subsurface_scattering.use and onceSss:
if material.pov_subsurface_scattering.use and onceSss:
# In pov, the scale has reversed influence compared to blender. these number
# should correct that
tabWrite("mm_per_unit %.6f\n" % \
(material.subsurface_scattering.scale * 1000.0))
(material.pov_subsurface_scattering.scale * 1000.0))
# 1000 rather than scale * (-100.0) + 15.0))
# In POV-Ray, the scale factor for all subsurface shaders needs to be the same
# formerly sslt_samples were multiplied by 100 instead of 10
sslt_samples = (11 - material.subsurface_scattering.error_threshold) * 10
sslt_samples = (11 - material.pov_subsurface_scattering.error_threshold) * 10
tabWrite("subsurface { samples %d, %d }\n" % (sslt_samples, sslt_samples / 10))
onceSss = 0
@ -3670,6 +3670,7 @@ def write_pov_ini(scene, filename_ini, filename_log, filename_pov, filename_imag
feature_set = bpy.context.preferences.addons[__package__].preferences.branch_feature_set_povray
using_uberpov = (feature_set=='uberpov')
#scene = bpy.data.scenes[0]
scene = bpy.context.scene
render = scene.render
x = int(render.resolution_x * render.resolution_percentage * 0.01)
@ -3795,9 +3796,10 @@ class PovrayRender(bpy.types.RenderEngine):
return pov_binary
return ""
def _export(self, scene, povPath, renderImagePath):
def _export(self, depsgraph, povPath, renderImagePath):
import tempfile
scene = bpy.context.scene
if scene.pov.tempfiles_enable:
self._temp_file_in = tempfile.NamedTemporaryFile(suffix=".pov", delete=False).name
# PNG with POV 3.7, can show the background color with alpha. In the long run using the
@ -3833,7 +3835,7 @@ class PovrayRender(bpy.types.RenderEngine):
write_pov(self._temp_file_in, scene, info_callback)
else:
pass
def _render(self, scene):
def _render(self, depsgraph):
try:
os.remove(self._temp_file_out) # so as not to load the old file
except OSError:
@ -3901,8 +3903,9 @@ class PovrayRender(bpy.types.RenderEngine):
# Wait a bit before retrying file might be still in use by Blender,
# and Windows does not know how to delete a file in use!
time.sleep(self.DELAY)
def render(self, scene):
def render(self, depsgraph):
import tempfile
scene = bpy.context.scene
r = scene.render
x = int(r.resolution_x * r.resolution_percentage * 0.01)
y = int(r.resolution_y * r.resolution_percentage * 0.01)
@ -3933,7 +3936,7 @@ class PovrayRender(bpy.types.RenderEngine):
return True
if scene.pov.text_block !="":
if bpy.context.scene.pov.text_block !="":
if scene.pov.tempfiles_enable:
self._temp_file_in = tempfile.NamedTemporaryFile(suffix=".pov", delete=False).name
self._temp_file_out = tempfile.NamedTemporaryFile(suffix=".png", delete=False).name
@ -4147,10 +4150,10 @@ class PovrayRender(bpy.types.RenderEngine):
# start export
self.update_stats("", "POV-Ray 3.7: Exporting data from Blender")
self._export(scene, povPath, renderImagePath)
self._export(depsgraph, povPath, renderImagePath)
self.update_stats("", "POV-Ray 3.7: Parsing File")
if not self._render(scene):
if not self._render(depsgraph):
self.update_stats("", "POV-Ray 3.7: Not found")
#return

View File

@ -664,7 +664,7 @@ class WORLD_PT_POV_world(WorldButtonsPanel, bpy.types.Panel):
def draw(self, context):
layout = self.layout
world = context.world
world = context.world.pov
row = layout.row(align=True)
row.menu(POV_WORLD_MT_presets.__name__, text=POV_WORLD_MT_presets.bl_label)
@ -684,7 +684,7 @@ class WORLD_PT_POV_world(WorldButtonsPanel, bpy.types.Panel):
row.column().prop(world, "ambient_color")
#row = layout.row()
#row.prop(world, "exposure")
#row.prop(world, "exposure") #Re-implement later as a light multiplier
#row.prop(world, "color_range")
class RENDER_PT_povray_export_settings(RenderButtonsPanel, bpy.types.Panel):
@ -1075,7 +1075,57 @@ class MODIFIERS_PT_povray_modifiers(ModifierButtonsPanel, bpy.types.Panel):
# Inside Vector for CSG
col.prop(ob.pov, "inside_vector")
class MATERIAL_PT_POV_sss(MaterialButtonsPanel, bpy.types.Panel):
bl_label = "Subsurface Scattering"
bl_options = {'DEFAULT_CLOSED'}
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 #FORMERLY : #active_node_mat(context.material)
sss = mat.pov_subsurface_scattering
self.layout.active = (not mat.pov.use_shadeless)
self.layout.prop(sss, "use", text="")
def draw(self, context):
layout = self.layout
mat = active_node_mat(context.material)
sss = mat.pov_subsurface_scattering
layout.active = (sss.use) and (not mat.pov.use_shadeless)
row = layout.row().split()
sub = row.row(align=True).split(align=True, percentage=0.75)
sub.menu("MATERIAL_MT_sss_presets", text=bpy.types.MATERIAL_MT_sss_presets.bl_label)
sub.operator("material.sss_preset_add", text="", icon='ADD')
sub.operator("material.sss_preset_add", text="", icon='REMOVE').remove_active = True
split = layout.split()
col = split.column()
col.prop(sss, "ior")
col.prop(sss, "scale")
col.prop(sss, "color", text="")
col.prop(sss, "radius", text="RGB Radius", expand=True)
col = split.column()
sub = col.column(align=True)
sub.label(text="Blend:")
sub.prop(sss, "color_factor", text="Color")
sub.prop(sss, "texture_factor", text="Texture")
sub.label(text="Scattering Weight:")
sub.prop(sss, "front")
sub.prop(sss, "back")
col.separator()
col.prop(sss, "error_threshold", text="Error")
class MATERIAL_PT_povray_activate_node(MaterialButtonsPanel, bpy.types.Panel):
bl_label = "Activate Node Settings"
bl_context = "material"
@ -1147,8 +1197,64 @@ class MATERIAL_PT_povray_active_node(MaterialButtonsPanel, bpy.types.Panel):
socket.draw(context, row, node, socket.name)
else:
layout.label("No active nodes!")
class MATERIAL_PT_POV_mirror(MaterialButtonsPanel, bpy.types.Panel):
bl_label = "Mirror"
bl_options = {'DEFAULT_CLOSED'}
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
raym = mat.pov_raytrace_mirror
self.layout.prop(raym, "use", text="")
def draw(self, context):
layout = self.layout
mat = context.material #Formerly : #mat = active_node_mat(context.material)
raym = mat.pov_raytrace_mirror
layout.active = raym.use
split = layout.split()
col = split.column()
col.prop(raym, "reflect_factor")
col.prop(mat, "mirror_color", text="")
col = split.column()
col.prop(raym, "fresnel")
sub = col.column()
sub.active = (raym.fresnel > 0.0)
sub.prop(raym, "fresnel_factor", text="Blend")
split = layout.split()
col = split.column()
col.separator()
col.prop(raym, "depth")
col.prop(raym, "distance", text="Max Dist")
col.separator()
sub = col.split(percentage=0.4)
sub.active = (raym.distance > 0.0)
sub.label(text="Fade To:")
sub.prop(raym, "fade_to", text="")
col = split.column()
col.label(text="Gloss:")
col.prop(raym, "gloss_factor", text="Amount")
sub = col.column()
sub.active = (raym.gloss_factor < 1.0)
sub.prop(raym, "gloss_threshold", text="Threshold")
sub.prop(raym, "gloss_samples", text="Samples")
sub.prop(raym, "gloss_anisotropic", text="Anisotropic")
class MATERIAL_PT_povray_reflection(MaterialButtonsPanel, bpy.types.Panel):
bl_label = "POV-Ray Reflection"
COMPAT_ENGINES = {'POVRAY_RENDER'}
@ -1158,7 +1264,7 @@ class MATERIAL_PT_povray_reflection(MaterialButtonsPanel, bpy.types.Panel):
engine = context.scene.render.engine
mat=context.material
ob = context.object
return mat and mat.type == "SURFACE" and (engine in cls.COMPAT_ENGINES) and not (mat.pov.material_use_nodes or mat.use_nodes)
return mat and mat.pov.type == "SURFACE" and (engine in cls.COMPAT_ENGINES) and not (mat.pov.material_use_nodes or mat.use_nodes)
def draw(self, context):
layout = self.layout
@ -1173,9 +1279,9 @@ class MATERIAL_PT_povray_reflection(MaterialButtonsPanel, bpy.types.Panel):
col.prop(mat.pov, "conserve_energy")
col2=col.split().column()
if not mat.raytrace_mirror.use:
if not mat.pov_raytrace_mirror.use:
col2.label(text="Please Check Mirror settings :")
col2.active = mat.raytrace_mirror.use
col2.active = mat.pov_raytrace_mirror.use
col2.prop(mat.pov, "mirror_use_IOR")
if mat.pov.mirror_use_IOR:
col2.alignment = 'CENTER'
@ -2109,7 +2215,7 @@ class TEXT_OT_povray_insert(bpy.types.Operator):
bl_idname = "text.povray_insert"
bl_label = "Insert"
filepath = bpy.props.StringProperty(name="Filepath", subtype='FILE_PATH')
filepath : bpy.props.StringProperty(name="Filepath", subtype='FILE_PATH')
@classmethod
def poll(cls, context):
@ -2216,8 +2322,9 @@ def menu_func_templates(self, context):
classes = (
#POV_WORLD_MT_presets,
#AddPresetWorld,
WORLD_PT_POV_world,
POV_WORLD_MT_presets,
AddPresetWorld,
#RenderButtonsPanel,
#ModifierButtonsPanel,
#MaterialButtonsPanel,
@ -2249,8 +2356,10 @@ classes = (
AddPresetRadiosity,
RENDER_PT_povray_media,
MODIFIERS_PT_povray_modifiers,
MATERIAL_PT_POV_sss,
MATERIAL_PT_povray_activate_node,
MATERIAL_PT_povray_active_node,
MATERIAL_PT_POV_mirror,
MATERIAL_PT_povray_reflection,
MATERIAL_PT_povray_fade_color,
MATERIAL_PT_povray_caustics,