diff --git a/render_povray/__init__.py b/render_povray/__init__.py index 65d8a04b13f3db0c84ca8cc3a6a6a3686a9cf62e..cfb7263203350c0a7b1cf2b2d528c6f6f8b9278d 100644 --- a/render_povray/__init__.py +++ b/render_povray/__init__.py @@ -174,7 +174,7 @@ def register(): min=1, max=256, default=5) Scene.pov_photon_adc_bailout = FloatProperty( - name="ADC Bailout", description="The adc_bailout for radiosity rays. Use adc_bailout = 0.01 / brightest_ambient_object for good results", + name="ADC Bailout", description="The adc_bailout for photons. Use adc_bailout = 0.01 / brightest_ambient_object for good results", min=0.0, max=1000.0, soft_min=0.0, soft_max=1.0, default=0.1, precision=3) Scene.pov_photon_gather_min = IntProperty( @@ -363,6 +363,44 @@ def register(): default=True) ########################################################################### + + Cam = bpy.types.Camera + + #DOF Toggle + Cam.pov_dof_enable = BoolProperty( + name="Depth Of Field", + description="Enable POV-Ray Depth Of Field ", + default=True) + + #Aperture (Intensity of the Blur) + Cam.pov_dof_aperture = FloatProperty( + name="Aperture", + description="Similar to a real camera's aperture effect over focal blur (though not in physical units and independant of focal length).Increase to get more blur", + min=0.01, max=1.00, default=0.25) + + #Aperture adaptive sampling + Cam.pov_dof_samples_min = IntProperty( + name="Samples Min", + description="Minimum number of rays to use for each pixel", + min=1, max=128, default=96) + + Cam.pov_dof_samples_max = IntProperty( + name="Samples Max", + description="Maximum number of rays to use for each pixel", + min=1, max=128, default=128) + + Cam.pov_dof_variance = IntProperty( + name="Variance", + 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", + min=1, max=100000, soft_max=10000, default=256) + + Cam.pov_dof_confidence = FloatProperty( + name="Confidence", + description="Probability to reach the real color value. Larger confidence values will lead to more samples, slower traces and better images.", + min=0.01, max=0.99, default=0.90) + + ########################################################################### + def unregister(): @@ -371,6 +409,7 @@ def unregister(): Mat = bpy.types.Material Tex = bpy.types.Texture Obj = bpy.types.Object + Cam = bpy.types.Camera del Scene.pov_tempfiles_enable # CR del Scene.pov_scene_name # CR del Scene.pov_deletefiles_enable # CR @@ -433,6 +472,12 @@ def unregister(): del Tex.pov_tex_gamma_value # MR del Obj.pov_importance_value # MR del Obj.pov_collect_photons # MR - + del Cam.pov_dof_enable # MR + del Cam.pov_dof_aperture # MR + del Cam.pov_dof_samples_min # MR + del Cam.pov_dof_samples_max # MR + del Cam.pov_dof_variance # MR + del Cam.pov_dof_confidence # MR + if __name__ == "__main__": register() diff --git a/render_povray/render.py b/render_povray/render.py index 1b868f7da83361e34234bfb6b9a24439a272a8fa..5844a0ee8a31052b5126e75f82232f5e9f609f18 100644 --- a/render_povray/render.py +++ b/render_povray/render.py @@ -535,10 +535,11 @@ def write_pov(filename, scene=None, info_callback=None): tabWrite("rotate <%.6f, %.6f, %.6f>\n" % tuple([degrees(e) for e in matrix.rotation_part().to_euler()])) tabWrite("translate <%.6f, %.6f, %.6f>\n" % (matrix[3][0], matrix[3][1], matrix[3][2])) - if focal_point != 0: - tabWrite("aperture 0.25\n") # fixed blur amount for now to do, add slider a button? - tabWrite("blur_samples 96 128\n") - tabWrite("variance 1/10000\n") + if camera.data.pov_dof_enable and focal_point != 0: + 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) tabWrite("}\n") diff --git a/render_povray/ui.py b/render_povray/ui.py index b302f5b572f1d14d51244dad510cba69047cfd4a..ba2e2411d11a9c5c14b0cfa0af63cba4b9f3b1c2 100644 --- a/render_povray/ui.py +++ b/render_povray/ui.py @@ -134,6 +134,19 @@ class ObjectButtonsPanel(): rd = context.scene.render return obj and (rd.use_game_engine == False) and (rd.engine in cls.COMPAT_ENGINES) +class CameraDataButtonsPanel(): + bl_space_type = 'PROPERTIES' + bl_region_type = 'WINDOW' + bl_context = "data" + # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here + + @classmethod + def poll(cls, context): + cam = context.camera + rd = context.scene.render + return cam and (rd.use_game_engine == False) and (rd.engine in cls.COMPAT_ENGINES) + + class RENDER_PT_povray_export_settings(RenderButtonsPanel, bpy.types.Panel): bl_label = "Export Settings" @@ -196,19 +209,25 @@ class RENDER_PT_povray_render_settings(RenderButtonsPanel, bpy.types.Panel): rd = scene.render layout.active = scene.pov_max_trace_level + split = layout.split() - col = split.column() + col.label(text="Global Settings") col.prop(scene, "pov_max_trace_level", text="Ray Depth") - row = col.row() + col.label(text="Global Photons") col.prop(scene, "pov_photon_max_trace_level", text="Photon Depth") - row = col.row() + + split = layout.split() + 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_min", text="Photons gathered min") - col.prop(scene, "pov_photon_gather_max", text="Photons gathered max") + col.prop(scene, "pov_photon_gather_max") class RENDER_PT_povray_antialias(RenderButtonsPanel, bpy.types.Panel): @@ -324,7 +343,8 @@ class RENDER_PT_povray_media(RenderButtonsPanel, bpy.types.Panel): col = split.column() col.prop(scene, "pov_media_samples", text="Samples") - col.prop(scene, "pov_media_color", text="Color") + col = split.column() + col.prop(scene, "pov_media_color", text="") ##class RENDER_PT_povray_baking(RenderButtonsPanel, bpy.types.Panel): ## bl_label = "Baking" @@ -519,3 +539,36 @@ class OBJECT_PT_povray_obj_importance(ObjectButtonsPanel, bpy.types.Panel): row = col.row() col.label(text="Photons") col.prop(obj, "pov_collect_photons", text="Receive Photon Caustics") + +class Camera_PT_povray_cam_dof(CameraDataButtonsPanel, bpy.types.Panel): + bl_label = "POV-Ray Depth Of Field" + COMPAT_ENGINES = {'POVRAY_RENDER'} + + def draw_header(self, context): + cam = context.camera + + self.layout.prop(cam, "pov_dof_enable", text="") + + def draw(self, context): + layout = self.layout + + cam = context.camera + + layout.active = cam.pov_dof_enable + + split = layout.split() + row = split.row() + row.prop(cam, "pov_dof_aperture") + + split = layout.split() + col = split.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_confidence") + +