[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [1178] trunk/py/scripts/addons/ render_povray: -Added more control over Straight/Premul Alpha,

Maurice Raybaud mauriceraybaud at hotmail.fr
Sun Nov 21 19:58:37 CET 2010


Revision: 1178
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-extensions&revision=1178
Author:   mauriceraybaud
Date:     2010-11-21 19:58:34 +0100 (Sun, 21 Nov 2010)

Log Message:
-----------
-Added more control over Straight/Premul Alpha,
-Added Distance based Depth of Field (not object based yet)

-Noticed a bug when parts of an object are flat shaded and other parts smooth shaded, not solved this yet.

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

Modified: trunk/py/scripts/addons/render_povray/render.py
===================================================================
--- trunk/py/scripts/addons/render_povray/render.py	2010-11-21 17:25:41 UTC (rev 1177)
+++ trunk/py/scripts/addons/render_povray/render.py	2010-11-21 18:58:34 UTC (rev 1178)
@@ -106,7 +106,8 @@
             if filename in names:
                 pahFile = os.path.join(root, filename)
         return pahFile
-    except: return ''
+    except: #OSError: #was that the proper error type?
+        return '' 
 
 def path_image(image):
     import os
@@ -228,10 +229,11 @@
             frontDiffuse=material.diffuse_intensity
             backDiffuse=material.translucency
             
-        
+            #But the conserve energy keyword does not keep their sum realistic in pov
+            #we can add this feature before the script writes their values to pov scene 
             if material.pov_conserve_energy:
 
-                #Total should not go above one
+                #Total of spec + diff should not go above one
                 if (frontDiffuse + backDiffuse) <= 1.0:
                     pass
                 elif frontDiffuse==backDiffuse:
@@ -505,6 +507,7 @@
     def exportCamera():
         camera = scene.camera
         matrix = camera.matrix_world
+        focal_point = camera.data.dof_distance
 
         # compute resolution
         Qsize = float(render.resolution_x) / float(render.resolution_y)
@@ -520,6 +523,11 @@
 
         file.write('\trotate  <%.6f, %.6f, %.6f>\n' % tuple([degrees(e) for e in matrix.rotation_part().to_euler()]))
         file.write('\ttranslate <%.6f, %.6f, %.6f>\n' % (matrix[3][0], matrix[3][1], matrix[3][2]))
+        if focal_point != 0:
+            file.write('\taperture 0.25\n') # fixed blur amount for now to do, add slider a button? 
+            file.write('\tblur_samples 96 128\n')
+            file.write('\tvariance 1/10000\n')
+            file.write('\tfocal_point <0, 0, %f>\n' % focal_point)
         file.write('}\n')
 
     def exportLamps(lamps):
@@ -1152,6 +1160,7 @@
             bpy.data.meshes.remove(me)
 
     def exportWorld(world):
+        render = scene.render
         camera = scene.camera
         matrix = camera.matrix_world
         if not world:
@@ -1161,8 +1170,14 @@
         if world:
             #For simple flat background:
             if not world.use_sky_blend:
-                file.write('background {rgbt<%.3g, %.3g, %.3g, 1>}\n' % (tuple(world.horizon_color)))#Non fully transparent background could premultiply alpha and avoid anti-aliasing problem. Put transmit to 1 reveals pov problem with nonpremult antialiased.
+                #Non fully transparent background could premultiply alpha and avoid anti-aliasing display issue. 
+                if render.alpha_mode == 'SKY' or render.alpha_mode == 'PREMUL' :
+                    file.write('background {rgbt<%.3g, %.3g, %.3g, 0.75>}\n' % (tuple(world.horizon_color)))
+                else:
+                    file.write('background {rgbt<%.3g, %.3g, %.3g, 1>}\n' % (tuple(world.horizon_color)))
 
+                    
+
             #For Background image textures
             for t in world.texture_slots: #risk to write several sky_spheres but maybe ok.
                 if t and t.texture.type == 'IMAGE': #and t.use: #No enable checkbox for world textures yet (report it?)
@@ -1192,19 +1207,26 @@
                     file.write('\tpigment {\n')
                     file.write('\t\tgradient z\n')#maybe Should follow the advice of POV doc about replacing gradient for skysphere..5.5
                     file.write('\t\tcolor_map {\n')
-                    file.write('\t\t\t[0.0 rgbt<%.3g, %.3g, %.3g, 1>]\n' % (tuple(world.zenith_color)))           
-                    file.write('\t\t\t[1.0 rgbt<%.3g, %.3g, %.3g, 0.99>]\n' % (tuple(world.horizon_color))) #aa premult not solved with transmit 1
+                    if render.alpha_mode == 'STRAIGHT':
+                        file.write('\t\t\t[0.0 rgbt<%.3g, %.3g, %.3g, 1>]\n' % (tuple(world.zenith_color)))
+                        file.write('\t\t\t[0.0 rgbt<%.3g, %.3g, %.3g, 1>]\n' % (tuple(world.zenith_color)))
+                    elif render.alpha_mode == 'PREMUL':
+                        file.write('\t\t\t[0.0 rgbt<%.3g, %.3g, %.3g, 0.99>]\n' % (tuple(world.zenith_color)))
+                        file.write('\t\t\t[0.0 rgbt<%.3g, %.3g, %.3g, 0.99>]\n' % (tuple(world.zenith_color))) #aa premult not solved with transmit 1
+                    else:
+                        file.write('\t\t\t[0.0 rgbt<%.3g, %.3g, %.3g, 1>]\n' % (tuple(world.zenith_color)))
+                        file.write('\t\t\t[0.0 rgbt<%.3g, %.3g, %.3g, 0.99>]\n' % (tuple(world.zenith_color)))
                     file.write('\t\t}\n')
                     file.write('\t}\n')
                     file.write('}\n')
-                    #problem with sky_sphere alpha (transmit) not translating into image alpha as well as "background" replace 0.75 by 1 when solved and later by some variable linked to background alpha state
+                    #sky_sphere alpha (transmit) is not translating into image alpha the same way as "background"
 
             if world.light_settings.use_indirect_light:
-                scene.pov_radio_enable=1
+                scene.pov_radio_enable=1 
                 
+            #Maybe change the above to scene.pov_radio_enable = world.light_settings.use_indirect_light ?
 
 
-
         ###############################################################
 
         mist = world.mist_settings
@@ -1355,7 +1377,7 @@
 
         try:
             os.remove(self._temp_file_out) # so as not to load the old file
-        except:
+        except: #OSError: #was that the proper error type?
             pass
 
         write_pov_ini(self._temp_file_ini, self._temp_file_in, self._temp_file_out)
@@ -1396,7 +1418,7 @@
         for f in (self._temp_file_in, self._temp_file_ini, self._temp_file_out):
             try:
                 os.remove(f)
-            except:
+            except OSError:  #was that the proper error type?
                 pass
 
         self.update_stats("", "")
@@ -1430,7 +1452,7 @@
             if self.test_break():
                 try:
                     self._process.terminate()
-                except:
+                except: #OSError: #was that the proper error type?
                     pass
                 break
 
@@ -1452,7 +1474,7 @@
                 # possible the image wont load early on.
                 try:
                     lay.load_from_file(self._temp_file_out)
-                except:
+                except: #OSError: #was that the proper error type?
                     pass
                 self.end_result(result)
 
@@ -1468,7 +1490,7 @@
                 if self.test_break():
                     try:
                         self._process.terminate()
-                    except:
+                    except: #OSError: #was that the proper error type?
                         pass
 
                     break

Modified: trunk/py/scripts/addons/render_povray/ui.py
===================================================================
--- trunk/py/scripts/addons/render_povray/ui.py	2010-11-21 17:25:41 UTC (rev 1177)
+++ trunk/py/scripts/addons/render_povray/ui.py	2010-11-21 18:58:34 UTC (rev 1178)
@@ -23,6 +23,7 @@
 properties_render.RENDER_PT_render.COMPAT_ENGINES.add('POVRAY_RENDER')
 properties_render.RENDER_PT_dimensions.COMPAT_ENGINES.add('POVRAY_RENDER')
 properties_render.RENDER_PT_antialiasing.COMPAT_ENGINES.add('POVRAY_RENDER')
+properties_render.RENDER_PT_shading.COMPAT_ENGINES.add('POVRAY_RENDER')
 properties_render.RENDER_PT_output.COMPAT_ENGINES.add('POVRAY_RENDER')
 del properties_render
 




More information about the Bf-extensions-cvs mailing list