[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [1379] trunk/py/scripts/addons/ render_povray: Added Atmospheric Media and custom image gamma

Maurice Raybaud mauriceraybaud at hotmail.fr
Sun Jan 9 20:58:15 CET 2011


Revision: 1379
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-extensions&revision=1379
Author:   mauriceraybaud
Date:     2011-01-09 19:58:13 +0000 (Sun, 09 Jan 2011)
Log Message:
-----------
Added Atmospheric Media and custom image gamma
fixed two typo errors and a compatibility for gamma syntax

Modified Paths:
--------------
    trunk/py/scripts/addons/render_povray/__init__.py
    trunk/py/scripts/addons/render_povray/render.py
    trunk/py/scripts/addons/render_povray/ui.py

Modified: trunk/py/scripts/addons/render_povray/__init__.py
===================================================================
--- trunk/py/scripts/addons/render_povray/__init__.py	2011-01-09 15:02:21 UTC (rev 1378)
+++ trunk/py/scripts/addons/render_povray/__init__.py	2011-01-09 19:58:13 UTC (rev 1379)
@@ -28,7 +28,7 @@
     "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.5/Py/"\
         "Scripts/Render/PovRay",
     "tracker_url": "https://projects.blender.org/tracker/index.php?"\
-        "func=detail&aid=22717",
+        "func=detail&atid=468&aid=22717&group_id=153",
     "category": "Render"}
 
 
@@ -55,6 +55,16 @@
             name="Advanced Options",
             description="Show advanced options",
             default=False)
+    Scene.pov_media_enable = BoolProperty(
+        name="Enable Media",
+        description="Enable povrays atmospheric media",
+        default=False)
+    Scene.pov_media_samples = IntProperty(
+            name="Samples", description="Number of samples taken from camera to first object encountered along ray path for media calculation",
+            min=1, max=100, default=35)
+    Scene.pov_media_color = FloatProperty(
+            name="Media Color", description="The atmospheric media color. Grey value for now",
+            min=0.00, max=1.00, soft_min=0.01, soft_max=1.00, default=0.01)
     Scene.pov_baking_enable = BoolProperty(
             name="Enable Baking",
             description="Enable povrays texture baking",
@@ -185,13 +195,27 @@
                    ],
             name="Refractive",
             description="use fake caustics (fast) or true photons for refractive Caustics",
-            default="1")#ui.py has to be loaded before render.py with this. 
+            default="1")#ui.py has to be loaded before render.py with this.
+    
+    ########################################################################################
+    #Custom texture gamma
+    Tex = bpy.types.Texture 
+    Tex.pov_tex_gamma_enable = BoolProperty(
+            name="Enable custom texture gamma",
+            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)",
+            default=False)
+    Tex.pov_tex_gamma_value = FloatProperty(
+            name="Custom texture gamma",
+            description="value for which the file was issued e.g. a Raw photo is gamma 1.0",
+            min=0.45, max=5.00, soft_min=1.00, soft_max=2.50, default=1.00)
+    
     ######################################EndMR#####################################
 
 def unregister():
     import bpy
     Scene = bpy.types.Scene
     Mat = bpy.types.Material # MR
+    Tex = bpy.types.Texture # MR
     del Scene.pov_radio_enable
     del Scene.pov_radio_display_advanced
     del Scene.pov_radio_adc_bailout
@@ -206,6 +230,9 @@
     del Scene.pov_radio_nearest_count
     del Scene.pov_radio_normal
     del Scene.pov_radio_recursion_limit
+    del Scene.pov_media_enable # MR
+    del Scene.pov_media_samples # MR
+    del Scene.pov_media_color # MR
     del Scene.pov_baking_enable # MR
     del Mat.pov_irid_enable # MR
     del Mat.pov_mirror_use_IOR # MR
@@ -221,6 +248,8 @@
     del Mat.pov_photons_dispersion # MR  
     del Mat.pov_photons_reflection # MR 
     del Mat.pov_refraction_type # MR
+    del Tex.pov_tex_gamma_enable # MR
+    del Tex.pov_tex_gamma_value # MR
 
 if __name__ == "__main__":
     register()

