[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [4455] trunk/py/scripts/addons/ render_povray/render.py: added: Colored Specular Highlights ( the only supported uvmaps channels that can work with this feature are alpha and bump , due to POV syntax limitations)

Maurice Raybaud mauriceraybaud at hotmail.fr
Sun Apr 7 18:49:28 CEST 2013


Revision: 4455
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=4455
Author:   mauriceraybaud
Date:     2013-04-07 16:49:27 +0000 (Sun, 07 Apr 2013)
Log Message:
-----------
added: Colored Specular Highlights (the only supported uvmaps channels that can work with this feature are alpha and bump, due to POV syntax limitations)
not fixed: vertex colors support broken since BMesh.

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

Modified: trunk/py/scripts/addons/render_povray/render.py
===================================================================
--- trunk/py/scripts/addons/render_povray/render.py	2013-04-07 15:10:41 UTC (rev 4454)
+++ trunk/py/scripts/addons/render_povray/render.py	2013-04-07 16:49:27 UTC (rev 4455)
@@ -311,7 +311,15 @@
 
         name = materialNames[name_orig] = uniqueName(bpy.path.clean_name(name_orig), materialNames)
         comments = scene.pov.comments_enable
-
+        
+        if material:
+            if (material.specular_color.r == material.specular_color.g) and (material.specular_color.r == material.specular_color.b):
+                colored_specular_found = False
+            else:
+                colored_specular_found = True
+        
+        
+        
         ##################
         # Several versions of the finish: Level conditions are variations for specular/Mirror
         # texture channel map with alternative finish of 0 specular and no mirror reflection.
@@ -446,6 +454,9 @@
                     # really works. --Maurice.
                     tabWrite("conserve_energy\n")
 
+                if colored_specular_found == True:
+                     tabWrite("metallic\n")          
+
                 # 'phong 70.0 '
                 if Level != 1:
                     if material.raytrace_mirror.use:
@@ -507,7 +518,7 @@
                     special_texture_found = True
                     continue  # Some texture found
 
-            if special_texture_found:
+            if special_texture_found or colored_specular_found:
                 # Level=1 Means No specular nor Mirror reflection
                 povHasnoSpecularMaps(Level=1)
 
@@ -1170,475 +1181,512 @@
                             key = diffuse_color[0], diffuse_color[1], diffuse_color[2], i  # i == f.mat
                             vertCols[key] = [-1]
 
-            # Vert Colors
-            tabWrite("texture_list {\n")
-            file.write(tabStr + "%s" % (len(vertCols)))  # vert count
-            idx = 0
+                        idx = 0
+                        LocalMaterialNames = []                        
+                        for col, index in vertCols.items():
+                            #if me_materials:
+                            material = me_materials[col[3]]
+                            if me_materials == None: #XXX working?
+                                material_finish = DEF_MAT_NAME  # not working properly,
+                                trans = 0.0
 
-            for col, index in vertCols.items():
-                if me_materials:
-                    material = me_materials[col[3]]
-                    material_finish = materialNames[material.name]
+                            else:
+                                material_finish = materialNames[material.name]                        
+                                if material.use_transparency:
+                                    trans = 1.0 - material.alpha
+                                else:
+                                    trans = 0.0                            
+                                if (material.specular_color.r == material.specular_color.g) and (material.specular_color.r == material.specular_color.b):
+                                    colored_specular_found = False
+                                else:
+                                    colored_specular_found = True
 
-                    if material.use_transparency:
-                        trans = 1.0 - material.alpha
-                    else:
-                        trans = 0.0
+                                if material.use_transparency and material.transparency_method == 'RAYTRACE':
+                                    povFilter = material.raytrace_transparency.filter * (1.0 - material.alpha)
+                                    trans = (1.0 - material.alpha) - povFilter
+                                else:
+                                    povFilter = 0.0
+                                    
+                                ##############SF
+                                texturesDif = ""
+                                texturesSpec = ""
+                                texturesNorm = ""
+                                texturesAlpha = ""
+                                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)
+                                        imgGamma = ""
+                                        if image_filename:
+                                            if t.use_map_color_diffuse:
+                                                texturesDif = image_filename
+                                                # colvalue = t.default_value  # UNUSED
+                                                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  # UNUSED
+                                                t_spec = t
+                                            if t.use_map_normal:
+                                                texturesNorm = image_filename
+                                                # colvalue = t.normal_factor * 10.0  # UNUSED
+                                                #textNormName=t.texture.image.name + ".normal"
+                                                #was the above used? --MR
+                                                t_nor = t
+                                            if t.use_map_alpha:
+                                                texturesAlpha = image_filename
+                                                # colvalue = t.alpha_factor * 10.0  # UNUSED
+                                                #textDispName=t.texture.image.name + ".displ"
+                                                #was the above used? --MR
+                                                t_alpha = t
 
-                    if material.use_transparency and material.transparency_method == 'RAYTRACE':
-                        povFilter = material.raytrace_transparency.filter * (1.0 - material.alpha)
-                        trans = (1.0 - material.alpha) - povFilter
-                    else:
-                        povFilter = 0.0
-                else:
-                    material_finish = DEF_MAT_NAME  # not working properly,
-                    trans = 0.0
+                                ####################################################################################
 
-                ##############SF
-                texturesDif = ""
-                texturesSpec = ""
-                texturesNorm = ""
-                texturesAlpha = ""
-                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)
-                        imgGamma = ""
-                        if image_filename:
-                            if t.use_map_color_diffuse:
-                                texturesDif = image_filename
-                                # colvalue = t.default_value  # UNUSED
-                                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  # UNUSED
-                                t_spec = t
-                            if t.use_map_normal:
-                                texturesNorm = image_filename
-                                # colvalue = t.normal_factor * 10.0  # UNUSED
-                                #textNormName=t.texture.image.name + ".normal"
-                                #was the above used? --MR
-                                t_nor = t
-                            if t.use_map_alpha:
-                                texturesAlpha = image_filename
-                                # colvalue = t.alpha_factor * 10.0  # UNUSED
-                                #textDispName=t.texture.image.name + ".displ"
-                                #was the above used? --MR
-                                t_alpha = t
 
-                ####################################################################################
+                                file.write("\n")
+                                # THIS AREA NEEDS TO LEAVE THE TEXTURE OPEN UNTIL ALL MAPS ARE WRITTEN DOWN.
+                                # --MR
+                                currentMatName = string_strip_hyphen(materialNames[material.name])
+                                LocalMaterialNames.append(currentMatName)
+                                file.write("\n #declare MAT_%s = \ntexture{\n" % currentMatName)
 
-                if material.pov.replacement_text != "":
-                    file.write("\n")
-                    file.write(" texture{%s}\n" % material.pov.replacement_text)
+                                ################################################################################
+                                if material.diffuse_shader == 'MINNAERT':
+                                    tabWrite("\n")
+                                    tabWrite("aoi\n")
+                                    tabWrite("texture_map {\n")
+                                    tabWrite("[%.3g finish {diffuse %.3g}]\n" % \
+                                             (material.darkness / 2.0, 2.0 - material.darkness))
+                                    tabWrite("[%.3g\n" % (1.0 - (material.darkness / 2.0)))
 
-                else:
-                    file.write("\n")

@@ Diff output truncated at 10240 characters. @@


More information about the Bf-extensions-cvs mailing list