[Bf-extensions-cvs] [be03a24] master: fixed : BI texture Scale support for procedurals

Maurice Raybaud noreply at git.blender.org
Thu Jul 21 21:59:40 CEST 2016


Commit: be03a24dc537262012c1c3fca6d2dc0a01752b50
Author: Maurice Raybaud
Date:   Thu Jul 21 21:59:30 2016 +0200
Branches: master
https://developer.blender.org/rBAbe03a24dc537262012c1c3fca6d2dc0a01752b50

fixed : BI texture Scale support for procedurals

===================================================================

M	render_povray/render.py
M	render_povray/shading.py

===================================================================

diff --git a/render_povray/render.py b/render_povray/render.py
index d0fde8d..4d6d7e6 100644
--- a/render_povray/render.py
+++ b/render_povray/render.py
@@ -93,6 +93,9 @@ def imgMapTransforms(ts):
     # inverse, a standard scale factor.
     # 0.5 Offset is needed relatively to scale because center of the
     # scale is 0.5,0.5 in blender and 0,0 in POV
+            # Strange that the translation factor for scale is not the same as for
+            # translate.
+            # TODO: verify both matches with blender internal.
     image_map_transforms = ""
     image_map_transforms = ("scale <%.4g,%.4g,%.4g> translate <%.4g,%.4g,%.4g>" % \
                   ( 1.0 / ts.scale.x,
@@ -3159,7 +3162,7 @@ def write_pov(filename, scene=None, info_callback=None):
         file.write("\n//--Patterns Definitions--\n\n")
     LocalPatternNames = []
     for texture in bpy.data.textures: #ok?
-        if texture.users > 0:
+        if texture.users > 0:         
             currentPatName = string_strip_hyphen(bpy.path.clean_name(texture.name)) 
             #string_strip_hyphen(patternNames[texture.name]) #maybe instead of the above
             LocalPatternNames.append(currentPatName) 
diff --git a/render_povray/shading.py b/render_povray/shading.py
index 8a7cff7..88c085c 100644
--- a/render_povray/shading.py
+++ b/render_povray/shading.py
@@ -231,7 +231,6 @@ def writeMaterial(using_uberpov, DEF_MAT_NAME, scene, tabWrite, safety, comments
             # Level=3 Means Maximum Spec and Mirror
             povHasnoSpecularMaps(Level=3)
 
-
 def exportPattern(texture, string_strip_hyphen):
     tex=texture
     pat = tex.pov
@@ -291,8 +290,7 @@ def exportPattern(texture, string_strip_hyphen):
 
             if tex.color_mode == 'POSITION':
                 texStrg+="solid\n"
-            texStrg+="scale 0.25\n"
-            
+            texStrg+="scale 0.25\n"     
             if tex.use_color_ramp == True:
                 texStrg+=exportColorRamp(tex)
             else:
@@ -300,13 +298,14 @@ def exportPattern(texture, string_strip_hyphen):
                 texStrg+="[0 color rgbt<0,0,0,1>]\n"
                 texStrg+="[1 color rgbt<1,1,1,0>]\n" 
                 texStrg+="}\n"            
+
         ####################### EMULATE BLENDER CLOUDS TEXTURE ####################
         if tex.type == 'CLOUDS':  
             if tex.noise_type == 'SOFT_NOISE':
                 texStrg+="wrinkles\n"
                 texStrg+="scale 0.25\n"
             else:
-                texStrg+="granite\n"
+                texStrg+="granite\n"               
             if tex.use_color_ramp == True:
                 texStrg+=exportColorRamp(tex)
             else:
@@ -314,6 +313,7 @@ def exportPattern(texture, string_strip_hyphen):
                 texStrg+="[0 color rgbt<0,0,0,1>]\n"
                 texStrg+="[1 color rgbt<1,1,1,0>]\n" 
                 texStrg+="}\n"
+
         ####################### EMULATE BLENDER WOOD TEXTURE ####################
         if tex.type == 'WOOD':
             if tex.wood_type == 'RINGS':
@@ -346,6 +346,7 @@ def exportPattern(texture, string_strip_hyphen):
                 texStrg+="[0 color rgbt<0,0,0,0>]\n"
                 texStrg+="[1 color rgbt<1,1,1,0>]\n" 
                 texStrg+="}\n"
+ 
         ####################### EMULATE BLENDER STUCCI TEXTURE ####################
         if tex.type == 'STUCCI':  
             texStrg+="bozo\n"
@@ -367,6 +368,7 @@ def exportPattern(texture, string_strip_hyphen):
                     texStrg+="[0 color rgbf<0,0,0,1>]\n"
                     texStrg+="[1 color rgbt<1,1,1,0>]\n"
                     texStrg+="}\n"
+ 
         ####################### EMULATE BLENDER MAGIC TEXTURE ####################
         if tex.type == 'MAGIC':  
             texStrg+="leopard\n"
@@ -381,6 +383,7 @@ def exportPattern(texture, string_strip_hyphen):
                 texStrg+="[1 color rgbf<0,1,0,0.75>]\n"
                 texStrg+="}\n"
             texStrg+="scale 0.1\n"            
+ 
         ####################### EMULATE BLENDER MARBLE TEXTURE ####################
         if tex.type == 'MARBLE':  
             texStrg+="marble\n"
@@ -413,6 +416,7 @@ def exportPattern(texture, string_strip_hyphen):
                 texStrg+="triangle_wave\n"
             if tex.noise_basis_2 == 'SAW':
                 texStrg+="ramp_wave\n"
+ 
         ####################### EMULATE BLENDER BLEND TEXTURE ####################
         if tex.type == 'BLEND':
             if tex.progression=='RADIAL':
@@ -454,7 +458,9 @@ def exportPattern(texture, string_strip_hyphen):
             if tex.progression == 'QUADRATIC': 
                 texStrg+="    poly_wave 2\n"
             if tex.progression == 'EASING':
-                texStrg+="    poly_wave 1.5\n"            
+                texStrg+="    poly_wave 1.5\n"
+                
+
         ####################### EMULATE BLENDER MUSGRAVE TEXTURE ####################
         # if tex.type == 'MUSGRAVE':  
             # texStrg+="function{ f_ridged_mf( x, y, 0, 1, 2, 9, -0.5, 3,3 )*0.5}\n"
@@ -469,7 +475,8 @@ def exportPattern(texture, string_strip_hyphen):
             if tex.use_color_ramp == True:
                 texStrg+=exportColorRamp(tex)
             else: 
-                texStrg+="color_map {[0.5 color rgbf<0,0,0,1>][1 color rgbt<1,1,1,0>]}ramp_wave \n"            
+                texStrg+="color_map {[0.5 color rgbf<0,0,0,1>][1 color rgbt<1,1,1,0>]}ramp_wave \n"
+               
         ####################### EMULATE BLENDER DISTORTED NOISE TEXTURE ####################
         if tex.type == 'DISTORTED_NOISE':  
             texStrg+="average\n"
@@ -525,6 +532,7 @@ def exportPattern(texture, string_strip_hyphen):
                     texStrg+="}\n"
                 texStrg+="]\n"
             texStrg+="  }\n"
+
         ####################### EMULATE BLENDER NOISE TEXTURE ####################
         if tex.type == 'NOISE':  
             texStrg+="cells\n"
@@ -731,6 +739,7 @@ def writeTextureInfluence(mater, materialNames, LocalMaterialNames, path_image,
     texturesAlpha = ""
     #proceduralFlag=False
     for t in mater.texture_slots:
+        # PROCEDURAL
         if t and t.use and t.texture.type != 'IMAGE' and t.texture.type != 'NONE':
             proceduralFlag=True
             image_filename = "PAT_%s"%string_strip_hyphen(bpy.path.clean_name(t.texture.name))
@@ -758,8 +767,10 @@ def writeTextureInfluence(mater, materialNames, LocalMaterialNames, path_image,
                     #was the above used? --MR
                     t_alpha = t
 
+        # RASTER IMAGE            
         if t and t.texture.type == 'IMAGE' and t.use and t.texture.image and t.texture.pov.tex_pattern_type == 'emulator':
             proceduralFlag=False
+            #PACKED
             if t.texture.image.packed_file:
                 orig_image_filename=t.texture.image.filepath_raw
                 unpackedfilename= os.path.join(preview_dir,("unpacked_img_"+(string_strip_hyphen(bpy.path.clean_name(t.texture.name)))))
@@ -773,6 +784,7 @@ def writeTextureInfluence(mater, materialNames, LocalMaterialNames, path_image,
                 # .replace("\\","/") to get only forward slashes as it's what POV prefers, 
                 # even on windows
                 t.texture.image.filepath_raw=orig_image_filename
+            #FILE
             else:
                 image_filename = path_image(t.texture.image)
             # IMAGE SEQUENCE BEGINS
@@ -807,7 +819,7 @@ def writeTextureInfluence(mater, materialNames, LocalMaterialNames, path_image,
                     #textDispName=t.texture.image.name + ".displ"
                     #was the above used? --MR
                     t_alpha = t
-
+        
     ####################################################################################
 
 
@@ -817,7 +829,6 @@ def writeTextureInfluence(mater, materialNames, LocalMaterialNames, path_image,
     currentMatName = string_strip_hyphen(materialNames[mater.name])
     LocalMaterialNames.append(currentMatName)
     tabWrite("\n#declare MAT_%s = \ntexture{\n" % currentMatName)
-
     ################################################################################
     
     if mater.pov.replacement_text != "":
@@ -857,18 +868,13 @@ def writeTextureInfluence(mater, materialNames, LocalMaterialNames, path_image,
         if texturesSpec != "":
             # tabWrite("\n")
             tabWrite("pigment_pattern {\n")
+            
+            mappingSpec =imgMapTransforms(t_spec)
             if texturesSpec and texturesSpec.startswith("PAT_"):
-                tabWrite("function{f%s(x,y,z).grey}" %texturesSpec) 
+                tabWrite("function{f%s(x,y,z).grey}\n" %texturesSpec) 
+                tabWrite("%s\n" % mappingSpec)                
             else:
-                # POV-Ray "scale" is not a number of repetitions factor, but its
-                # inverse, a standard scale factor.
-                # Offset seems needed relatively to scale so probably center of the
-                # scale is not the same in blender and POV
-                mappingSpec =imgMapTransforms(t_spec)
-                # mappingSpec = "translate <%.4g,%.4g,%.4g> scale <%.4g,%.4g,%.4g>\n" % \
-                              # (-t_spec.offset.x, t_spec.offset.y, t_spec.offset.z,
-                               # 1.0 / t_spec.scale.x, 1.0 / t_spec.scale.y,
-                               # 1.0 / t_spec.scale.z)
+
                 tabWrite("uv_mapping image_map{%s \"%s\" %s}\n" % \
                          (imageFormat(texturesSpec), texturesSpec, imgMap(t_spec)))
                 tabWrite("%s\n" % mappingSpec)
@@ -879,19 +885,13 @@ def writeTextureInfluence(mater, materialNames, LocalMaterialNames, path_image,
         if texturesDif == "":
             if texturesAlpha != "":
                 tabWrite("\n")
+
+                mappingAlpha = imgMapTransforms(t_alpha)
+
                 if texturesAlpha and texturesAlpha.startswith("PAT_"):
-                    tabWrite("function{f%s(x,y,z).transmit}\n" %texturesAlpha) 
+                    tabWrite("function{f%s(x,y,z).transmit}%s\n" %(texturesAlpha, mappingAlpha)) 
                 else:
-                    # POV-Ray "scal

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list