diff options
author | Maurice Raybaud <mauriceraybaud@hotmail.fr> | 2017-02-01 19:50:49 +0300 |
---|---|---|
committer | Maurice Raybaud <mauriceraybaud@hotmail.fr> | 2017-02-01 19:50:49 +0300 |
commit | dbddb9496a97105fa6cdd6e0065ec599c49d2dce (patch) | |
tree | 74bc9a320ce20dc00f513b7ebc83990eb6c53b61 | |
parent | 1a0b479eda66cd8971a2625bb4197950f03828c4 (diff) |
Added some more properties from Lanuhum commits, such as
*photon map save and load
*camera normal perturbation
*Depth Of Field focal point by object (from Blender native dof_object property)
*unchecked always sample from radiosity defaults
*some other interface tweaks
-rw-r--r-- | render_povray/__init__.py | 44 | ||||
-rw-r--r-- | render_povray/render.py | 81 | ||||
-rw-r--r-- | render_povray/ui.py | 146 |
3 files changed, 183 insertions, 88 deletions
diff --git a/render_povray/__init__.py b/render_povray/__init__.py index 7b23f6c4..bd7142f7 100644 --- a/render_povray/__init__.py +++ b/render_povray/__init__.py @@ -1,4 +1,4 @@ -# ##### BEGIN GPL LICENSE BLOCK ##### +# ##### BEGIN GPL LICENSE BLOCK ##### # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -339,6 +339,30 @@ class RenderPovSettingsScene(PropertyGroup): photon_gather_max = IntProperty( name="Gather Max", description="Maximum number of photons gathered for each point", min=1, max=256, default=100) + + photon_map_file_save_load = EnumProperty( + name="Operation", + description="Load or Save photon map file", + items=(("NONE", "None", ""), + ("save", "Save", ""), + ("load", "Load", "")), + default="NONE") + + photon_map_filename = StringProperty( + name="Filename", + description="", + maxlen=1024) + + photon_map_dir = StringProperty( + name="Directory", + description="", + maxlen=1024, subtype="DIR_PATH") + + photon_map_file = StringProperty( + name="File", + description="", + maxlen=1024, subtype="FILE_PATH") + radio_adc_bailout = FloatProperty( name="ADC Bailout", @@ -2065,6 +2089,24 @@ class RenderPovSettingsCamera(PropertyGroup): "will lead to more samples, slower traces and better images", min=0.01, max=0.99, default=0.20) + normal_enable = BoolProperty(name="Perturbated Camera", default=False) + cam_normal = FloatProperty(name="Normal Strenght", min=0.0, max=1.0, default=0.0) + normal_patterns = EnumProperty( + name="Pattern", + description="", + items=(('agate', "Agate", ""), ('boxed', "Boxed", ""), ('bumps', "Bumps", ""), ('cells', "Cells", ""), + ('crackle', "Crackle", ""),('dents', "Dents", ""), + ('granite', "Granite", ""), + ('leopard', "Leopard", ""), + ('marble', "Marble", ""), ('onion', "Onion", ""), ('pavement', "Pavement", ""), ('planar', "Planar", ""), + ('quilted', "Quilted", ""), ('ripples', "Ripples", ""), ('radial', "Radial", ""), + ('spherical', "Spherical", ""),('spiral1', "Spiral1", ""), ('spiral2', "Spiral2", ""), ('spotted', "Spotted", ""), + ('square', "Square", ""),('tiling', "Tiling", ""), + ('waves', "Waves", ""), ('wood', "Wood", ""),('wrinkles', "Wrinkles", "")), + default='agate') + turbulence = FloatProperty(name="Turbulence", min=0.0, max=100.0, default=0.1) + scale = FloatProperty(name="Scale", min=0.0,default=1.0) + ##################################CustomPOV Code############################ # Only DUMMIES below for now: replacement_text = StringProperty( diff --git a/render_povray/render.py b/render_povray/render.py index 8d247b8c..1a98bdc5 100644 --- a/render_povray/render.py +++ b/render_povray/render.py @@ -205,30 +205,27 @@ smokePath = os.path.join(preview_dir, "smoke.df3") def write_global_setting(scene,file): file.write("global_settings {\n") file.write(" assumed_gamma %.6f\n"%scene.pov.assumed_gamma) - if scene.pov.global_settings_default == False: - if scene.pov.adc_bailout_enable and scene.pov.radio_enable == False: + if scene.pov.global_settings_advanced: + if scene.pov.radio_enable == False: file.write(" adc_bailout %.6f\n"%scene.pov.adc_bailout) - if scene.pov.ambient_light_enable: - file.write(" ambient_light <%.6f,%.6f,%.6f>\n"%scene.pov.ambient_light[:]) - if scene.pov.irid_wavelength_enable: - file.write(" irid_wavelength <%.6f,%.6f,%.6f>\n"%scene.pov.irid_wavelength[:]) - if scene.pov.charset_enable: - file.write(" charset %s\n"%scene.pov.charset) - if scene.pov.max_trace_level_enable: - file.write(" max_trace_level %s\n"%scene.pov.max_trace_level) - if scene.pov.max_intersections_enable: - file.write(" max_intersections %s\n"%scene.pov.max_intersections) - if scene.pov.number_of_waves_enable: - file.write(" number_of_waves %s\n"%scene.pov.number_of_waves) - if scene.pov.noise_generator_enable: - file.write(" noise_generator %s\n"%scene.pov.noise_generator) - if scene.pov.sslt_enable: - file.write(" mm_per_unit %s\n"%scene.pov.mm_per_unit) - file.write(" subsurface {\n") - file.write(" samples %s, %s\n"%(scene.pov.sslt_samples_max,scene.pov.sslt_samples_min)) - if scene.pov.sslt_radiosity: - file.write(" radiosity on\n") - file.write("}\n") + file.write(" ambient_light <%.6f,%.6f,%.6f>\n"%scene.pov.ambient_light[:]) + file.write(" irid_wavelength <%.6f,%.6f,%.6f>\n"%scene.pov.irid_wavelength[:]) + file.write(" charset %s\n"%scene.pov.charset) + file.write(" max_trace_level %s\n"%scene.pov.max_trace_level) + file.write(" max_intersections %s\n"%scene.pov.max_intersections) + file.write(" number_of_waves %s\n"%scene.pov.number_of_waves) + file.write(" noise_generator %s\n"%scene.pov.noise_generator) + + # below properties not added to __init__ yet to avoid conflicts with material sss scale + # unless it would override then should be interfaced also in scene units property tab + + # if scene.pov.sslt_enable: + # file.write(" mm_per_unit %s\n"%scene.pov.mm_per_unit) + # file.write(" subsurface {\n") + # file.write(" samples %s, %s\n"%(scene.pov.sslt_samples_max,scene.pov.sslt_samples_min)) + # if scene.pov.sslt_radiosity: + # file.write(" radiosity on\n") + # file.write("}\n") if scene.pov.radio_enable: file.write(" radiosity {\n") @@ -271,12 +268,21 @@ def write_global_setting(scene,file): file.write(" adc_bailout %.6f\n"%scene.pov.photon_adc_bailout) if scene.pov.photon_media_enable: file.write(" media %s, %s\n"%(scene.pov.photon_media_steps,scene.pov.photon_media_factor)) - if scene.pov.photon_savefile or scene.pov.photon_loadfile: - filePh = bpy.path.abspath(scene.pov.photon_map_file) - if scene.pov.photon_savefile: - file.write('save_file "%s"\n'%filePh) - if scene.pov.photon_loadfile and os.path.exists(filePh): - file.write('load_file "%s"\n'%filePh) + if scene.pov.photon_map_file_save_load in {'save'}: + filePhName = 'Photon_map_file.ph' + if scene.pov.photon_map_file != '': + filePhName = scene.pov.photon_map_file+'.ph' + filePhDir = tempfile.gettempdir() + path = bpy.path.abspath(scene.pov.photon_map_dir) + if os.path.exists(path): + filePhDir = path + fullFileName = os.path.join(filePhDir,filePhName) + file.write(' save_file "%s"\n'%fullFileName) + scene.pov.photon_map_file = fullFileName + if scene.pov.photon_map_file_save_load in {'load'}: + fullFileName = bpy.path.abspath(scene.pov.photon_map_file) + if os.path.exists(fullFileName): + file.write(' load_file "%s"\n'%fullFileName) file.write("}\n") file.write("}\n") @@ -516,16 +522,27 @@ 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: + if camera.data.pov.dof_enable and (focal_point != 0 or camera.data.dof_object): tabWrite("aperture %.3g\n" % camera.data.pov.dof_aperture) 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) tabWrite("confidence %.3g\n" % camera.data.pov.dof_confidence) - tabWrite("focal_point <0, 0, %f>\n" % focal_point) + if camera.data.dof_object: + focalOb = scene.objects[camera.data.dof_object.name] + matrixBlur = global_matrix * focalOb.matrix_world + tabWrite("focal_point <%.4f,%.4f,%.4f>\n"% matrixBlur.translation[:]) + else: + tabWrite("focal_point <0, 0, %f>\n" % focal_point) + if camera.data.pov.normal_enable: + tabWrite("normal {%s %.4f turbulence %.4f scale %.4f}\n"% + (camera.data.pov.normal_patterns, + camera.data.pov.cam_normal, + camera.data.pov.turbulence, + camera.data.pov.scale)) tabWrite("}\n") - + def exportLamps(lamps): # Incremented after each lamp export to declare its target diff --git a/render_povray/ui.py b/render_povray/ui.py index 21dcbd5e..45649ea8 100644 --- a/render_povray/ui.py +++ b/render_povray/ui.py @@ -395,11 +395,18 @@ del properties_data_lamp ############################################################################### class RENDER_PT_povray_export_settings(RenderButtonsPanel, bpy.types.Panel): - bl_label = "Export Settings" + bl_label = "INI Options" + bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'POVRAY_RENDER'} + def draw_header(self, context): - self.layout.label(icon='CONSOLE') + scene = context.scene + if scene.pov.tempfiles_enable: + self.layout.prop(scene.pov, "tempfiles_enable", text="", icon='AUTO') + else: + self.layout.prop(scene.pov, "tempfiles_enable", text="", icon='CONSOLE') + def draw(self, context): layout = self.layout @@ -412,36 +419,34 @@ class RENDER_PT_povray_export_settings(RenderButtonsPanel, bpy.types.Panel): col.label(text="Command line switches:") col.prop(scene.pov, "command_line_switches", text="") split = layout.split() - split.prop(scene.pov, "tempfiles_enable", text="OS Tempfiles") + + layout.active = not scene.pov.tempfiles_enable + #if not scene.pov.tempfiles_enable: + split.prop(scene.pov, "deletefiles_enable", text="Delete files") split.prop(scene.pov, "pov_editor", text="POV Editor") - if not scene.pov.tempfiles_enable: - split.prop(scene.pov, "deletefiles_enable", text="Delete files") - if not scene.pov.tempfiles_enable: - col = layout.column() - col.prop(scene.pov, "scene_name", text="Name") - col.prop(scene.pov, "scene_path", text="Path to files") - #col.prop(scene.pov, "scene_path", text="Path to POV-file") - #col.prop(scene.pov, "renderimage_path", text="Path to image") + col = layout.column() + col.prop(scene.pov, "scene_name", text="Name") + col.prop(scene.pov, "scene_path", text="Path to files") + #col.prop(scene.pov, "scene_path", text="Path to POV-file") + #col.prop(scene.pov, "renderimage_path", text="Path to image") - split = layout.split() - split.prop(scene.pov, "indentation_character", text="Indent") - if scene.pov.indentation_character == 'SPACE': - split.prop(scene.pov, "indentation_spaces", text="Spaces") + split = layout.split() + split.prop(scene.pov, "indentation_character", text="Indent") + if scene.pov.indentation_character == 'SPACE': + split.prop(scene.pov, "indentation_spaces", text="Spaces") - row = layout.row() - row.prop(scene.pov, "comments_enable", text="Comments") - row.prop(scene.pov, "list_lf_enable", text="Line breaks in lists") + row = layout.row() + row.prop(scene.pov, "comments_enable", text="Comments") + row.prop(scene.pov, "list_lf_enable", text="Line breaks in lists") class RENDER_PT_povray_render_settings(RenderButtonsPanel, bpy.types.Panel): bl_label = "Render Settings" bl_icon = 'SETTINGS' + bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'POVRAY_RENDER'} - # def draw_header(self, context): - # self.layout.label(icon='SETTINGS') - def draw_header(self, context): scene = context.scene if scene.pov.global_settings_advanced: @@ -452,37 +457,32 @@ class RENDER_PT_povray_render_settings(RenderButtonsPanel, bpy.types.Panel): layout = self.layout scene = context.scene - layout.active = (scene.pov.max_trace_level != 0) + #layout.active = (scene.pov.max_trace_level != 0) col = layout.column() col.label(text="Global Settings:") col.prop(scene.pov, "max_trace_level", text="Ray Depth") - if scene.pov.global_settings_advanced: - layout.prop(scene.pov,"charset") - align = True - row = layout.row(align = align) - row.prop(scene.pov,"adc_bailout_enable",text = "") - row.prop(scene.pov,"adc_bailout") - row = layout.row(align = align) - row.prop(scene.pov,"ambient_light_enable",text = "") - row.prop(scene.pov,"ambient_light") - row = layout.row(align = align) - row.prop(scene.pov,"irid_wavelength_enable",text = "") - row.prop(scene.pov,"irid_wavelength") - row = layout.row(align = align) - row.prop(scene.pov,"max_intersections_enable",text = "") - row.prop(scene.pov,"max_intersections") - row = layout.row(align = align) - row.prop(scene.pov,"number_of_waves_enable",text = "") - row.prop(scene.pov,"number_of_waves") - row = layout.row(align = align) - row.prop(scene.pov,"noise_generator_enable",text = "") - row.prop(scene.pov,"noise_generator") + layout.active = scene.pov.global_settings_advanced + layout.prop(scene.pov,"charset") + align = True + row = layout.row(align = align) + row.prop(scene.pov,"adc_bailout") + row = layout.row(align = align) + row.prop(scene.pov,"ambient_light") + row = layout.row(align = align) + row.prop(scene.pov,"irid_wavelength") + row = layout.row(align = align) + row.prop(scene.pov,"max_intersections") + row = layout.row(align = align) + row.prop(scene.pov,"number_of_waves") + row = layout.row(align = align) + row.prop(scene.pov,"noise_generator") class RENDER_PT_povray_photons(RenderButtonsPanel, bpy.types.Panel): bl_label = "Photons" + bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'POVRAY_RENDER'} # def draw_header(self, context): @@ -497,24 +497,36 @@ class RENDER_PT_povray_photons(RenderButtonsPanel, bpy.types.Panel): def draw(self, context): scene = context.scene layout = self.layout - if scene.pov.photon_enable: - col = layout.column() - #col.label(text="Global Photons:") - col.prop(scene.pov, "photon_max_trace_level", text="Photon Depth") - - split = layout.split() + layout.active = scene.pov.photon_enable + col = layout.column() + #col.label(text="Global Photons:") + col.prop(scene.pov, "photon_max_trace_level", text="Photon Depth") - col = split.column() - col.prop(scene.pov, "photon_spacing", text="Spacing") - col.prop(scene.pov, "photon_gather_min") + split = layout.split() - col = split.column() - col.prop(scene.pov, "photon_adc_bailout", text="Photon ADC") - col.prop(scene.pov, "photon_gather_max") + col = split.column() + col.prop(scene.pov, "photon_spacing", text="Spacing") + col.prop(scene.pov, "photon_gather_min") + col = split.column() + col.prop(scene.pov, "photon_adc_bailout", text="Photon ADC") + col.prop(scene.pov, "photon_gather_max") + + + box = layout.box() + box.label('Photon Map File:') + row = box.row() + row.prop(scene.pov, "photon_map_file_save_load",expand = True) + if scene.pov.photon_map_file_save_load in {'save'}: + box.prop(scene.pov, "photon_map_dir") + box.prop(scene.pov, "photon_map_filename") + if scene.pov.photon_map_file_save_load in {'load'}: + box.prop(scene.pov, "photon_map_file") + #end main photons class RENDER_PT_povray_antialias(RenderButtonsPanel, bpy.types.Panel): bl_label = "Anti-Aliasing" + bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'POVRAY_RENDER'} @@ -574,6 +586,7 @@ class RENDER_PT_povray_antialias(RenderButtonsPanel, bpy.types.Panel): class RENDER_PT_povray_radiosity(RenderButtonsPanel, bpy.types.Panel): bl_label = "Radiosity" + bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'POVRAY_RENDER'} def draw_header(self, context): scene = context.scene @@ -1605,6 +1618,29 @@ class CAMERA_PT_povray_cam_dof(CameraDataButtonsPanel, bpy.types.Panel): col.prop(cam.pov, "dof_confidence") + +class CAMERA_PT_povray_cam_nor(CameraDataButtonsPanel, bpy.types.Panel): + bl_label = "POV-Ray Perturbation" + COMPAT_ENGINES = {'POVRAY_RENDER'} + + def draw_header(self, context): + cam = context.camera + + self.layout.prop(cam.pov, "normal_enable", text="") + + def draw(self, context): + layout = self.layout + + cam = context.camera + + layout.active = cam.pov.normal_enable + + layout.prop(cam.pov,"normal_patterns") + layout.prop(cam.pov,"cam_normal") + layout.prop(cam.pov,"turbulence") + layout.prop(cam.pov,"scale") + + class CAMERA_PT_povray_replacement_text(CameraDataButtonsPanel, bpy.types.Panel): bl_label = "Custom POV Code" COMPAT_ENGINES = {'POVRAY_RENDER'} |