1 # ##### BEGIN GPL LICENSE BLOCK #####
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software Foundation,
15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 # ##### END GPL LICENSE BLOCK #####
21 """update new variables to values from older API.
23 It does not have a UI and used to be found with F3 search field.
24 This file needs an update."""
27 from bpy
.props
import (
38 # Temporally register old props, so we can access their values.
41 # Mapping old names -> old default values
42 # XXX We could also store the new name, but as it is just the same without leading pov_ ...
43 # Get default values of pov scene props.
46 "pov_tempfiles_enable",
47 "pov_deletefiles_enable",
50 "pov_renderimage_path",
53 "pov_radio_display_advanced",
58 "pov_indentation_character",
59 "pov_indentation_spaces",
60 "pov_comments_enable",
61 "pov_command_line_switches",
62 "pov_antialias_enable",
63 "pov_antialias_method",
64 "pov_antialias_depth",
65 "pov_antialias_threshold",
68 "pov_antialias_gamma",
69 "pov_max_trace_level",
71 "pov_photon_max_trace_level",
72 "pov_photon_adc_bailout",
73 "pov_photon_gather_min",
74 "pov_photon_gather_max",
75 "pov_radio_adc_bailout",
76 "pov_radio_always_sample",
77 "pov_radio_brightness",
79 "pov_radio_error_bound",
80 "pov_radio_gray_threshold",
81 "pov_radio_low_error_factor",
83 "pov_radio_minimum_reuse",
84 "pov_radio_nearest_count",
86 "pov_radio_recursion_limit",
87 "pov_radio_pretrace_start",
88 "pov_radio_pretrace_end",
90 old_sce_props
[k
] = getattr(bpy
.types
.Scene
, k
)[1].get('default', None)
92 # Get default values of pov material props.
97 "pov_mirror_metallic",
98 "pov_conserve_energy",
100 "pov_irid_thickness",
101 "pov_irid_turbulence",
102 "pov_interior_fade_color",
103 "pov_caustics_enable",
105 "pov_fake_caustics_power",
106 "pov_photons_refraction",
107 "pov_photons_dispersion",
108 "pov_photons_reflection",
109 "pov_refraction_type",
110 "pov_replacement_text",
112 old_mat_props
[k
] = getattr(bpy
.types
.Material
, k
)[1].get(
116 # Get default values of pov texture props.
119 "pov_tex_gamma_enable",
120 "pov_tex_gamma_value",
121 "pov_replacement_text",
123 old_tex_props
[k
] = getattr(bpy
.types
.Texture
, k
)[1].get('default', None)
125 # Get default values of pov object props.
128 "pov_importance_value",
129 "pov_collect_photons",
130 "pov_replacement_text",
132 old_obj_props
[k
] = getattr(bpy
.types
.Object
, k
)[1].get('default', None)
134 # Get default values of pov camera props.
139 "pov_dof_samples_min",
140 "pov_dof_samples_max",
142 "pov_dof_confidence",
143 "pov_replacement_text",
145 old_cam_props
[k
] = getattr(bpy
.types
.Camera
, k
)[1].get('default', None)
147 # Get default values of pov text props.
149 for k
in ["pov_custom_code"]:
150 old_txt_props
[k
] = getattr(bpy
.types
.Text
, k
)[1].get('default', None)
152 ################################################################################################
154 # For each old pov property of each scene, if its value is not equal to the default one,
155 # copy it to relevant new prop...
156 for sce
in bpy
.data
.scenes
:
157 for k
, d
in old_sce_props
.items():
158 val
= getattr(sce
, k
, d
)
160 setattr(sce
.pov
, k
[4:], val
)
161 # The same goes for materials, textures, etc.
162 for mat
in bpy
.data
.materials
:
163 for k
, d
in old_mat_props
.items():
164 val
= getattr(mat
, k
, d
)
166 setattr(mat
.pov
, k
[4:], val
)
167 for tex
in bpy
.data
.textures
:
168 for k
, d
in old_tex_props
.items():
169 val
= getattr(tex
, k
, d
)
171 setattr(tex
.pov
, k
[4:], val
)
172 for obj
in bpy
.data
.objects
:
173 for k
, d
in old_obj_props
.items():
174 val
= getattr(obj
, k
, d
)
176 setattr(obj
.pov
, k
[4:], val
)
177 for cam
in bpy
.data
.cameras
:
178 for k
, d
in old_cam_props
.items():
179 val
= getattr(cam
, k
, d
)
181 setattr(cam
.pov
, k
[4:], val
)
182 for txt
in bpy
.data
.texts
:
183 for k
, d
in old_txt_props
.items():
184 val
= getattr(txt
, k
, d
)
186 setattr(txt
.pov
, k
[4:], val
)
187 # Finally, unregister old props !
191 class RenderCopySettings(bpy
.types
.Operator
):
192 """Update old POV properties to new ones"""
194 bl_idname
= "scene.pov_update_properties"
195 bl_label
= "PovRay render: Update to script v0.0.9"
196 bl_option
= {'REGISTER'}
199 def poll(cls
, context
):
202 def execute(self
, context
):
208 Scene
= bpy
.types
.Scene
209 Mat
= bpy
.types
.Material
210 Tex
= bpy
.types
.Texture
211 Obj
= bpy
.types
.Object
212 Cam
= bpy
.types
.Camera
213 Text
= bpy
.types
.Text
214 ###########################SCENE##################################
217 Scene
.pov_tempfiles_enable
= BoolProperty(
218 name
="Enable Tempfiles",
219 description
="Enable the OS-Tempfiles. Otherwise set the path where to save the files",
222 Scene
.pov_deletefiles_enable
= BoolProperty(
224 description
="Delete files after rendering. Doesn't work with the image",
227 Scene
.pov_scene_name
= StringProperty(
229 description
="Name of POV-Ray scene to create. Empty name will use the name of the blend file",
233 Scene
.pov_scene_path
= StringProperty(
234 name
="Export scene path",
235 # description="Path to directory where the exported scene (POV and INI) is created", # Bug in POV-Ray RC3
236 description
="Path to directory where the files are created",
241 Scene
.pov_renderimage_path
= StringProperty(
242 name
="Rendered image path",
243 description
="Full path to directory where the rendered image is saved",
248 Scene
.pov_list_lf_enable
= BoolProperty(
250 description
="Enable line breaks in lists (vectors and indices). Disabled: lists are exported in one line",
254 # Not a real pov option, just to know if we should write
255 Scene
.pov_radio_enable
= BoolProperty(
256 name
="Enable Radiosity",
257 description
="Enable POV-Rays radiosity calculation",
260 Scene
.pov_radio_display_advanced
= BoolProperty(
261 name
="Advanced Options",
262 description
="Show advanced options",
265 Scene
.pov_media_enable
= BoolProperty(
267 description
="Enable POV-Rays atmospheric media",
270 Scene
.pov_media_samples
= IntProperty(
272 description
="Number of samples taken from camera to first object encountered along ray path for media calculation",
278 Scene
.pov_media_color
= FloatVectorProperty(
280 description
="The atmospheric media color",
286 default
=(0.001, 0.001, 0.001),
287 options
={'ANIMATABLE'},
290 Scene
.pov_baking_enable
= BoolProperty(
291 name
="Enable Baking",
292 description
="Enable POV-Rays texture baking",
295 Scene
.pov_indentation_character
= EnumProperty(
297 description
="Select the indentation type",
299 ("0", "None", "No indentation"),
300 ("1", "Tabs", "Indentation with tabs"),
301 ("2", "Spaces", "Indentation with spaces"),
305 Scene
.pov_indentation_spaces
= IntProperty(
306 name
="Quantity of spaces",
307 description
="The number of spaces for indentation",
313 Scene
.pov_comments_enable
= BoolProperty(
314 name
="Enable Comments",
315 description
="Add comments to pov file",
320 Scene
.pov_command_line_switches
= StringProperty(
321 name
="Command Line Switches",
322 description
="Command line switches consist of a + (plus) or - (minus) sign, followed by one or more alphabetic characters and possibly a numeric value",
327 Scene
.pov_antialias_enable
= BoolProperty(
328 name
="Anti-Alias", description
="Enable Anti-Aliasing", default
=True
331 Scene
.pov_antialias_method
= EnumProperty(
333 description
="AA-sampling method. Type 1 is an adaptive, non-recursive, super-sampling method. Type 2 is an adaptive and recursive super-sampling method",
335 ("0", "non-recursive AA", "Type 1 Sampling in POV-Ray"),
336 ("1", "recursive AA", "Type 2 Sampling in POV-Ray"),
341 Scene
.pov_antialias_depth
= IntProperty(
342 name
="Antialias Depth",
343 description
="Depth of pixel for sampling",
349 Scene
.pov_antialias_threshold
= FloatProperty(
350 name
="Antialias Threshold",
351 description
="Tolerance for sub-pixels",
359 Scene
.pov_jitter_enable
= BoolProperty(
361 description
="Enable Jittering. Adds noise into the sampling process (it should be avoided to use jitter in animation)",
365 Scene
.pov_jitter_amount
= FloatProperty(
366 name
="Jitter Amount",
367 description
="Amount of jittering",
375 Scene
.pov_antialias_gamma
= FloatProperty(
376 name
="Antialias Gamma",
377 description
="POV-Ray compares gamma-adjusted values for super sampling. Antialias Gamma sets the Gamma before comparison",
385 Scene
.pov_max_trace_level
= IntProperty(
386 name
="Max Trace Level",
387 description
="Number of reflections/refractions allowed on ray path",
393 Scene
.pov_photon_spacing
= FloatProperty(
395 description
="Average distance between photons on surfaces. half this get four times as many surface photons",
404 Scene
.pov_photon_max_trace_level
= IntProperty(
405 name
="Max Trace Level",
406 description
="Number of reflections/refractions allowed on ray path",
412 Scene
.pov_photon_adc_bailout
= FloatProperty(
414 description
="The adc_bailout for photons. Use adc_bailout = 0.01 / brightest_ambient_object for good results",
423 Scene
.pov_photon_gather_min
= IntProperty(
425 description
="Minimum number of photons gathered for each point",
431 Scene
.pov_photon_gather_max
= IntProperty(
433 description
="Maximum number of photons gathered for each point",
439 Scene
.pov_radio_adc_bailout
= FloatProperty(
441 description
="The adc_bailout for radiosity rays. Use adc_bailout = 0.01 / brightest_ambient_object for good results",
450 Scene
.pov_radio_always_sample
= BoolProperty(
451 name
="Always Sample",
452 description
="Only use the data from the pretrace step and not gather any new samples during the final radiosity pass",
456 Scene
.pov_radio_brightness
= FloatProperty(
458 description
="Amount objects are brightened before being returned upwards to the rest of the system",
466 Scene
.pov_radio_count
= IntProperty(
468 description
="Number of rays for each new radiosity value to be calculated (halton sequence over 1600)",
475 Scene
.pov_radio_error_bound
= FloatProperty(
477 description
="One of the two main speed/quality tuning values, lower values are more accurate",
485 Scene
.pov_radio_gray_threshold
= FloatProperty(
486 name
="Gray Threshold",
487 description
="One of the two main speed/quality tuning values, lower values are more accurate",
495 Scene
.pov_radio_low_error_factor
= FloatProperty(
496 name
="Low Error Factor",
497 description
="Just enough samples is slightly blotchy. Low error changes error tolerance for less critical last refining pass",
505 # max_sample - not available yet
506 Scene
.pov_radio_media
= BoolProperty(
508 description
="Radiosity estimation can be affected by media",
512 Scene
.pov_radio_minimum_reuse
= FloatProperty(
513 name
="Minimum Reuse",
514 description
="Fraction of the screen width which sets the minimum radius of reuse for each sample point (At values higher than 2% expect errors)",
523 Scene
.pov_radio_nearest_count
= IntProperty(
524 name
="Nearest Count",
525 description
="Number of old ambient values blended together to create a new interpolated value",
531 Scene
.pov_radio_normal
= BoolProperty(
533 description
="Radiosity estimation can be affected by normals",
537 Scene
.pov_radio_recursion_limit
= IntProperty(
538 name
="Recursion Limit",
539 description
="how many recursion levels are used to calculate the diffuse inter-reflection",
545 Scene
.pov_radio_pretrace_start
= FloatProperty(
546 name
="Pretrace Start",
547 description
="Fraction of the screen width which sets the size of the blocks in the mosaic preview first pass",
555 Scene
.pov_radio_pretrace_end
= FloatProperty(
557 description
="Fraction of the screen width which sets the size of the blocks in the mosaic preview last pass",
566 #############################MATERIAL######################################
568 Mat
.pov_irid_enable
= BoolProperty(
569 name
="Enable Iridescence",
570 description
="Newton's thin film interference (like an oil slick on a puddle of water or the rainbow hues of a soap bubble.)",
574 Mat
.pov_mirror_use_IOR
= BoolProperty(
575 name
="Correct Reflection",
576 description
="Use same IOR as raytrace transparency to calculate mirror reflections. More physically correct",
580 Mat
.pov_mirror_metallic
= BoolProperty(
581 name
="Metallic Reflection",
582 description
="mirror reflections get colored as diffuse (for metallic materials)",
586 Mat
.pov_conserve_energy
= BoolProperty(
587 name
="Conserve Energy",
588 description
="Light transmitted is more correctly reduced by mirror reflections, also the sum of diffuse and translucency gets reduced below one ",
592 Mat
.pov_irid_amount
= FloatProperty(
594 description
="Contribution of the iridescence effect to the overall surface color. As a rule of thumb keep to around 0.25 (25% contribution) or less, but experiment. If the surface is coming out too white, try lowering the diffuse and possibly the ambient values of the surface",
602 Mat
.pov_irid_thickness
= FloatProperty(
604 description
="A very thin film will have a high frequency of color changes while a thick film will have large areas of color",
612 Mat
.pov_irid_turbulence
= FloatProperty(
614 description
="This parameter varies the thickness",
622 Mat
.pov_interior_fade_color
= FloatVectorProperty(
624 description
="Color of filtered attenuation for transparent materials",
631 options
={'ANIMATABLE'},
634 Mat
.pov_caustics_enable
= BoolProperty(
636 description
="use only fake refractive caustics (default) or photon based reflective/refractive caustics",
640 Mat
.pov_fake_caustics
= BoolProperty(
641 name
="Fake Caustics",
642 description
="use only (Fast) fake refractive caustics",
646 Mat
.pov_fake_caustics_power
= FloatProperty(
647 name
="Fake caustics power",
648 description
="Values typically range from 0.0 to 1.0 or higher. Zero is no caustics. Low, non-zero values give broad hot-spots while higher values give tighter, smaller simulated focal points",
656 Mat
.pov_photons_refraction
= BoolProperty(
657 name
="Refractive Photon Caustics",
658 description
="more physically correct",
662 Mat
.pov_photons_dispersion
= FloatProperty(
663 name
="chromatic dispersion",
664 description
="Light passing through will be separated according to wavelength. This ratio of refractive indices for violet to red controls how much the colors are spread out 1 = no dispersion, good values are 1.01 to 1.1",
673 Mat
.pov_photons_reflection
= BoolProperty(
674 name
="Reflective Photon Caustics",
675 description
="Use this to make your Sauron's ring ;-P",
679 Mat
.pov_refraction_type
= EnumProperty(
681 ("0", "None", "use only reflective caustics"),
682 ("1", "Fake Caustics", "use fake caustics"),
683 ("2", "Photons Caustics", "use photons for refractive caustics"),
686 description
="use fake caustics (fast) or true photons for refractive Caustics",
689 ##################################CustomPOV Code############################
690 Mat
.pov_replacement_text
= StringProperty(
691 name
="Declared name:",
692 description
="Type the declared name in custom POV code or an external .inc it points at. texture {} expected",
696 # Only DUMMIES below for now:
697 Tex
.pov_replacement_text
= StringProperty(
698 name
="Declared name:",
699 description
="Type the declared name in custom POV code or an external .inc it points at. pigment {} expected",
703 Obj
.pov_replacement_text
= StringProperty(
704 name
="Declared name:",
705 description
="Type the declared name in custom POV code or an external .inc it points at. Any POV shape expected e.g: isosurface {}",
709 Cam
.pov_replacement_text
= StringProperty(
710 name
="Texts in blend file",
711 description
="Type the declared name in custom POV code or an external .inc it points at. camera {} expected",
714 ##############################TEXTURE######################################
716 # Custom texture gamma
717 Tex
.pov_tex_gamma_enable
= BoolProperty(
718 name
="Enable custom texture gamma",
719 description
="Notify some custom gamma for which texture has been precorrected without the file format carrying it and only if it differs from your OS expected standard (see pov doc)",
723 Tex
.pov_tex_gamma_value
= FloatProperty(
724 name
="Custom texture gamma",
725 description
="value for which the file was issued e.g. a Raw photo is gamma 1.0",
733 #################################OBJECT####################################
735 # Importance sampling
736 Obj
.pov_importance_value
= FloatProperty(
737 name
="Radiosity Importance",
738 description
="Priority value relative to other objects for sampling radiosity rays. Increase to get more radiosity rays at comparatively small yet bright objects",
745 Obj
.pov_collect_photons
= BoolProperty(
746 name
="Receive Photon Caustics",
747 description
="Enable object to collect photons from other objects caustics. Turn off for objects that don't really need to receive caustics (e.g. objects that generate caustics often don't need to show any on themselves) ",
751 ##################################CAMERA###################################
754 Cam
.pov_dof_enable
= BoolProperty(
755 name
="Depth Of Field",
756 description
="Enable POV-Ray Depth Of Field ",
760 # Aperture (Intensity of the Blur)
761 Cam
.pov_dof_aperture
= FloatProperty(
763 description
="Similar to a real camera's aperture effect over focal blur (though not in physical units and independent of focal length).Increase to get more blur",
769 # Aperture adaptive sampling
770 Cam
.pov_dof_samples_min
= IntProperty(
772 description
="Minimum number of rays to use for each pixel",
778 Cam
.pov_dof_samples_max
= IntProperty(
780 description
="Maximum number of rays to use for each pixel",
786 Cam
.pov_dof_variance
= IntProperty(
788 description
="Minimum threshold (fractional value) for adaptive DOF sampling (up increases quality and render time). The value for the variance should be in the range of the smallest displayable color difference",
795 Cam
.pov_dof_confidence
= FloatProperty(
797 description
="Probability to reach the real color value. Larger confidence values will lead to more samples, slower traces and better images",
803 ###################################TEXT####################################
805 Text
.pov_custom_code
= BoolProperty(
807 description
="Add this text at the top of the exported POV-Ray file",
813 Scene
= bpy
.types
.Scene
814 Mat
= bpy
.types
.Material
815 Tex
= bpy
.types
.Texture
816 Obj
= bpy
.types
.Object
817 Cam
= bpy
.types
.Camera
818 Text
= bpy
.types
.Text
819 del Scene
.pov_tempfiles_enable
# CR
820 del Scene
.pov_scene_name
# CR
821 del Scene
.pov_deletefiles_enable
# CR
822 del Scene
.pov_scene_path
# CR
823 del Scene
.pov_renderimage_path
# CR
824 del Scene
.pov_list_lf_enable
# CR
825 del Scene
.pov_radio_enable
826 del Scene
.pov_radio_display_advanced
827 del Scene
.pov_radio_adc_bailout
828 del Scene
.pov_radio_always_sample
829 del Scene
.pov_radio_brightness
830 del Scene
.pov_radio_count
831 del Scene
.pov_radio_error_bound
832 del Scene
.pov_radio_gray_threshold
833 del Scene
.pov_radio_low_error_factor
834 del Scene
.pov_radio_media
835 del Scene
.pov_radio_minimum_reuse
836 del Scene
.pov_radio_nearest_count
837 del Scene
.pov_radio_normal
838 del Scene
.pov_radio_recursion_limit
839 del Scene
.pov_radio_pretrace_start
# MR
840 del Scene
.pov_radio_pretrace_end
# MR
841 del Scene
.pov_media_enable
# MR
842 del Scene
.pov_media_samples
# MR
843 del Scene
.pov_media_color
# MR
844 del Scene
.pov_baking_enable
# MR
845 del Scene
.pov_max_trace_level
# MR
846 del Scene
.pov_photon_spacing
# MR
847 del Scene
.pov_photon_max_trace_level
# MR
848 del Scene
.pov_photon_adc_bailout
# MR
849 del Scene
.pov_photon_gather_min
# MR
850 del Scene
.pov_photon_gather_max
# MR
851 del Scene
.pov_antialias_enable
# CR
852 del Scene
.pov_antialias_method
# CR
853 del Scene
.pov_antialias_depth
# CR
854 del Scene
.pov_antialias_threshold
# CR
855 del Scene
.pov_antialias_gamma
# CR
856 del Scene
.pov_jitter_enable
# CR
857 del Scene
.pov_jitter_amount
# CR
858 del Scene
.pov_command_line_switches
# CR
859 del Scene
.pov_indentation_character
# CR
860 del Scene
.pov_indentation_spaces
# CR
861 del Scene
.pov_comments_enable
# CR
862 del Mat
.pov_irid_enable
# MR
863 del Mat
.pov_mirror_use_IOR
# MR
864 del Mat
.pov_mirror_metallic
# MR
865 del Mat
.pov_conserve_energy
# MR
866 del Mat
.pov_irid_amount
# MR
867 del Mat
.pov_irid_thickness
# MR
868 del Mat
.pov_irid_turbulence
# MR
869 del Mat
.pov_interior_fade_color
# MR
870 del Mat
.pov_caustics_enable
# MR
871 del Mat
.pov_fake_caustics
# MR
872 del Mat
.pov_fake_caustics_power
# MR
873 del Mat
.pov_photons_refraction
# MR
874 del Mat
.pov_photons_dispersion
# MR
875 del Mat
.pov_photons_reflection
# MR
876 del Mat
.pov_refraction_type
# MR
877 del Mat
.pov_replacement_text
# MR
878 del Tex
.pov_tex_gamma_enable
# MR
879 del Tex
.pov_tex_gamma_value
# MR
880 del Tex
.pov_replacement_text
# MR
881 del Obj
.pov_importance_value
# MR
882 del Obj
.pov_collect_photons
# MR
883 del Obj
.pov_replacement_text
# MR
884 del Cam
.pov_dof_enable
# MR
885 del Cam
.pov_dof_aperture
# MR
886 del Cam
.pov_dof_samples_min
# MR
887 del Cam
.pov_dof_samples_max
# MR
888 del Cam
.pov_dof_variance
# MR
889 del Cam
.pov_dof_confidence
# MR
890 del Cam
.pov_replacement_text
# MR
891 del Text
.pov_custom_code
# MR