Modified: trunk/py/scripts/addons/render_povray/render.py
===================================================================
--- trunk/py/scripts/addons/render_povray/render.py	2011-01-09 15:02:21 UTC (rev 1378)
+++ trunk/py/scripts/addons/render_povray/render.py	2011-01-09 19:58:13 UTC (rev 1379)
@@ -778,11 +778,14 @@
                 for t in material.texture_slots:
                     if t and t.texture.type == 'IMAGE' and t.use and t.texture.image: 
                         image_filename = path_image(t.texture.image.filepath)
+                        imgGamma = ''
                         if image_filename:
                             if t.use_map_color_diffuse: 
                                 texturesDif = image_filename
                                 colvalue = t.default_value
                                 t_dif = t
+                                if t_dif.texture.pov_tex_gamma_enable:
+                                    imgGamma = (" gamma %.3g " % t_dif.texture.pov_tex_gamma_value)
                             if t.use_map_specular or t.use_map_raymir: 
                                 texturesSpec = image_filename
                                 colvalue = t.default_value
@@ -873,16 +876,15 @@
 
                 else:
                     mappingDif = (" translate <%.4g-0.75,%.4g-0.75,%.4g-0.75> scale <%.4g,%.4g,%.4g>" % (t_dif.offset.x / 10 ,t_dif.offset.y / 10 ,t_dif.offset.z / 10, t_dif.scale.x / 2.25, t_dif.scale.y / 2.25, t_dif.scale.z / 2.25)) #strange that the translation factor for scale is not the same as for translate. ToDo: verify both matches with blender internal. 
-
                     if texturesAlpha !='':
                         mappingAlpha = (" translate <%.4g-0.75,%.4g-0.75,%.4g-0.75> scale <%.4g,%.4g,%.4g>" % (t_alpha.offset.x / 10 ,t_alpha.offset.y / 10 ,t_alpha.offset.z / 10, t_alpha.scale.x / 2.25, t_alpha.scale.y / 2.25, t_alpha.scale.z / 2.25)) #strange that the translation factor for scale is not the same as for translate. ToDo: verify both matches with blender internal. 
                         file.write('\n\t\t\t\tpigment {pigment_pattern {uv_mapping image_map{%s \"%s\" %s}%s}' % (imageFormat(texturesAlpha),texturesAlpha,imgMap(t_alpha),mappingAlpha))
                         file.write('\n\t\t\t\t\tpigment_map {\n\t\t\t\t\t\t[0 color rgbft<0,0,0,1,1>]')
-                        file.write('\n\t\t\t\t\t\t[1 uv_mapping image_map {%s \"%s\" %s}%s]\n\t\t\t\t}' % (imageFormat(texturesDif),texturesDif,imgMap(t_dif),mappingDif))
+                        file.write('\n\t\t\t\t\t\t[1 uv_mapping image_map {%s \"%s\" %s}%s]\n\t\t\t\t}' % (imageFormat(texturesDif),texturesDif,(imgGamma + imgMap(t_dif)),mappingDif))
                         file.write('\n\t\t\t\t}')
 
                     else:
-                        file.write("\n\t\t\t\tpigment {uv_mapping image_map {%s \"%s\" %s}%s}" % (imageFormat(texturesDif),texturesDif,imgMap(t_dif),mappingDif))
+                        file.write("\n\t\t\t\tpigment {uv_mapping image_map {%s \"%s\" %s}%s}" % (imageFormat(texturesDif),texturesDif,(imgGamma + imgMap(t_dif)),mappingDif))
 
                     if texturesSpec !='':
                         file.write('finish {%s}' % (safety(material_finish, Level=1)))# Level 1 is no specular
@@ -924,17 +926,16 @@
                         file.write('finish {%s}' % (safety(material_finish, Level=2)))# Level 2 is translated specular
 
                 else:
