From 6fc3f7d09bd3a12933021d95342427ac63e99f9a Mon Sep 17 00:00:00 2001
From: Constantin Rahn <conz@vrchannel.de>
Date: Wed, 19 Jan 2011 14:33:45 +0000
Subject: [PATCH] Declare only required materials

---
 render_povray/render.py | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/render_povray/render.py b/render_povray/render.py
index f3628a040..48b0bd718 100644
--- a/render_povray/render.py
+++ b/render_povray/render.py
@@ -426,14 +426,23 @@ def write_pov(filename, scene=None, info_callback=None):
 
             tabWrite('}\n\n')
 
-        # Level=1 Means No specular nor Mirror reflection
-        povHasnoSpecularMaps(Level=1)
-
         # Level=2 Means translation of spec and mir levels for when no map influences them
         povHasnoSpecularMaps(Level=2)
-        
-        # Level=3 Means Maximum Spec and Mirror
-        povHasnoSpecularMaps(Level=3)
+
+        if material: 
+            special_texture_found = False
+            for t in material.texture_slots:
+                if t and t.texture.type == 'IMAGE' and t.use and t.texture.image and (t.use_map_specular or t.use_map_raymir or t.use_map_normal or t.use_map_alpha): 
+                    special_texture_found = True
+                    continue # Some texture found
+            
+            if special_texture_found:
+                # Level=1 Means No specular nor Mirror reflection
+                povHasnoSpecularMaps(Level=1)
+
+                # Level=3 Means Maximum Spec and Mirror
+                povHasnoSpecularMaps(Level=3)
+                    
 
     def exportCamera():
         camera = scene.camera
@@ -1350,11 +1359,9 @@ def write_pov(filename, scene=None, info_callback=None):
             writeMaterial(material)
     if comments: file.write('\n')
 
-    # if comments: file.write('//--Blob objects--\n\n')
     exportMeta([l for l in sel if l.type == 'META'])
-    # if comments: file.write('\n')
 
-    if comments: file.write('//--Mesh objecs--\n')
+    if comments: file.write('//--Mesh objects--\n')
     
     exportMeshs(scene, sel)
     #What follow used to happen here:
-- 
GitLab