1 # SPDX-FileCopyrightText: 2010-2022 Blender Foundation
3 # SPDX-License-Identifier: GPL-2.0-or-later
5 """update new variables to values from older API.
7 It does not have a UI and used to be found with F3 search field.
8 This file needs an update."""
11 from bpy
.props
import (
21 # *update this file to just cover 2.79 to 3.xx and ui it from a Blender internal to pov menu
22 # *as well as update from older pov > switch to QMC when pov 3.8 is out ?
23 # *filter if possible files built in pre 2.79 versions. tell user their file is too old and may
24 # be salvaged from older version of this operator from within latest stable blender 2.79 version.
25 # else if bpy.app.version[0] == 2 and bpy.app.version[1] <= 92 and and bpy.app.version[1] >= 79:
26 # warn users to update blender to 3.xx for creating their newer files then try to salvage
29 # if bpy.app.version[0] >= 3: # just test file created a)there or b)before, a) do nothing
30 # "your version is relatively futureproof" > doing nothing
31 # b)"use this operator to salvage your blends from latest stable 2.79"
35 """Update properties from older Blender versions. The render API changed a lot up to 2.79."""
36 # Temporally register old props, so we can access their values.
39 # Mapping old names -> old default values
40 # XXX We could also store the new name, but as it is just the same without leading pov_ ...
41 # Get default values of pov scene props.
43 k
: getattr(bpy
.types
.Scene
, k
)[1].get("default", None)
45 "pov_tempfiles_enable",
46 "pov_deletefiles_enable",
49 "pov_renderimage_path",
52 "pov_radio_display_advanced",
57 "pov_indentation_character",
58 "pov_indentation_spaces",
59 "pov_comments_enable",
60 "pov_command_line_switches",
61 "pov_antialias_enable",
62 "pov_antialias_method",
63 "pov_antialias_depth",
64 "pov_antialias_threshold",
67 "pov_antialias_gamma",
68 "pov_max_trace_level",
70 "pov_photon_max_trace_level",
71 "pov_photon_adc_bailout",
72 "pov_photon_gather_min",
73 "pov_photon_gather_max",
74 "pov_radio_adc_bailout",
75 "pov_radio_always_sample",
76 "pov_radio_brightness",
78 "pov_radio_error_bound",
79 "pov_radio_gray_threshold",
80 "pov_radio_low_error_factor",
82 "pov_radio_minimum_reuse",
83 "pov_radio_nearest_count",
85 "pov_radio_recursion_limit",
86 "pov_radio_pretrace_start",
87 "pov_radio_pretrace_end",
91 # Get default values of pov material props.
93 k
: getattr(bpy
.types
.Material
, k
)[1].get("default", None)
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",
114 # Get default values of pov texture props.
116 k
: getattr(bpy
.types
.Texture
, k
)[1].get("default", None)
118 "pov_tex_gamma_enable",
119 "pov_tex_gamma_value",
120 "pov_replacement_text",
124 # Get default values of pov object props.
126 k
: getattr(bpy
.types
.Object
, k
)[1].get("default", None)
128 "pov_importance_value",
129 "pov_collect_photons",
130 "pov_replacement_text",
134 # Get default values of pov camera props.
136 k
: getattr(bpy
.types
.Camera
, k
)[1].get("default", None)
140 "pov_dof_samples_min",
141 "pov_dof_samples_max",
143 "pov_dof_confidence",
144 "pov_replacement_text",
148 # Get default values of pov text props.
150 k
: getattr(bpy
.types
.Text
, k
)[1].get("default", None) for k
in ["pov_custom_code"]
153 # -----------------------------------------------------------------------------
155 # For each old pov property of each scene, if its value is not equal to the default one,
156 # copy it to relevant new prop...
157 for sce
in bpy
.data
.scenes
:
158 for k
, d
in old_sce_props
.items():
159 val
= getattr(sce
, k
, d
)
161 setattr(sce
.pov
, k
[4:], val
)
162 # The same goes for materials, textures, etc.
163 for mat
in bpy
.data
.materials
:
164 for k
, d
in old_mat_props
.items():
165 val
= getattr(mat
, k
, d
)
167 setattr(mat
.pov
, k
[4:], val
)
168 for tex
in bpy
.data
.textures
:
169 for k
, d
in old_tex_props
.items():
170 val
= getattr(tex
, k
, d
)
172 setattr(tex
.pov
, k
[4:], val
)
173 for obj
in bpy
.data
.objects
:
174 for k
, d
in old_obj_props
.items():
175 val
= getattr(obj
, k
, d
)
177 setattr(obj
.pov
, k
[4:], val
)
178 for cam
in bpy
.data
.cameras
:
179 for k
, d
in old_cam_props
.items():
180 val
= getattr(cam
, k
, d
)
182 setattr(cam
.pov
, k
[4:], val
)
183 for txt
in bpy
.data
.texts
:
184 for k
, d
in old_txt_props
.items():
185 val
= getattr(txt
, k
, d
)
187 setattr(txt
.pov
, k
[4:], val
)
188 # Finally, unregister old props !
192 class RenderCopySettings(bpy
.types
.Operator
):
193 """Update old POV properties to new ones."""
195 bl_idname
= "scene.pov_update_properties"
196 bl_label
= "PovRay render: Update to script v0.0.9"
197 bl_option
= {"REGISTER"}
200 def poll(cls
, context
):
203 def execute(self
, context
):
209 Scene
= bpy
.types
.Scene
210 Mat
= bpy
.types
.Material
211 Tex
= bpy
.types
.Texture
212 Obj
= bpy
.types
.Object
213 Cam
= bpy
.types
.Camera
214 Text
= bpy
.types
.Text
215 # -------------------------------------- SCENE --------------------------------------#
218 Scene
.pov_tempfiles_enable
= BoolProperty(
219 name
="Enable Tempfiles",
220 description
="Enable the OS-Tempfiles. Otherwise set the path where to save the files",
223 Scene
.pov_deletefiles_enable
= BoolProperty(
225 description
="Delete files after rendering. Doesn't work with the image",
228 Scene
.pov_scene_name
= StringProperty(
230 description
="Name of POV-Ray scene to create. Empty name will use the name of the blend file",
234 Scene
.pov_scene_path
= StringProperty(
235 name
="Export scene path",
236 # description="Path to directory where the exported scene (POV and INI) is created", # Bug in POV-Ray RC3
237 description
="Path to directory where the files are created",
242 Scene
.pov_renderimage_path
= StringProperty(
243 name
="Rendered image path",
244 description
="Full path to directory where the rendered image is saved",
249 Scene
.pov_list_lf_enable
= BoolProperty(
251 description
="Enable line breaks in lists (vectors and indices). Disabled: lists are exported in one line",
255 # Not a real pov option, just to know if we should write
256 Scene
.pov_radio_enable
= BoolProperty(
257 name
="Enable Radiosity", description
="Enable POV-Rays radiosity calculation", default
=False
259 Scene
.pov_radio_display_advanced
= BoolProperty(
260 name
="Advanced Options", description
="Show advanced options", default
=False
262 Scene
.pov_media_enable
= BoolProperty(
263 name
="Enable Media", description
="Enable POV-Rays atmospheric media", default
=False
265 Scene
.pov_media_samples
= IntProperty(
267 description
="Number of samples taken from camera to first object encountered along ray path for media calculation",
273 Scene
.pov_media_color
= FloatVectorProperty(
275 description
="The atmospheric media color",
281 default
=(0.001, 0.001, 0.001),
282 options
={"ANIMATABLE"},
285 Scene
.pov_baking_enable
= BoolProperty(
286 name
="Enable Baking", description
="Enable POV-Rays texture baking", default
=False
288 Scene
.pov_indentation_character
= EnumProperty(
290 description
="Select the indentation type",
292 ("0", "None", "No indentation"),
293 ("1", "Tabs", "Indentation with tabs"),
294 ("2", "Spaces", "Indentation with spaces"),
298 Scene
.pov_indentation_spaces
= IntProperty(
299 name
="Quantity of spaces",
300 description
="The number of spaces for indentation",
306 Scene
.pov_comments_enable
= BoolProperty(
307 name
="Enable Comments", description
="Add comments to pov file", default
=True
311 Scene
.pov_command_line_switches
= StringProperty(
312 name
="Command Line Switches",
313 description
="Command line switches consist of a + (plus) or - (minus) sign, followed by one or more alphabetic characters and possibly a numeric value",
318 Scene
.pov_antialias_enable
= BoolProperty(
319 name
="Anti-Alias", description
="Enable Anti-Aliasing", default
=True
322 Scene
.pov_antialias_method
= EnumProperty(
324 description
="AA-sampling method. Type 1 is an adaptive, non-recursive, super-sampling method. Type 2 is an adaptive and recursive super-sampling method",
326 ("0", "non-recursive AA", "Type 1 Sampling in POV-Ray"),
327 ("1", "recursive AA", "Type 2 Sampling in POV-Ray"),
332 Scene
.pov_antialias_depth
= IntProperty(
333 name
="Antialias Depth", description
="Depth of pixel for sampling", min=1, max=9, default
=3
336 Scene
.pov_antialias_threshold
= FloatProperty(
337 name
="Antialias Threshold",
338 description
="Tolerance for sub-pixels",
346 Scene
.pov_jitter_enable
= BoolProperty(
348 description
="Enable Jittering. Adds noise into the sampling process (it should be avoided to use jitter in animation)",
352 Scene
.pov_jitter_amount
= FloatProperty(
353 name
="Jitter Amount",
354 description
="Amount of jittering",
362 Scene
.pov_antialias_gamma
= FloatProperty(
363 name
="Antialias Gamma",
364 description
="POV-Ray compares gamma-adjusted values for super sampling. Antialias Gamma sets the Gamma before comparison",
372 Scene
.pov_max_trace_level
= IntProperty(
373 name
="Max Trace Level",
374 description
="Number of reflections/refractions allowed on ray path",
380 Scene
.pov_photon_spacing
= FloatProperty(
382 description
="Average distance between photons on surfaces. half this get four times as many surface photons",
391 Scene
.pov_photon_max_trace_level
= IntProperty(
392 name
="Max Trace Level",
393 description
="Number of reflections/refractions allowed on ray path",
399 Scene
.pov_photon_adc_bailout
= FloatProperty(
401 description
="The adc_bailout for photons. Use adc_bailout = 0.01 / brightest_ambient_object for good results",
410 Scene
.pov_photon_gather_min
= IntProperty(
412 description
="Minimum number of photons gathered for each point",
418 Scene
.pov_photon_gather_max
= IntProperty(
420 description
="Maximum number of photons gathered for each point",
426 Scene
.pov_radio_adc_bailout
= FloatProperty(
428 description
="The adc_bailout for radiosity rays. Use adc_bailout = 0.01 / brightest_ambient_object for good results",
437 Scene
.pov_radio_always_sample
= BoolProperty(
438 name
="Always Sample",
439 description
="Only use the data from the pretrace step and not gather any new samples during the final radiosity pass",
443 Scene
.pov_radio_brightness
= FloatProperty(
445 description
="Amount objects are brightened before being returned upwards to the rest of the system",
453 Scene
.pov_radio_count
= IntProperty(
455 description
="Number of rays for each new radiosity value to be calculated (halton sequence over 1600)",
462 Scene
.pov_radio_error_bound
= FloatProperty(
464 description
="One of the two main speed/quality tuning values, lower values are more accurate",
472 Scene
.pov_radio_gray_threshold
= FloatProperty(
473 name
="Gray Threshold",
474 description
="One of the two main speed/quality tuning values, lower values are more accurate",
482 Scene
.pov_radio_low_error_factor
= FloatProperty(
483 name
="Low Error Factor",
484 description
="Just enough samples is slightly blotchy. Low error changes error tolerance for less critical last refining pass",
492 # max_sample - not available yet
493 Scene
.pov_radio_media
= BoolProperty(
494 name
="Media", description
="Radiosity estimation can be affected by media", default
=False
497 Scene
.pov_radio_minimum_reuse
= FloatProperty(
498 name
="Minimum Reuse",
499 description
="Fraction of the screen width which sets the minimum radius of reuse for each sample point (At values higher than 2% expect errors)",
508 Scene
.pov_radio_nearest_count
= IntProperty(
509 name
="Nearest Count",
510 description
="Number of old ambient values blended together to create a new interpolated value",
516 Scene
.pov_radio_normal
= BoolProperty(
517 name
="Normals", description
="Radiosity estimation can be affected by normals", default
=False
520 Scene
.pov_radio_recursion_limit
= IntProperty(
521 name
="Recursion Limit",
522 description
="how many recursion levels are used to calculate the diffuse inter-reflection",
528 Scene
.pov_radio_pretrace_start
= FloatProperty(
529 name
="Pretrace Start",
530 description
="Fraction of the screen width which sets the size of the blocks in the mosaic preview first pass",
538 Scene
.pov_radio_pretrace_end
= FloatProperty(
540 description
="Fraction of the screen width which sets the size of the blocks in the mosaic preview last pass",
549 # -------------------------------------- MATERIAL -------------------------------------- #
551 Mat
.pov_irid_enable
= BoolProperty(
552 name
="Enable Iridescence",
553 description
="Newton's thin film interference (like an oil slick on a puddle of water or the rainbow hues of a soap bubble.)",
557 Mat
.pov_mirror_use_IOR
= BoolProperty(
558 name
="Correct Reflection",
559 description
="Use same IOR as raytrace transparency to calculate mirror reflections. More physically correct",
563 Mat
.pov_conserve_energy
= BoolProperty(
564 name
="Conserve Energy",
565 description
="Light transmitted is more correctly reduced by mirror reflections, also the sum of diffuse and translucency gets reduced below one ",
569 Mat
.pov_irid_amount
= FloatProperty(
571 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",
579 Mat
.pov_irid_thickness
= FloatProperty(
581 description
="A very thin film will have a high frequency of color changes while a thick film will have large areas of color",
589 Mat
.pov_irid_turbulence
= FloatProperty(
591 description
="This parameter varies the thickness",
599 Mat
.pov_interior_fade_color
= FloatVectorProperty(
601 description
="Color of filtered attenuation for transparent materials",
608 options
={"ANIMATABLE"},
611 Mat
.pov_caustics_enable
= BoolProperty(
613 description
="use only fake refractive caustics (default) or photon based reflective/refractive caustics",
617 Mat
.pov_fake_caustics
= BoolProperty(
618 name
="Fake Caustics", description
="use only (Fast) fake refractive caustics", default
=True
621 Mat
.pov_fake_caustics_power
= FloatProperty(
622 name
="Fake caustics power",
623 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",
631 Mat
.pov_photons_refraction
= BoolProperty(
632 name
="Refractive Photon Caustics", description
="more physically correct", default
=False
635 Mat
.pov_photons_dispersion
= FloatProperty(
636 name
="chromatic dispersion",
637 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",
646 Mat
.pov_photons_reflection
= BoolProperty(
647 name
="Reflective Photon Caustics",
648 description
="Use this to make your Sauron's ring ;-P",
652 Mat
.pov_refraction_type
= EnumProperty(
654 ("0", "None", "use only reflective caustics"),
655 ("1", "Fake Caustics", "use fake caustics"),
656 ("2", "Photons Caustics", "use photons for refractive caustics"),
659 description
="use fake caustics (fast) or true photons for refractive Caustics",
662 # -------------------------------------- CustomPOV Code -------------------------------------- #
663 Mat
.pov_replacement_text
= StringProperty(
664 name
="Declared name:",
665 description
="Type the declared name in custom POV code or an external .inc it points at. texture {} expected",
669 # Only DUMMIES below for now:
670 Tex
.pov_replacement_text
= StringProperty(
671 name
="Declared name:",
672 description
="Type the declared name in custom POV code or an external .inc it points at. pigment {} expected",
676 Obj
.pov_replacement_text
= StringProperty(
677 name
="Declared name:",
678 description
="Type the declared name in custom POV code or an external .inc it points at. Any POV shape expected e.g: isosurface {}",
682 Cam
.pov_replacement_text
= StringProperty(
683 name
="Texts in blend file",
684 description
="Type the declared name in custom POV code or an external .inc it points at. camera {} expected",
687 # -------------------------------------- TEXTURE -------------------------------------- #
689 # Custom texture gamma
690 Tex
.pov_tex_gamma_enable
= BoolProperty(
691 name
="Enable custom texture gamma",
692 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)",
696 Tex
.pov_tex_gamma_value
= FloatProperty(
697 name
="Custom texture gamma",
698 description
="value for which the file was issued e.g. a Raw photo is gamma 1.0",
706 # -------------------------------------- OBJECT -------------------------------------- #
708 # Importance sampling
709 Obj
.pov_importance_value
= FloatProperty(
710 name
="Radiosity Importance",
711 description
="Priority value relative to other objects for sampling radiosity rays. Increase to get more radiosity rays at comparatively small yet bright objects",
718 Obj
.pov_collect_photons
= BoolProperty(
719 name
="Receive Photon Caustics",
720 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) ",
724 # -------------------------------------- CAMERA -------------------------------------- #
727 Cam
.pov_dof_enable
= BoolProperty(
728 name
="Depth Of Field", description
="Enable POV-Ray Depth Of Field ", default
=True
731 # Aperture (Intensity of the Blur)
732 Cam
.pov_dof_aperture
= FloatProperty(
734 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",
740 # Aperture adaptive sampling
741 Cam
.pov_dof_samples_min
= IntProperty(
743 description
="Minimum number of rays to use for each pixel",
749 Cam
.pov_dof_samples_max
= IntProperty(
751 description
="Maximum number of rays to use for each pixel",
757 Cam
.pov_dof_variance
= IntProperty(
759 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",
766 Cam
.pov_dof_confidence
= FloatProperty(
768 description
="Probability to reach the real color value. Larger confidence values will lead to more samples, slower traces and better images",
774 # -------------------------------------- TEXT -------------------------------------- #
776 Text
.pov_custom_code
= BoolProperty(
778 description
="Add this text at the top of the exported POV-Ray file",
784 Scene
= bpy
.types
.Scene
785 Mat
= bpy
.types
.Material
786 Tex
= bpy
.types
.Texture
787 Obj
= bpy
.types
.Object
788 Cam
= bpy
.types
.Camera
789 Text
= bpy
.types
.Text
790 del Scene
.pov_tempfiles_enable
791 del Scene
.pov_scene_name
792 del Scene
.pov_deletefiles_enable
793 del Scene
.pov_scene_path
794 del Scene
.pov_renderimage_path
795 del Scene
.pov_list_lf_enable
796 del Scene
.pov_radio_enable
797 del Scene
.pov_radio_display_advanced
798 del Scene
.pov_radio_adc_bailout
799 del Scene
.pov_radio_always_sample
800 del Scene
.pov_radio_brightness
801 del Scene
.pov_radio_count
802 del Scene
.pov_radio_error_bound
803 del Scene
.pov_radio_gray_threshold
804 del Scene
.pov_radio_low_error_factor
805 del Scene
.pov_radio_media
806 del Scene
.pov_radio_minimum_reuse
807 del Scene
.pov_radio_nearest_count
808 del Scene
.pov_radio_normal
809 del Scene
.pov_radio_recursion_limit
810 del Scene
.pov_radio_pretrace_start
811 del Scene
.pov_radio_pretrace_end
812 del Scene
.pov_media_enable
813 del Scene
.pov_media_samples
814 del Scene
.pov_media_color
815 del Scene
.pov_baking_enable
816 del Scene
.pov_max_trace_level
817 del Scene
.pov_photon_spacing
818 del Scene
.pov_photon_max_trace_level
819 del Scene
.pov_photon_adc_bailout
820 del Scene
.pov_photon_gather_min
821 del Scene
.pov_photon_gather_max
822 del Scene
.pov_antialias_enable
823 del Scene
.pov_antialias_method
824 del Scene
.pov_antialias_depth
825 del Scene
.pov_antialias_threshold
826 del Scene
.pov_antialias_gamma
827 del Scene
.pov_jitter_enable
828 del Scene
.pov_jitter_amount
829 del Scene
.pov_command_line_switches
830 del Scene
.pov_indentation_character
831 del Scene
.pov_indentation_spaces
832 del Scene
.pov_comments_enable
833 del Mat
.pov_irid_enable
834 del Mat
.pov_mirror_use_IOR
835 del Mat
.pov_conserve_energy
836 del Mat
.pov_irid_amount
837 del Mat
.pov_irid_thickness
838 del Mat
.pov_irid_turbulence
839 del Mat
.pov_interior_fade_color
840 del Mat
.pov_caustics_enable
841 del Mat
.pov_fake_caustics
842 del Mat
.pov_fake_caustics_power
843 del Mat
.pov_photons_refraction
844 del Mat
.pov_photons_dispersion
845 del Mat
.pov_photons_reflection
846 del Mat
.pov_refraction_type
847 del Mat
.pov_replacement_text
848 del Tex
.pov_tex_gamma_enable
849 del Tex
.pov_tex_gamma_value
850 del Tex
.pov_replacement_text
851 del Obj
.pov_importance_value
852 del Obj
.pov_collect_photons
853 del Obj
.pov_replacement_text
854 del Cam
.pov_dof_enable
855 del Cam
.pov_dof_aperture
856 del Cam
.pov_dof_samples_min
857 del Cam
.pov_dof_samples_max
858 del Cam
.pov_dof_variance
859 del Cam
.pov_dof_confidence
860 del Cam
.pov_replacement_text
861 del Text
.pov_custom_code