-                    mappingDif = (" translate <%.4g-0.75,%.4g-0.75,%.4g-0.75> scale <%.4g,%.4g,%.4g>" % (t_dif.offset.x / 10 ,t_dif.offset.y / 10 ,t_dif.offset.z / 10, t_dif.scale.x / 2.25, t_dif.scale.y / 2.25, t_dif.scale.z / 2.25)) #strange that the translation factor for scale is not the same as for translate. ToDo: verify both matches with blender internal. 
-
+                    mappingDif = (" translate <%.4g-0.75,%.4g-0.75,%.4g-0.75> scale <%.4g,%.4g,%.4g>" % (t_dif.offset.x / 10 ,t_dif.offset.y / 10 ,t_dif.offset.z / 10, t_dif.scale.x / 2.25, t_dif.scale.y / 2.25, t_dif.scale.z / 2.25)) #strange that the translation factor for scale is not the same as for translate. ToDo: verify both matches with blender internal.
                     if texturesAlpha !='':
                         mappingAlpha = (" translate <%.4g-0.75,%.4g-0.75,%.4g-0.75> scale <%.4g,%.4g,%.4g>" % (t_alpha.offset.x / 10 ,t_alpha.offset.y / 10 ,t_alpha.offset.z / 10, t_alpha.scale.x / 2.25, t_alpha.scale.y / 2.25, t_alpha.scale.z / 2.25)) #strange that the translation factor for scale is not the same as for translate. ToDo: verify both matches with blender internal. 
                         file.write('\n\t\t\t\tpigment {pigment_pattern {uv_mapping image_map{%s \"%s\" %s}%s}' % (imageFormat(texturesAlpha),texturesAlpha,imgMap(t_alpha),mappingAlpha))
                         file.write('\n\t\t\t\tpigment_map {\n\t\t\t\t\t[0 color rgbft<0,0,0,1,1>]')
-                        file.write('\n\t\t\t\t\t\t[1 uv_mapping image_map {%s \"%s\" %s}%s]\n\t\t\t\t\t}' % (imageFormat(texturesDif),texturesDif,imgMap(t_dif),mappingDif))
+                        file.write('\n\t\t\t\t\t\t[1 uv_mapping image_map {%s \"%s\" %s}%s]\n\t\t\t\t\t}' % (imageFormat(texturesDif),texturesDif,(imgMap(t_dif)+imgGamma),mappingDif))
                         file.write('\n\t\t\t\t}')
 
                     else:
-                        file.write("\n\t\t\tpigment {uv_mapping image_map {%s \"%s\" %s}%s}" % (imageFormat(texturesDif),texturesDif,imgMap(t_dif),mappingDif))
+                        file.write("\n\t\t\tpigment {uv_mapping image_map {%s \"%s\" %s}%s}" % (imageFormat(texturesDif),texturesDif,(imgGamma + imgMap(t_dif)),mappingDif))
                     if texturesSpec !='':
                         file.write('finish {%s}' % (safety(material_finish, Level=3)))# Level 3 is full specular
                     else:
@@ -1159,10 +1160,16 @@
             #file.write('\tturb_depth 0.3\n')
             file.write('\tfog_type 1\n')
             file.write('}\n')
+        if scene.pov_media_enable:
+            file.write('media {\n')
+            file.write('\tscattering { 1, rgb %.3g}\n' % scene.pov_media_color)
+            file.write('\tsamples %.d\n' % scene.pov_media_samples)
+            file.write('}\n')
 
     def exportGlobalSettings(scene):
 
         file.write('global_settings {\n')
+        file.write('\tassumed_gamma 1.0\n')
         file.write('\tmax_trace_level 7\n')
 
         if scene.pov_radio_enable:

Modified: trunk/py/scripts/addons/render_povray/ui.py
===================================================================
--- trunk/py/scripts/addons/render_povray/ui.py	2011-01-09 15:02:21 UTC (rev 1378)
+++ trunk/py/scripts/addons/render_povray/ui.py	2011-01-09 19:58:13 UTC (rev 1379)
@@ -106,6 +106,17 @@
         rd = context.scene.render

@@ Diff output truncated at 10240 characters. @@


More information about the Bf-extensions-cvs mailing list