# Copyright (c) 2010 www.rendering3d.net (GPL license) # author Silvio Falcinelli 2010 # silvio.falcinelli@rendering3d.net # # # experimet Yafaray integration in Blender 2.5 alpha2 # # version 2.0alpha2 15-04-2010 # # for yafaray experimental 523 - 541M linux # # know serius bug: # # if use renderengine panel or F12 # matrix mesh with modiefier crash # because (bpy.types.RenderEngine) API problem ??? # the same code export in (bpy.types.Operator) or (bpy.types.Panel) no crash # # for temporaly solution of this bug API 2.5.2 # for render user panel called 'Render(2)' # Render(2) not integration in Blender but not crash # the final solution waiting blender 2.6 stable # # # also 'engine_render_pov.py' in Blender 2.5 aplha # has same problem bpy.types.RenderEngine # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser General Public License for more details. # ################################################################################ import bpy from math import atan, pi, degrees import subprocess import os import sys import time import platform as pltfrm import Mathutils from rna_prop_ui import PropertyPanel from bpy.props import * import space_userpref import bgl import blf import platform import shutil from bpy.props import * updatemsg=() yafarayxmlVer='' yafarayVer ='' infoSystem ='' yafarayToBlender=True scene = bpy.context.scene event=0 narrowui = 180 def splitExt(path): dotidx = path.rfind('.') if dotidx == -1: return path, '' else: return path[dotidx:] def splitVer(path): dotidx = path.rfind(' ') if dotidx == -1: return path, '' else: return path[dotidx:] def splitFile(path): idx = path.rfind('/') if idx == -1: idx = path.rfind('\\') return path[idx:].replace("/", "").replace("\\", "") def yaf_init(): global yafarayxmlVer , yafarayVer , infoSystem, yafaray_ver scene = bpy.context.scene yafarayVer='' yafaraypath='' if platform.system()=='Linux': os.system('yafaray-xml -v > ver.txt') if platform.system()=='Windows': ### Find Where is Yafaray in microsoft os and choose the better Yafaray 64 bit if existing import winreg ### win xp 32 bit try: regKey = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, 'Software\\YafRay Team\\YafaRay') except: () ### win server 32 bit try: regKey = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, 'SOFTWARE\\YafRay Team\\YafaRay') except: () ### win xp 64 bit try: regKey = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, 'Software\\Wow6432Node\\YafRay Team\\YafaRay') except: () ### win server 64 bit try: regKey = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, 'SOFTWARE\\Wow6432Node\\YafRay Team\\YafaRay') except: () yafaraypath = winreg.QueryValueEx(regKey, 'InstallDir')[0] + '\\' pid=os.system('"%syafaray-xml\" -ver > ver.txt' % yafaraypath ) try: f=open('ver.txt', 'r') yafarayVer = f.readline() yafarayxmlVer = f.readline() yafarayVer = f.readline() f.close() yafarayVer = yafarayVer.replace('\n','') yafarayxmlVer = yafarayxmlVer.replace('\n','') print(yafarayxmlVer) print(yafarayVer) except: yafarayVer = 'Yafaray engine not found' yafarayxmlVer = 'Yafaray-xml not found' yafaray_ver=splitVer(yafarayVer).replace(' ','') infoSystem =('System: %s %s Cpus: %s' % (platform.system(),(platform.architecture()[0]),cpuCount())) return yafaraypath yafaray_ver='' ################### start temporaly solution for bug API 2.5.2 def render_frame(frame,fformat,fb): import platform _SYS = platform.system() scene = bpy.context.scene render = scene.render try: sframe="%.5d" % int(frame) except: sframe='' info='render yafaray-xml frame: %s' % frame import tempfile _temp_file_in = tempfile.mktemp(suffix='_%s.xml' % frame) if(scene.get("YafRay")) and scene.yaf_MASTER_enable: hasYafRay = True else: hasYafRay = False bpy.ops.export.xml(path=_temp_file_in , use_YMODE=hasYafRay , use_PR_MAT='') if _SYS != 'Windows': comando=('xterm -bg "#444" -fg "#eee" -fa face:terminal:Italic:pixelsize=10 -title "%s" -e "yafaray-xml %s -f %s -o /tmp/" ' % (info, _temp_file_in , fformat)) pID=os.system(comando) if render.output_path == '': render.output_path = '/tmp/YafaRay.tga' if render.output_path == '/tmp/': render.output_path = '/tmp/YafaRay.tga' if render.output_path == '/tmp/yafaray.tga': render.output_path = '/tmp/YafaRay.tga' output_file = render.output_path.replace(".tga","_%s.tga" % sframe) try: os.rename('/tmp/yafaray.tga' , output_file) print ("***-DONE-***") if fb: id=os.popen('eog -n %s' % output_file) if scene.yaf_sound_alert and frame =='': soundalert() try: #os.remove(_temp_file_in) # so as not to load the old file ###trovami () except: pass except: print ("***-ERROR-***") else: yafaraypath=yaf_init() import tempfile wintempdir = tempfile.gettempdir() windir = os.getenv("windir") winsysdrive = os.getenv("SystemDrive") output_path=render.output_path if output_path == '' or not (os.path.exists(os.path.dirname(output_path))) or output_path == '/tmp\\' or output_path.find("yafaray.tga") > -1 : render.output_path = '%s\\Yafa_Ray.tga' % wintempdir batfile = ('%s.bat' % _temp_file_in) f = open(batfile, 'w') f.write('%s:\n' % wintempdir.partition(':')[0] ) f.write('cd %s\n' % wintempdir.partition(':')[2] ) f.write('"%syafaray-xml\" "%s" -f %s -o "%s" \n' % (yafaraypath, _temp_file_in , fformat, wintempdir)) output_file = render.output_path.replace(".tga","_%s.tga" % sframe) f.write('copy %s\\yafaray.tga %s\n\n' % (wintempdir, output_file)) f.close() pID=os.system('%s.bat' % _temp_file_in) print ("***-DONE-***") if fb: id=os.popen('imdisplay \\"%s\\"' % output_file) try: os.remove(_temp_file_in) except: pass try: os.remove('%s.bat' % _temp_file_in) if scene.yaf_sound_alert: soundalert() except: pass def render_still(): import platform _SYS = platform.system() scene = bpy.context.scene render = scene.render render.color_mode = 'RGBA' if render.file_format == 'OPENEXR': fformat = 'EXR' render.color_mode = 'RGBA' else: fformat = 'TGA' render.file_format = 'TARGA' render.color_mode = 'RGBA' render_frame('',fformat,True) def render_animation(): import platform _SYS = platform.system() scene = bpy.context.scene render = scene.render render.color_mode = 'RGBA' if render.file_format == 'OPENEXR': fformat = 'EXR' render.color_mode = 'RGBA' else: fformat = 'TGA' render.file_format = 'TARGA' render.color_mode = 'RGBA' remCf=scene.current_frame if _SYS == 'windows': import msvcrt for f in range(scene.start_frame, scene.end_frame): scene.current_frame = f if f == scene.start_frame: render_frame(str(f),fformat,True) else: render_frame(str(f),fformat,False) if msvcrt.kbhit(): if ord(msvcrt.getch()) == 27: break else: for f in range(scene.start_frame, scene.end_frame): scene.current_frame = f if f == scene.start_frame: render_frame(str(f),fformat,True) else: render_frame(str(f),fformat,False) scene.current_frame=remCf if scene.yaf_sound_alert: soundalert() ##### render preview def render_preview(frame,material,mode): import platform _SYS = platform.system() scene = bpy.context.scene render = scene.render try: sframe="%.5d" % int(frame) except: sframe='' info='render yafaray-xml frame: %s' % frame import tempfile _temp_file_in = tempfile.mktemp(suffix='_%s.xml' % frame) if(scene.get("YafRay")) and scene.yaf_MASTER_enable: hasYafRay = True else: hasYafRay = False if material.type=='LAMP':bpy.ops.export.xml(path=_temp_file_in , use_YMODE=hasYafRay , use_PR_MAT='SkyPreview' ) else: if mode=='mat': bpy.ops.export.xml(path=_temp_file_in , use_YMODE=hasYafRay , use_PR_MAT=material.name ) if mode=='objPreview':bpy.ops.export.xml(path=_temp_file_in , use_YMODE=hasYafRay , use_PR_MAT=mode ) if _SYS != 'Windows': ### unix comando=('xterm -bg "#444" -fg "#eee" -fa face:terminal:Italic:pixelsize=10 -title "%s" -e "yafaray-xml %s -o /tmp/" ' % (info, _temp_file_in)) pID=os.system(comando) try: output_file = "/tmp/preview.tga" os.rename('/tmp/yafaray.tga' , output_file) id=os.popen('eog -n %s' % output_file) except: print('***ERRROR***') else: ### windows yafaraypath=yaf_init() import tempfile wintempdir = tempfile.gettempdir() windir = os.getenv("windir") winsysdrive = os.getenv("SystemDrive") output_path=render.output_path batfile = ('%s.bat' % _temp_file_in) f = open(batfile, 'w') f.write('%s:\n' % wintempdir.partition(':')[0] ) f.write('cd %s\n' % wintempdir.partition(':')[2] ) f.write('"%syafaray-xml\" "%s" -o "%s" \n' % (yafaraypath, _temp_file_in, wintempdir)) output_file = wintempdir+"\\preview.tga" f.write('copy %s\\yafaray.tga %s\n\n' % (wintempdir, output_file)) f.close() pID=os.system('%s.bat' % _temp_file_in) os.remove('%s.bat' % _temp_file_in) id=os.popen('imdisplay \\"%s\\"' % output_file) ################### end temporaly solution for bug API 2.5.2 ################## start convert yafaray team to Blender def yaf_obj_to_blender(): for mat in bpy.data.materials: matYaf = mat.get("YafRay") if matYaf: Type =matYaf.get("type") IOR =matYaf.get("IOR") diffuse_reflect =matYaf.get("diffuse_reflect") emit =matYaf.get("emit") specular_reflect =matYaf.get("specular_reflect") translucency =matYaf.get("translucency") transmit_filter =matYaf.get("transmit_filter") transparency =matYaf.get("transparency") color =matYaf.get("color") diffuse_reflect =matYaf.get("diffuse_reflect") exp_u =matYaf.get("exp_u") exp_v =matYaf.get("exp_v") exponent =matYaf.get("exponent") dispersion_power =matYaf.get("dispersion_power") Iabsorption_dist =matYaf.get("Iabsorption_dist") glossy_reflect =matYaf.get("glossy_reflect") diffuse_color =matYaf.get("diffuse_color") fresnel_effect =matYaf.get("fresnel_effect") #bool fake_shadows =matYaf.get("fake_shadows") #bool as_diffuse =matYaf.get("as_diffuse") #bool anisotropic =matYaf.get("anisotropic") #bool mirror_color =matYaf.get("mirror_color") #col if not mat.get('yafaray_anisotropic'): mat['yafaray_anisotropic']=0 if not mat.get('yafaray_E_H'): mat['yafaray_E_H']=100 if not mat.get('yafaray_E_V'): mat['yafaray_E_V']=100 if not mat.get('yafaray_matType'): mat['yafaray_matType']='' if not mat.get('yafaray_mix'): mat['yafaray_mix']=50 if not mat.get('yaf_mat_fake_shadows'): mat['yaf_mat_fake_shadows']=0 if not mat.get('yafaray_mat_mix_texture'): mat['yafaray_mat_mix_texture']=() if not mat.get('yafaray_mix_use_text'): mat['yafaray_mix_use_text']=False if Type == 'glass': transparency = 5 if transparency > 0.001: mat.transparency_method = 'RAYTRACE' mat.transparency = True transparency = transparency * 4.00 mat.raytrace_transparency.fresnel = transparency mat.raytrace_transparency.fresnel_factor = transparency else: mat.transparency = False if glossy_reflect > 0.001 or specular_reflect > 0.001: mat.raytrace_mirror.enabled = True mat.raytrace_mirror.reflect_factor = glossy_reflect mat.diffuse_color = tuple(diffuse_color ) mat.diffuse_color = tuple(color) mat.specular_color = tuple(mirror_color ) mat.mirror_color = tuple(mirror_color ) mat.raytrace_transparency.filter = transmit_filter #mat.subsurface_scattering.scale = Iabsorption_dist mat.specular_intensity = exponent mat.raytrace_mirror.gloss_factor = exponent if Type == 'coated_glossy' or Type == 'glossy': gloss=1 if exponent < 40 : gloss = 0.01 if exponent > 40 : gloss = 0.03 if exponent > 50 : gloss = 0.05 if exponent > 80 : gloss = 0.15 if exponent > 100 : gloss = 0.35 if exponent > 200 : gloss = 0.4 if exponent > 300 : gloss = 0.7 if exponent > 500 : gloss = 0.8 if exponent > 700 : gloss = 0.9 if exponent > 1000 : gloss = 0.95 if exponent > 2000 : gloss = 0.97 if exponent > 3000 : gloss = 0.99 mat.raytrace_mirror.gloss_factor = gloss mat['yafaray_E_H']= int(exp_u) mat['yafaray_E_V']= int(exp_v) if anisotropic == 'true': mat['yafaray_anisotropic']=True if anisotropic == 'false': mat['yafaray_anisotropic']=False mat.raytrace_transparency.fresnel = 0 mat.raytrace_transparency.fresnel_factor = 0 mat.diffuse_color = tuple(diffuse_color ) mat.mirror_color = tuple(mirror_color ) mat.translucency = 0 mat['yafaray_matType']='Node Material: glossy=True' mat.specular_ior = IOR if Type == 'coated_glossy': mat['yafaray_anisotropic']=True mat['yafaray_matType']='Node Material: cglossy=True' if Type == 'shinydiffusemat': mat.translucency = translucency mat.emit = emit mat['yafaray_matType']='Node Material: shiny=True' mat.specular_ior = IOR mat.translucency = translucency if Type == 'glass': if IOR == 1: IOR = 1.01 mat.raytrace_transparency.ior= IOR if fake_shadows=='true': mat['yaf_mat_fake_shadows']=True if fake_shadows=='false': mat['yaf_mat_fake_shadows']=False mat['yafaray_matType']='Node Material: glass=True' scene=bpy.data.scenes[0] objects=scene.objects world=scene.world lamps=([l for l in scene.objects if l.type == 'LAMP']) for ob in lamps: yafLamp=ob.get("YafRay") lamp = ob.data if yafLamp: lpower = float(yafLamp.get('power')) lradius = float(yafLamp.get('radius')) ldouble_sided = yafLamp.get('double_sided') lcolor=yafLamp.get('color') lsamples=yafLamp.get('samples') linfinite=yafLamp.get('infinite') ldirectioal=yafLamp.get('directional') try: ltype=yafLamp.get('type') # 'Sphere' 'Point' 'Spot' 'Directional' 'Sun' 'Area' except: if lamp.type == 'POINT' and lamp.shadow_soft_size > 0: ltype = 'Sphere' softSwadow = lradius lamp.color=lcolor if ltype == 'Sun': lamp.name = 'SUN' lamp.shadow_ray_samples = int(lsamples) if ltype == 'Area': lpower = float(float(lpower / (lamp.distance / lamp.distance))) lamp.shadow_ray_samples_x = lsamples lamp.shadow_ray_samples_y = lsamples if ltype == 'Sphere': lpower = (((lpower / 2.0) / lamp.distance) * (softSwadow / softSwadow)) if ltype == 'Sphere' or ltype == 'Spot': lpower = lpower / lamp.distance lamp.energy = lpower try: lamp.shadow_soft_size = softSwadow except:() objs=([o for o in scene.objects if o.type == 'MESH']) for ob in objs: if not ob.get('yafaray_meshLight'): ob['yafaray_meshLight']=0 if not ob.get('yafaray_meshLight_power'): ob['yafaray_meshLight_power']=2 if not ob.get('yafaray_meshLight_samples'):ob['yafaray_meshLight_samples']=24 if ob.get("YafRay"): objY = ob.get("YafRay") if objY.get('meshlight'): ob['yafaray_meshLight']=1 ob['yafaray_meshLight_power']=objY.get('power') ob['yafaray_meshLight_samples']=objY.get('samples') if not ob.color: objY.get('color') for mat in ob.data.materials: mat.emit=objY.get('power') def yaf_to_blender(): global yafarayToBlender yafarayToBlender=False scene=bpy.data.scenes[0] if scene.yaf_cam_type1==False and scene.yaf_cam_type2==False and scene.yaf_cam_type3==False and scene.yaf_cam_type4 == False: scene.yaf_cam_type1 = True rd = scene.render rd.display_mode = 'WINDOW' if(scene.get("YafRay")): if not (scene.get('YafRay').get('switch')): YR=scene.get('YafRay').get('Renderer') yaf_engine = YR.get('lightType') #print(yaf_engine) #if yaf_engine == 'Direct lighting': scene.yaf_PM_enable=False scene.yaf_PT_enable=False scene.yaf_AO_enable=False scene.yaf_SKY_enable=False rd.antialiasing=True if yaf_engine == 'Photon mapping' : scene.yaf_PM_enable=True scene.yaf_gamma =(YR.get('gamma')) scene.yaf_raydepth=YR.get('raydepth') scene.yaf_shadowdepth=YR.get('shadowDepth') scene.yaf_transp_shadows= YR.get('transpShad') if YR.get('caustics'): scene.UseCaustics=True else:scene.UseCaustics=False scene.yaf_PM_photons=YR.get('photons') scene.yaf_PT_photons=YR.get('photons') scene.yaf_AO_caus_mix=YR.get('caustic_mix') scene.yaf_PT_caus_mix=YR.get('caustic_mix') scene.yaf_PM_caus_mix=YR.get('caustic_mix') scene.yaf_AO_caus_radius = (YR.get('caustic_radius')) scene.yaf_AO_caus_depth = int(YR.get('caustic_depth')) scene.yaf_PT_caus_depth = int(YR.get('caustic_depth')) #YR.get('do_AO') scene.yaf_ao_samples = int(YR.get('AO_samples')) scene.yaf_AO_distance_calc= int(YR.get('AO_distance')) scene.world.ambient_color = tuple(YR.get('AO_color')) if YR.get('photonmapping'): scene.UsePhoton = True else: scene.UsePhoton = False scene.yaf_PT_samples=int(YR.get('fg_samples')) scene.yaf_PM_diff_radius=(YR.get('diffuseRadius')) scene.yaf_PM_search=(YR.get('search')) #YR.get('show_map') scene.yaf_PM_bounces=int(YR.get('fg_bounces')) if YR.get('finalGather'): scene.FinalGather=True else: scene.FinalGather=False scene.yaf_PT_depth=(YR.get('bounces')) scene.yaf_PM_depth=(YR.get('bounces')) scene.UseBGPT=YR.get('use_background') scene.UseBG=YR.get('use_background') # print (YR.get('stepSize')) # print (YR.get('adaptive')) # print (YR.get('optimize')) # print (YR.get('dsturbidity')) # print (YR.get('sigma_t')) scene.AA_passes = YR.get('AA_passes') scene.AA_inc_samples =YR.get('AA_inc_samples') scene.AA_minsamples = YR.get('AA_minsamples') rd.filter_size= YR.get('AA_pixelwidth') try: rd.pixel_filter=(str.upper(YR.get('filter_type'))) except:() scene.yaf_threshold=YR.get('AA_threshold') # print(YR.get('world_background')) # print (YR.get('alpha')) ################## end convert yafaray team to Blender MTL_DICT = {} if pltfrm.architecture()[0] == '64bit': bitness = 64 else: bitness = 32 def soundalert(): import os try: windir = os.getenv("windir") os.system('%s\\system32\\SNDREC32 /play /close /embedding %s\\MEDIA\\NOTIFY.WAV\n' % (windir,windir)) except:() try: os.popen('play /usr/share/sounds/KDE-Sys-Log-In-Short.ogg') except:() def cpuCount(): import sys import os if sys.platform == 'win32': try: num = int(os.environ['NUMBER_OF_PROCESSORS']) except (ValueError, KeyError): pass elif sys.platform == 'darwin': try: num = int(os.popen('sysctl -n hw.ncpu').read()) except ValueError: pass else: try: num = os.sysconf('SC_NPROCESSORS_ONLN') except (ValueError, OSError, AttributeError): pass if num >= 1: return num else: raise NotImplementedError #--------------------------------------------------------------------------------------------- def write_yafaray(filename, scene=None, info_callback=None): if(scene.get("YafRay")) and scene.yaf_MASTER_enable: hasYafRay = True else: hasYafRay = False bpy.ops.export.xml(path=filename , use_YMODE=hasYafRay ) ######### crash for API 2.5.2 class YafaRay(bpy.types.RenderEngine): DELAY=0.02 bl_idname = 'YAFARAY_RENDER' bl_label = "Yafaray 1.0alpha2" DELAY = 0.05 def _export(self, scene): import tempfile self._temp_file_in = tempfile.mktemp(suffix='.xml') def info_callback(txt): self.update_stats("", "YAFARAY: " + txt) time.sleep(self.DELAY) write_yafaray(self._temp_file_in, scene, info_callback) def _render(self): print ("***-STARTING-***") time.sleep(self.DELAY) def render(self, scene): import platform _SYS = platform.system() global updatemsg updatemsg=self info= 'Yafaray OS %s %s cpu %s Silvio Falcinelli' % (_SYS , (platform.architecture()[0]) , cpuCount() ) self = self render = scene.render self.update_stats("", "Yafaray: Exporting data from Blender") self._export(scene) self.update_stats("", "Yafaray: Silvio Falcinelli Export done, rendering in progress...") render.color_mode = 'RGBA' if render.file_format == 'OPENEXR': fformat = 'EXR' render.color_mode = 'RGBA' else: fformat = 'TGA' render.file_format = 'TARGA' render.color_mode = 'RGBA' x= int(render.resolution_x*render.resolution_percentage*0.01) y= int(render.resolution_y*render.resolution_percentage*0.01) if _SYS != 'Windows': comando=('xterm -bg "#444" -fg "#eee" -fa face:terminal:Italic:pixelsize=10 -title "%s" -e "yafaray-xml %s -f %s -o /tmp/" ' % (info, self._temp_file_in , fformat)) pid=os.system(comando) if render.output_path == '': render.output_path = '/tmp/YafaRay.tga' if render.output_path == '/tmp/': render.output_path = '/tmp/YafaRay.tga' if render.output_path == '/tmp/yafaray.tga': render.output_path = '/tmp/YafaRay.tga' try: os.rename('/tmp/yafaray.tga' , render.output_path) print ("***-DONE-***") result = self.begin_result(0, 0, x, y) result.layers[0].load_from_file(render.output_path) self.end_result(result) id=os.popen('eog -n %s' % render.output_path) if scene.yaf_sound_alert: soundalert() try: #os.remove(self._temp_file_in) # so as not to load the old file ###trovami () except: pass except: self.update_stats("", "General Error...") print ("***-ERROR-***") else: yafaraypath=yaf_init() import tempfile wintempdir = tempfile.gettempdir() windir = os.getenv("windir") winsysdrive = os.getenv("SystemDrive") if render.output_path == '': render.output_path = '%s\\temp\\Yafa_Ray.tga' % winsysdrive if render.output_path == '/tmp\\': render.output_path = '%s\\temp\\Yafa_Ray.tga' % winsysdrive if render.output_path == ('%s\\temp\\yafaray.tga' % winsysdrive): render.output_path = '%s\\temp\\Yafa_Ray.tga' % winsysdrive batfile = ('%s.bat' % self._temp_file_in) f = open(batfile, 'w') f.write('%s:\n' % wintempdir.partition(':')[0] ) f.write('cd %s\n' % wintempdir.partition(':')[2] ) f.write('"%syafaray-xml\" "%s" -f %s -o "%s" \n' % (yafaraypath, self._temp_file_in , fformat, wintempdir)) f.write('copy %s\\yafaray.tga %s\n\n' % (wintempdir, render.output_path)) f.close() pid=os.system('%s.bat' % self._temp_file_in) print ("***-DONE-***") time.sleep(self.DELAY) result = self.begin_result(0, 0, x, y) lay = result.layers[0] lay.load_from_file(render.output_path) self.end_result(result) try: os.remove(self._temp_file_in) except: pass try: os.remove('%s.bat' % self._temp_file_in) if scene.yaf_sound_alert: soundalert() except: pass import properties_render properties_render.RENDER_PT_dimensions.COMPAT_ENGINES.add('YAFARAY_RENDER') properties_render.RENDER_PT_output.COMPAT_ENGINES.add('YAFARAY_RENDER') del properties_render import properties_world properties_world.WORLD_PT_world.COMPAT_ENGINES.add('YAFARAY_RENDER') del properties_world class RenderPanel(bpy.types.Panel): bl_space_type = 'PROPERTIES' bl_region_type = 'WINDOW' bl_context = "render" () # AO panel, use in the scene for now. FloatProperty = bpy.types.Scene.FloatProperty IntProperty = bpy.types.Scene.IntProperty BoolProperty = bpy.types.Scene.BoolProperty BoolPropertyg = bpy.types.Scene.BoolProperty # skylight BoolProperty(attr="yaf_SKY_enable", name="Enable SKY", description="Enable yafarays ambient occlusion calculation", default=False) BoolProperty(attr="UseSun", name="Visible Sun", description="use one Direct Light name SUN in the scene", default=False) FloatProperty(attr="yaf_SKY_sun", min=0.00, max=10.00, default=0.50) BoolProperty(attr="UseSkyLight", name="Sky Light", description="Sky Light for exteriors scene is better AO", default=False) IntProperty(attr="yaf_SKY_samples", name="SKY samples", description="Number of samples SKY value has to be calculated", min=6, max=128, default=24) FloatProperty(attr="yaf_SKY_power", name="Power", description="Power", min=0, max=1, default=0.6) BoolProperty(attr="yaf_mat_preview", default=False) BoolProperty(attr="yaf_obj_preview", default=False) ## general setting BoolProperty(attr="yaf_transp_shadows", name="transparent shadows", description="", default=False) IntProperty(attr="yaf_raydepth", name="ray depht", description="", min=0, max=20, default=6) IntProperty(attr="yaf_shadowdepth", name="shadows depth", description="", min=0, max=20, default=2) FloatProperty(attr="yaf_gamma", name="gamma", description="", min=0.0, max=5.0, default=1.8) FloatProperty(attr="yaf_threshold", name="threshold", description="", min=0.00000, max=1.0000, default=0.0500) IntProperty(attr="yaf_meshlight_samples", name="mesh light samples", description="", min=1, max=128, default=24) BoolProperty(attr="yaf_master_light_samples", name="All Lights samples: ", description="over setting", default=False) IntProperty(attr="yaf_lights_samples", name="Samples", description="", min=1, max=128, default=24) BoolProperty(attr="yaf_sound_alert", name="Sound Notify at finish Rendering: ", description="", default=True) FloatProperty(attr="yaf_color_0_r") FloatProperty(attr="yaf_color_0_g") FloatProperty(attr="yaf_color_0_b") FloatProperty(attr="yaf_point_light_m", default=1) class RENDER_PT_yafaray_SKY(RenderPanel): global SunLamp bl_label = "SKY" ##COMPAT_ENGINES = {'YAFARAY_RENDER'} bl_default_closed = True bl_context = "render" def draw_header(self, context): scene = context.scene () BoolProperty(attr="yaf_meshLight", default=False) # Ambient Occlusion BoolProperty(attr="yaf_AO_enable", name="Enable AO", description="Enable yafarays ambient occlusion calculation", default=False) BoolProperty(attr="UseCaustics", name="Use Caustics", description="Use Caustics", default=False) IntProperty(attr="yaf_ao_samples", name="AO samples", description="Number of samples AO value has to be calculated", min=1, max=128, default=32) IntProperty(attr="yaf_AO_distance_calc", name="Recursion Limit", description="distance AO nice 3 unit meter", min=1, max=100, default=3) IntProperty(attr="yaf_AO_photons", name="photons", description="", min=100, max=10000000, default=500000) IntProperty(attr="yaf_AO_caus_depth", name="AO caustics depth", description="Caustics scatter depth", min=0, max=50, default=10) IntProperty(attr="yaf_AO_caus_mix", name="Mix", description="Caustics mix", min=1, max=10000, default=100) FloatProperty(attr="yaf_AO_caus_radius", name="Radius", description="Caustics radius", min=0.000, max=100.000, default=50.000) # PathTracing BoolProperty(attr="yaf_PT_enable", name="Enable PT", description="Enable yafarays Pathtracing calculation", default=False) BoolProperty(attr="UseBGPT", name="Use Background", description="Use Background", default=False) BoolProperty(attr="NoRec", name="No recursion", description="No recursion", default=False) BoolProperty(attr="UsePhoton", name="Use Photon", description="", default=False) IntProperty(attr="yaf_PT_samples", name="PT samples", description="Number of samples Pathtracing value has to be calculated", min=1, max=128, default=16) IntProperty(attr="yaf_PT_depth", name="Pathtracing light bounces", description="", min=0, max=50, default=5) IntProperty(attr="yaf_PT_photons", name="photons", description="", min=100, max=10000000, default=500000) IntProperty(attr="yaf_PT_caus_depth", name="PT caustics depth", description="Caustics scatter depth", min=0, max=50, default=10) IntProperty(attr="yaf_PT_caus_mix", name="Mix", description="Caustics mix", min=1, max=10000, default=100) FloatProperty(attr="yaf_PT_caus_radius", name="Radius", description="Caustics radius", min=0.000, max=100.000, default=1) # photon mapp BoolProperty(attr="yaf_PM_enable", name="Enable PM", description="Enable yafarays Photon Mapping calculation", default=False) BoolProperty(attr="UseBG", name="Use Background", description="Use Background", default=False) BoolProperty(attr="NoRec", name="No recursion", description="No recursion", default=False) IntProperty(attr="yaf_PM_samples", name="FG Samples", description="Number of samples Pathtracing value has to be calculated", min=1, max=128, default=35) IntProperty(attr="yaf_PM_bounces", name="FG bounces", description="", min=1, max=20, default=3) IntProperty(attr="yaf_PM_depth", name="depth", description="", min=0, max=50, default=5) IntProperty(attr="yaf_PM_photons", name="photons", description="", min=100, max=10000000, default=500000) IntProperty(attr="yaf_PM_caus_mix", name="Mix", description="Caustics mix", min=1, max=10000, default=10) IntProperty(attr="yaf_PM_search", name="Search", description="Caustics search", min=1, max=10000, default=100) FloatProperty(attr="yaf_PM_caus_radius", name="Radius", description="", min=0.0001, max=100.000, default=0.5) FloatProperty(attr="yaf_PM_diff_radius", name="Radius", description="", min=0.0001, max=100.000, default=0.5) IntProperty(attr="yaf_PM_caus_photons", name="Phothons", description="", min=1, max=10000, default=100) IntProperty(attr="yaf_PM_caus_bounces", name="Bounces", description="", min=1, max=20, default=3) BoolProperty(attr="ShowMap", name="Show mapp", description="", default=False) BoolProperty(attr="FinalGather", name="Final Gather", description="", default=False) BoolProperty(attr="ShowMap", name="Show Map", description="", default=False) BoolProperty(attr="yaf_cam_enable", name="Enable", description="Enable yafarays Pathtracing calculation", default=False) FloatProperty(attr="yaf_cam_dof", name="yaf_cam_Dof", description="depth of field", min=0.00, max=1000.00, default=0.00) FloatProperty(attr="yaf_cam_aperture", name="yaf_cam_aperture", description="", min=0.000, max=20.000, default=0.000) FloatProperty(attr="yaf_cam_brokeh", name="yaf_cam_Brokeh", description="camera dof Brokeh", min=0.00, max=180.0, default=0.00) FloatProperty(attr="yaf_cam_oscale", name="yaf_cam_Oscale", description="", min=0.00, max=1000.0, default=10.00) FloatProperty(attr="yaf_cam_ang1", name="yaf_cam_Ang1", description="", min=0.00, max=180.0, default=90.00) FloatProperty(attr="yaf_cam_ang2", name="yaf_cam_Ang2", description="", min=0.00, max=180.0, default=90.00) BoolProperty(attr="yaf_cam_opt1", name="yaf_cam_AngOpt1", description="", default=False) BoolProperty(attr="yaf_cam_opt2", name="yaf_cam_AngOpt2", description="", default=False) BoolProperty(attr="yaf_cam_type1") BoolProperty(attr="yaf_cam_type2") BoolProperty(attr="yaf_cam_type3") BoolProperty(attr="yaf_cam_type4") BoolProperty(attr="yaf_cam_bb1") BoolProperty(attr="yaf_cam_bb2") BoolProperty(attr="yaf_cam_bb3") BoolProperty(attr="yaf_cam_bb4") BoolProperty(attr="yaf_cam_bb5") BoolProperty(attr="yaf_cam_bb6") BoolProperty(attr="yaf_cam_bb7") BoolProperty(attr="yaf_MASTER_enable", name="Enable PT", description="Enable yafarays Pathtracing calculation", default=False) BoolProperty(attr="yaf_OBJ_to_blender", default=False) class RENDER_PT_yafaray_MASTER(RenderPanel): bl_label = "Use Yafaray system" ##COMPAT_ENGINES = {'YAFARAY_RENDER'} bl_default_closed = False def draw_header(self, context): global yafarayToBlender scene = context.scene self.layout.prop(scene, "yaf_MASTER_enable", text="") if yafarayToBlender and scene.yaf_MASTER_enable: yaf_to_blender() def draw(self, context): global yafarayToBlender global updatemsg if not context.scene.yaf_MASTER_enable: yafarayToBlender=True layout = self.layout scene = context.scene rd = scene.render layout = self.layout if(scene.get("YafRay")): layout.label(text='Yafary scene available') layout.prop(scene, "yaf_OBJ_to_blender", text="yafaray setting to blender", toggle=True) else: layout.label(text='Blender Translation mode') if scene.yaf_OBJ_to_blender: yaf_to_blender() yaf_obj_to_blender() print( 'INFO: convert done') scene.yaf_OBJ_to_blender=False updatemsg=self split = layout.split() split = layout.split() layout.label(text=infoSystem) layout.label(text= yafarayVer) layout.label(text= yafarayxmlVer) scene['yafaray_ver']= splitVer(yafarayVer).replace(' ','') if bpy.context.scene.get('yafaray_ver') > '522': split = layout.split() split = layout.split() layout.label(text=scene.get('yafaray_ver') + " enabled for:") layout.label(text=" IES LIGHT , FROST GLASS, MATERIAL LIGHT RADIANCE" ) if scene.get('yafaray_ver') > '541M': layout.label(text=" LIGHT LINEAR DECAY") IntProperty(attr="AA_passes", min=0, max=20, default=2) IntProperty(attr="AA_inc_samples", min=0, max=128, default=8) IntProperty(attr="AA_minsamples", min=0, max=64, default=2) class MaterialButtonsPanel(bpy.types.Panel): bl_space_type = 'PROPERTIES' bl_region_type = 'WINDOW' bl_context = "material" def poll(self, context): mat = context.material engine = context.scene.render.engine return mat and (engine in self.COMPAT_ENGINES) BoolProperty(attr="yafaray_mix_use_text", default=True) BoolProperty(attr="yafaray_use_ies", default=False) BoolProperty(attr="yaf_mat_fake_shadows", default=True) BoolProperty(attr="yaf_mat_aniso", default=True) IntProperty(attr="E_H", min=0, max=10000, default=100) IntProperty(attr="E_V", min=0, max=10000, default=100) BoolProperty(attr="yaf_mat_glass", default=False) BoolProperty(attr="yaf_mat_shiny", default=True) BoolProperty(attr="yaf_mat_glossy", default=False) BoolProperty(attr="yaf_mat_cglossy", default=False) BoolProperty(attr="yaf_mat_glass", default=False) IntProperty(attr="yaf_mix", min=0, max=100, default=50) yaf_current_obj = 'empity' yaf_mat_mix_filename = '' class RENDER_yafaray_mat(RenderPanel): ##COMPAT_ENGINES = {'YAFARAY_RENDER'} bl_idname = "YafaRay_mat" bl_label = "YafaRay Material" bl_space_type = "PROPERTIES" bl_context = "material" def draw(self, context): global yaf_current_obj layout = self.layout obj = context.material scene = context.scene if obj.name != yaf_current_obj: if not obj.get('yafaray_anisotropic'): obj['yafaray_anisotropic']=0 if not obj.get('yafaray_E_H'): obj['yafaray_E_H']=100 if not obj.get('yafaray_E_V'): obj['yafaray_E_V']=100 if not obj.get('yafaray_matType'): obj['yafaray_matType']='' if not obj.get('yafaray_mix'): obj['yafaray_mix']=50 if not obj.get('yaf_mat_fake_shadows'): obj['yaf_mat_fake_shadows']=0 if not obj.get('yafaray_mat_mix_texture'): obj['yafaray_mat_mix_texture']=() if not obj.get('yafaray_mix_use_text'): obj['yafaray_mix_use_text']=False if not obj.get('yafaray_use_ies'): obj['yafaray_use_ies']=False scene.yafaray_mix_use_text= obj.get('yafaray_mix_use_text') scene.yaf_mat_aniso= obj.get('yafaray_anisotropic') scene.E_H=obj.get('yafaray_E_H') scene.E_V=obj.get('yafaray_E_V') scene.yaf_mix= int(obj.get('yafaray_mix')) scene.yaf_mat_fake_shadows= obj.get('yaf_mat_fake_shadows') scene.yafaray_use_ies= obj.get('yafaray_use_ies') #print('USE IES %s ' % obj.get('yafaray_use_ies')) obj.transparency_method = 'RAYTRACE' yaf_current_obj=obj.name split = layout.split() col = split.column() col.prop(scene , "yaf_mat_preview" , text='Preview Material', toggle=True) col = split.column() col.prop(scene , "yaf_obj_preview" , text='Preview Objcet', toggle=True) split = layout.split() row = layout.row() col = split.column() col.enabled=False col.prop(scene , "yaf_mat_shiny" , text='Shiny', toggle=True) col = split.column() col.enabled=False col.prop(scene , "yaf_mat_glossy" , text='Glossy' , toggle=True) col = split.column() col.enabled=False col.prop(scene , "yaf_mat_cglossy" , text='CGlossy', toggle=True) col = split.column() r='' if obj.raytrace_transparency.gloss_factor < 1: r = 'R-' col.enabled=False col.prop(scene , "yaf_mat_glass" , text='%sGlass' % r, toggle=True) split = layout.split() split.label(text="Diffuse") split = layout.split() col = split.column() col.prop(obj, "diffuse_color", text="") col = split.column() col.prop(obj, "diffuse_intensity", text="Diffuse") split = layout.split() col = split.column() col.prop(obj, "diffuse_shader") if obj.diffuse_shader == 'LAMBERT': #print('lambert') () if obj.diffuse_shader == 'OREN_NAYAR': col.prop(obj, "roughness" , slider=True) layout.separator() split = layout.split() split.label(text="Specular & Mirror Color") split = layout.split() col = split.column() split = layout.split() col = split.column() col.prop(obj, "specular_color", text="") col = split.column() col.prop(obj, "specular_intensity", text="Specular") split = layout.split() col = split.column() col.prop(scene , "yaf_mat_aniso" , text='Anisotropic') col = split.column() col.prop(obj, "specular_ior", text="IOR") split = layout.split() col = split.column() layout.separator() if scene.yaf_mat_aniso: col = layout.split() split = layout.split() split = layout.split() col.prop(scene, "E_H", text="E Hor" ) col.prop(scene, "E_V", text="E Vert") obj['yafaray_E_H']=scene.E_H obj['yafaray_E_V']=scene.E_V obj['yafaray_anisotropic']=scene.yaf_mat_aniso emit = layout.split() emit.prop(obj, "emit", text="Emit", slider=True) split = layout.split() split.separator() split.separator() split.separator() mirror = layout.split() mirror.prop(obj.raytrace_mirror, "enabled", text="Mirror") if obj.raytrace_mirror.enabled: split = layout.split() col = split.column() split = layout.split() mirf = split.column() mirf.prop(obj.raytrace_mirror, "reflect_factor", text="Mirror") gloss = split.column() gloss.prop(obj.raytrace_mirror, "gloss_factor", text="Gloss") layout.separator() layout.separator() split = layout.split() split.prop(obj, "transparency") if obj.transparency: split = layout.split() col = split.column() split = layout.split() transp = split.column() transp.prop(obj.raytrace_transparency, "fresnel_factor", text="Transparency" , event=1) iort = split.column() split = layout.split() iort.prop(obj.raytrace_transparency, "ior", text="Glass IOR") col = split.column() split = layout.split() filter = split.column() filter.prop(obj.raytrace_transparency, "filter", text="filter") fake = split.column() fake.prop(scene , "yaf_mat_fake_shadows" , text='Glass Fake Shadows') split = layout.split() split = layout.split() col = split.column() col.prop(obj.subsurface_scattering, "scale", text="SSS") col = split.column() col.prop(obj.subsurface_scattering, "color", text="") split = layout.split() transl = split.column() transl.prop(obj, "translucency", text="Shiny Translucency", slider=True) obj['yaf_mat_fake_shadows']=scene.yaf_mat_fake_shadows split = layout.split() if yafaray_ver > '522': split.prop(obj.raytrace_transparency, "gloss_factor", text="Glossy Rough-Glass") layout.separator() emit.enabled=scene.yaf_mat_shiny if obj.transparency: if obj.raytrace_transparency.fresnel_factor != obj.raytrace_transparency.fresnel: obj.raytrace_transparency.fresnel = obj.raytrace_transparency.fresnel_factor if obj.raytrace_transparency.fresnel_factor > 1: filter.enabled=True if obj.raytrace_transparency.ior > 1: fake.enabled = True else : fake.enabled = False else: filter.enabled=False fake.enabled = False scene.yaf_mat_glass =False scene.yaf_mat_shiny =True scene.yaf_mat_glossy =False scene.yaf_mat_cglossy =False if scene.yaf_mat_aniso: scene.yaf_mat_cglossy =True scene.yaf_mat_glossy =False if obj.raytrace_transparency.ior > 1 and obj.transparency: scene.yaf_mat_glass =True if obj.raytrace_mirror.gloss_factor == 0 and not scene.yaf_mat_aniso: scene.yaf_mat_shiny =True if not scene.yaf_mat_aniso and obj.raytrace_mirror.gloss_factor != 1 and obj.raytrace_mirror.reflect_factor > 0: scene.yaf_mat_glossy =True if obj.raytrace_transparency.fresnel_factor ==1 or not obj.transparency : scene.yaf_mat_shiny =False if obj.raytrace_transparency.fresnel_factor > 1 and obj.raytrace_mirror.gloss_factor == 1: scene.yaf_mat_shiny =True if obj.raytrace_transparency.ior > 1 and scene.yaf_mat_aniso: scene.yaf_mat_shiny =False if (obj.raytrace_mirror.gloss_factor == 1 or scene.yaf_mat_aniso) and obj.raytrace_transparency.fresnel_factor > 1 and obj.raytrace_transparency.ior == 1: scene.yaf_mat_shiny =True if scene.yaf_mat_glass and obj.raytrace_mirror.reflect_factor == 0 or not obj.raytrace_mirror.enabled and obj.raytrace_transparency.ior > 1: scene.yaf_mat_shiny =False if obj.translucency>0:scene.yaf_mat_shiny =True if scene.yaf_mat_aniso and obj.raytrace_transparency.fresnel_factor == 1: scene.yaf_mat_shiny =False yafaray_matType = ('NodeYafaray: glass=%s shiny=%s glossy=%s cglossy=%s' % (scene.yaf_mat_glass, scene.yaf_mat_shiny,scene.yaf_mat_glossy, scene.yaf_mat_cglossy)) #print(yafaray_matType) if obj.raytrace_transparency.fresnel_factor > 0 and obj.raytrace_mirror.gloss_factor != 1 and obj.raytrace_mirror.enabled and obj.raytrace_transparency.ior > 1: scene.yaf_mat_shiny =False obj['yafaray_matType']= yafaray_matType if scene.yaf_mat_preview: frame=1 render_preview(frame,obj,'mat') scene.yaf_mat_preview=False if scene.yaf_obj_preview: frame=1 render_preview(frame,obj,'objPreview') scene.yaf_obj_preview=False node=0 node1='' node2='' if scene.yaf_mat_cglossy: if node1=='': node1='C Glossy' else: node2 = 'C Gloss' node +=1 if scene.yaf_mat_glass: if node1=='': node1='Glass' else: node2 = 'Glass' node +=1 if scene.yaf_mat_glossy: if node1=='': node1='Gloss' else: node2 = 'Glossy' node +=1 if scene.yaf_mat_shiny: if node1=='': node1='Shiny' else: node2 = 'Shiny' node +=1 if node>1: #layout.separator() split = layout.split() split.label(text=" Blend 2 Materials Node:" , icon='NODETREE') split = layout.split() col = split.column() col.label(text=node1, icon='MATERIAL' ) col = split.column() col = split.column() col.label(text=node2 , icon='MATERIAL') split = layout.split() split.prop(scene, "yaf_mix", text="Mix" ) ct=obj.get('yafaray_mat_mix_texture') sw=False nslot=0 for t in obj.texture_slots: try: if t.name == ct: sw=True nslot+=1 except: () if not sw: obj['yafaray_mat_mix_texture']='' if nslot > 0: split = layout.split() split.prop(scene, "yafaray_mix_use_text" , text="Use Texture in slot for Mixing:" ) obj['yafaray_mix_use_text']=scene.yafaray_mix_use_text if scene.yafaray_mix_use_text: split = layout.split() te=obj.get('yafaray_mat_mix_texture') col = split.column() col = split.column() col.label(text="%s" % te) split = layout.split() split = layout.split() nslot=0 listText=[] for t in obj.texture_slots: try: sname= t.name listText.append(t) if t.texture.type == 'IMAGE': split.label(text=" Type : %s" % t.texture.type , icon="FILE_IMAGE" ) else: split.label(text=" Type : %s" % t.texture.type , icon="TEXTURE_SHADED" ) BoolProperty(attr="mixText%s" % nslot , default=False ) col = split.column() col.prop(scene , "mixText%s" % nslot , toggle=True, text="%s" % sname) split = layout.split() nslot+=1 except: () try: if scene.mixText0: obj['yafaray_mat_mix_texture']= (listText[0].name) if scene.mixText1: obj['yafaray_mat_mix_texture']= (listText[1].name) if scene.mixText2: obj['yafaray_mat_mix_texture']= (listText[2].name) if scene.mixText3: obj['yafaray_mat_mix_texture']= (listText[3].name) if scene.mixText4: obj['yafaray_mat_mix_texture']= (listText[4].name) if scene.mixText5: obj['yafaray_mat_mix_texture']= (listText[5].name) if scene.mixText6: obj['yafaray_mat_mix_texture']= (listText[6].name) if scene.mixText7: obj['yafaray_mat_mix_texture']= (listText[7].name) if scene.mixText8: obj['yafaray_mat_mix_texture']= (listText[8].name) if scene.mixText9: obj['yafaray_mat_mix_texture']= (listText[9].name) if scene.mixText10: obj['yafaray_mat_mix_texture']= (listText[10].name) except: () try: scene.mixText0=False scene.mixText1=False scene.mixText2=False scene.mixText3=False scene.mixText4=False scene.mixText5=False scene.mixText6=False scene.mixText7=False scene.mixText8=False scene.mixText9=False scene.mixText10=False except: () else: layout.separator() split = layout.split() split.label(text=" For mixing 2 node is possible use Texture " , icon='INFO') split = layout.split() split.label(text=" Node Material [ %s ] 0 Texture" % obj.name , icon='MATERIAL_DATA') obj['yafaray_mix']=scene.yaf_mix layout.separator() split = layout.split() col = split.column() layout.separator() layout.separator() ### trovami FloatProperty(attr="yafaray_power", min=0.00, max=1000, default=50) class RENDER_yafaray_obj(RenderPanel): ##COMPAT_ENGINES = {'YAFARAY_RENDER'} bl_idname = "YafaRay_Object" bl_label = "YafaRay Object" bl_space_type = "PROPERTIES" bl_context = "object" def draw(self, context): global yaf_current_obj layout = self.layout obj = context.object row = layout.row() scene = context.scene if obj.type == 'MESH': if obj.name != yaf_current_obj: if not obj.get('yafaray_meshLight'): obj['yafaray_meshLight']=0 if not obj.get('yafaray_meshLight_power'): obj['yafaray_meshLight_power']=4.0 if not obj.get('yafaray_meshLight_samples'):obj['yafaray_meshLight_samples']=32 scene.yaf_meshLight= obj.get('yafaray_meshLight') scene.E_H=obj.get('yafaray_meshLight_samples') scene.yafaray_power=obj.get('yafaray_meshLight_power') yaf_current_obj=obj.name if obj.type == 'MESH': row.label(text=' %s name: %s' % (obj.type, obj.name ), icon='OBJECT_DATA') row.prop(scene,"yaf_meshLight", text='Mesh Light') if scene.yaf_meshLight: split = layout.split() row = split.column() row.prop(scene,"E_H", text='Samples') row = split.column() row.prop(scene,"yafaray_power", text='Power') split = layout.split() row = split.column() row.prop(obj,"color", text='Radiance Color' , slider=True) split = layout.split() for mat in obj.data.materials: split = layout.split() split.prop(mat,"emit", text='%s Emit' % mat.name , slider=True) obj['yafaray_meshLight_power']=scene.yafaray_power obj['yafaray_meshLight_samples']=scene.E_H obj['yafaray_meshLight']=scene.yaf_meshLight if obj.type == 'LAMP': if obj.data.type == 'SUN': lamp=obj.data row.label(text=' %s name: %s' % (obj.type, obj.name ), icon='LAMP_SUN') SunLamp= lamp.sky row.prop(SunLamp,"use_sky", text='activate Sunsky') if SunLamp.use_sky: obj['yafaray_meshLight']=scene.yaf_meshLight matrix = obj.matrix SunDir = matrix[2] layout.label(text='Direction: ') layout.label(text='X: %f Y: %f Z: %f' % (SunDir[0], SunDir[1], SunDir[2])) split = layout.split() split.template_preview(lamp, "preview" ) row = layout.row() row.prop(SunLamp, "atmosphere_turbidity", slider=True, text="Turbidity") split = layout.split() row = split.column() sub = row.column() sub.prop(SunLamp, "sky_blend", slider=True, text="Factor") row.active = SunLamp.use_sky row.label(text="Horizon:") sub = row.column() sub.prop(SunLamp, "horizon_brightness", slider=True, text="A Brightness") sub.prop(SunLamp, "spread", slider=True, text="B Spread") row.label(text="Sun:") sub = row.column() sub.prop(SunLamp, "sun_brightness", slider=True, text="C Brightness") sub.prop(SunLamp, "sun_size", slider=True, text="D Size") sub.prop(SunLamp, "backscattered_light", slider=True, text="E Back Light") split = layout.split() split = layout.split() split = layout.split() col = split.column() col.prop(scene , "yaf_mat_preview" , text='Preview Yafaray Sky', toggle=True) if scene.yaf_mat_preview: frame=1 render_preview(frame,obj,'sky') scene.yaf_mat_preview=False if obj.data.type == 'SPOT': if obj.name != yaf_current_obj: yaf_current_obj=obj.name if not obj.get('yafaray_use_ies'): obj['yafaray_use_ies']=False scene.yafaray_use_ies= obj.get('yafaray_use_ies') row.label(text=' %s name: %s' % (obj.type, obj.name ), icon='LAMP_SPOT') ct=obj.get('yafaray_lamp_ies') sw=False nslot=0 for t in obj.data.texture_slots: try: if t.name == ct: sw=True nslot+=1 except: () if not sw: obj['yafaray_use_ies']='' if nslot > 0: split = layout.split() split.prop(scene, "yafaray_use_ies" , text="Use IES in Slot Textures:" ) if scene.yafaray_use_ies: te=obj.get('yafaray_lamp_ies_file') iesfile='' for t in obj.data.texture_slots: try: if t.name == te: iesfile=splitFile(t.texture.image.filename) except: () split = layout.split() split.label(text="%s" % iesfile) split = layout.split() col = split.column() col = split.column() col.label(text="%s" % te) split = layout.split() split = layout.split() nslot=0 listText=[] for t in obj.data.texture_slots: try: sname= t.name listText.append(t) if t.texture.type == 'IMAGE' and str.upper(splitExt(t.texture.image.filename)) == '.IES': split.label(text=" Type : %s" % 'IES' , icon="TEXTURE_SHADED" ) BoolProperty(attr="mixText%s" % nslot , default=False ) col = split.column() col.prop(scene , "mixText%s" % nslot , toggle=True, text="%s" % sname) split = layout.split() nslot+=1 except: () try: if scene.mixText0: obj['yafaray_lamp_ies_file']= (listText[0].name) if scene.mixText1: obj['yafaray_lamp_ies_file']= (listText[1].name) if scene.mixText2: obj['yafaray_lamp_ies_file']= (listText[2].name) if scene.mixText3: obj['yafaray_lamp_ies_file']= (listText[3].name) if scene.mixText4: obj['yafaray_lamp_ies_file']= (listText[4].name) if scene.mixText5: obj['yafaray_lamp_ies_file']= (listText[5].name) if scene.mixText6: obj['yafaray_lamp_ies_file']= (listText[6].name) if scene.mixText7: obj['yafaray_lamp_ies_file']= (listText[7].name) if scene.mixText8: obj['yafaray_lamp_ies_file']= (listText[8].name) if scene.mixText9: obj['yafaray_lamp_ies_file']= (listText[9].name) if scene.mixText10: obj['yafaray_lamp_ies_file']= (listText[10].name) except: () try: scene.mixText0=False scene.mixText1=False scene.mixText2=False scene.mixText3=False scene.mixText4=False scene.mixText5=False scene.mixText6=False scene.mixText7=False scene.mixText8=False scene.mixText9=False scene.mixText10=False except: () obj['yafaray_use_ies']= scene.yafaray_use_ies print(obj.get('yafaray_use_ies')) row = layout.row() row = layout.row() BoolProperty(attr="yafaray_export", default=False) BoolProperty(attr="yafaray_exportA", default=False) class RENDER_yafaray_export(RenderPanel): bl_idname = "YafaRay_export" bl_label = "Yafaray Render" bl_space_type = "PROPERTIES" bl_context = "render" def draw(self, context): layout = self.layout scene = context.scene render = scene.render rd = scene.render layout = self.layout scene = context.scene separator="___________________________________________________________________" sepdot="........................................................................." split = layout.split() col = split.column() col.prop(scene, "yafaray_export", text="Image", toggle=True , icon='RENDER_STILL') if scene.yafaray_export: render_still() scene.yafaray_export=False col = split.column() col.prop(scene, "yafaray_exportA", text="Animation", toggle=True , icon='RENDER_ANIMATION') if scene.yafaray_exportA: render_animation() scene.yafaray_exportA=False layout.separator() layout = self.layout scene = context.scene rd = scene.render layout = self.layout split = layout.split() split.prop(rd,"antialiasing") if rd.antialiasing: split = layout.split() col = split.column() col.label(text="filter type") col = split.column() col.row().prop(scene.render, "pixel_filter", text="") split = layout.split() col = split.column() col.label(text="pixel width") col = split.column() col.row().prop(scene.render, "filter_size", text="") split = layout.split() split = layout.split() split = layout.split() col = split.column() col.label(text="Passes") col = split.column() col.prop(scene, "AA_passes" , text="") split = layout.split() col = split.column() col.label(text="Samples") col = split.column() col.prop(scene, "AA_minsamples" , text="") split = layout.split() col = split.column() col.label(text="Samples passes") col = split.column() col.prop(scene, "AA_inc_samples" ,text="") split = layout.split() split.label(text=separator) split = layout.split() split.label(text='General Settings') split = layout.split() split.prop(scene, "yaf_raydepth", text="ray depth") split = layout.split() split.prop(scene, "yaf_shadowdepth", text="shadows depth") split = layout.split() split.prop(scene, "yaf_gamma", text="Gamma:") split = layout.split() col = split.column() col.prop(scene, "yaf_transp_shadows") col = split.column() col.prop(scene, "yaf_threshold", text="AA Threshold:") split = layout.split() split = layout.split() split = layout.split() split = layout.split() layout.label(text="Option Master Setting") split = layout.split() split.prop(scene, "yaf_meshlight_samples") split = layout.split() col = split.column() col.prop(scene, "yaf_master_light_samples" , icon='OUTLINER_OB_LAMP') col = split.column() col.prop(scene, "yaf_lights_samples") split = layout.split() split = layout.split() split.label(text="Point Light power mult") split.prop(scene, "yaf_point_light_m") split = layout.split() split = layout.split() col = split.column() col.prop(scene, "yaf_sound_alert") split = layout.split() split.label(text=separator) split = layout.split() split.prop(scene, "yaf_AO_enable", text="Engine - Ambient Occlusion") if scene.yaf_AO_enable: scene.yaf_PT_enable = False scene.yaf_PM_enable = False layout = self.layout scene = context.scene rd = scene.render layout.active = scene.yaf_AO_enable split = layout.split() col = split.column() col.prop(scene, "yaf_ao_samples", text="Samples") col = split.column() col.prop(scene, "yaf_AO_distance_calc", text="Distance") split = layout.split() col = split.column() column=col row = col.row() col.row().prop(scene.world, "ambient_color", text="") col = split.column() col.label(text=" Ambient Color:", icon='WORLD_DATA') split = layout.split() split = layout.split() split = layout.split() col = split.column() col.prop(scene, "UseCaustics") col = split.column() col.prop(scene, "yaf_AO_photons", text="Photn") split = layout.split() split.prop(scene, "yaf_AO_caus_depth", text="Caustics depth") split = layout.split() col = split.column() col.prop(scene, "yaf_AO_caus_mix") col = split.column() col.prop(scene, "yaf_AO_caus_radius") split = layout.split() split.label(text=separator) split = layout.split() split.prop(scene, "yaf_PT_enable", text="Engine - Pathtracing") if scene.yaf_PT_enable: scene.yaf_AO_enable = False scene.yaf_PM_enable = False layout = self.layout scene = context.scene rd = scene.render layout.active = scene.yaf_PT_enable split = layout.split() col = split.column() col.prop(scene, "yaf_PT_samples", text="FG Samples") col = split.column() col.prop(scene, "yaf_PT_depth", text="Depth") split = layout.split() col = split.column() col.prop(scene, "UsePhoton") col = split.column() col.prop(scene, "yaf_PT_photons", text="Photn") split = layout.split() split.prop(scene, "yaf_PT_caus_depth", text="Caustics depth") split = layout.split() col = split.column() col.prop(scene, "yaf_PT_caus_mix") col = split.column() col.prop(scene, "yaf_PT_caus_radius") split = layout.split() col = split.column() col.prop(scene, "UseBGPT") col = split.column() col.prop(scene, "NoRec") split = layout.split() split.prop(scene, "yaf_PM_enable", text="Engine - Photon mapping") if scene.yaf_PM_enable: scene.yaf_PT_enable = False scene.yaf_AO_enable = False layout = self.layout scene = context.scene rd = scene.render layout.active = scene.yaf_PM_enable split = layout.split() col = split.column() col.prop(scene, "yaf_PM_samples" ) col = split.column() col.prop(scene, "yaf_PM_depth", text="Depth") split = layout.split() col = split.column() col.prop(scene, "FinalGather") split = layout.split() split = layout.split() split = layout.split() split.prop(scene, "yaf_PM_photons", text="Photons") split = layout.split() split = layout.split() col = split.column() col.prop(scene, "yaf_PM_search" ) col = split.column() col.prop(scene, "yaf_PM_diff_radius") split = layout.split() split = layout.split() split = layout.split() col = split.column() col.label(text=" Caustics") split = layout.split() if yafaray_ver > '522': split.prop(scene, "yaf_PM_caus_photons") split = layout.split() col = split.column() col.prop(scene, "yaf_PM_caus_mix") col = split.column() col.prop(scene, "yaf_PM_caus_radius") #col.prop(scene, "yaf_PM_caus_bounces") split = layout.split() split = layout.split() split = layout.split() split = layout.split() split.prop(scene, "ShowMap" , toggle=True) split.prop(scene, "yaf_PM_caus_bounces") split = layout.split() split = layout.split() col = split.column() col.prop(scene, "UseBG") col = split.column() #col.prop(scene, "ShowMap") if scene.yaf_cam_type1 == True: scene.yaf_cam_type2 = False scene.yaf_cam_type3 = False scene.yaf_cam_type4 = False if scene.yaf_cam_type2 == True: scene.yaf_cam_type1 = False scene.yaf_cam_type3 = False scene.yaf_cam_type4 = False if scene.yaf_cam_type3 == True: scene.yaf_cam_type2 = False scene.yaf_cam_type1 = False scene.yaf_cam_type4 = False if scene.yaf_cam_type4 == True: scene.yaf_cam_type2 = False scene.yaf_cam_type3 = False scene.yaf_cam_type1 = False if scene.yaf_cam_bb1 == True: scene.yaf_cam_bb2 = False scene.yaf_cam_bb3 = False scene.yaf_cam_bb4 = False scene.yaf_cam_bb5 = False scene.yaf_cam_bb6 = False scene.yaf_cam_bb7 = False if scene.yaf_cam_bb2 == True: scene.yaf_cam_bb1 = False scene.yaf_cam_bb3 = False scene.yaf_cam_bb4 = False scene.yaf_cam_bb5 = False scene.yaf_cam_bb6 = False scene.yaf_cam_bb7 = False if scene.yaf_cam_bb3 == True: scene.yaf_cam_bb2 = False scene.yaf_cam_bb1 = False scene.yaf_cam_bb4 = False scene.yaf_cam_bb5 = False scene.yaf_cam_bb6 = False scene.yaf_cam_bb7 = False if scene.yaf_cam_bb4 == True: scene.yaf_cam_bb2 = False scene.yaf_cam_bb3 = False scene.yaf_cam_bb1 = False scene.yaf_cam_bb5 = False scene.yaf_cam_bb6 = False scene.yaf_cam_bb7 = False if scene.yaf_cam_bb5 == True: scene.yaf_cam_bb2 = False scene.yaf_cam_bb3 = False scene.yaf_cam_bb4 = False scene.yaf_cam_bb1 = False scene.yaf_cam_bb6 = False scene.yaf_cam_bb7 = False if scene.yaf_cam_bb6 == True: scene.yaf_cam_bb2 = False scene.yaf_cam_bb3 = False scene.yaf_cam_bb4 = False scene.yaf_cam_bb5 = False scene.yaf_cam_bb1 = False scene.yaf_cam_bb7 = False if scene.yaf_cam_bb7 == True: scene.yaf_cam_bb2 = False scene.yaf_cam_bb3 = False scene.yaf_cam_bb4 = False scene.yaf_cam_bb5 = False scene.yaf_cam_bb6 = False scene.yaf_cam_bb1 = False split = layout.split() split.label(text=separator) split = layout.split() split = layout.split() col = split.column() col.prop(scene, "yaf_cam_type1", text="Perspective", toggle=True) col = split.column() col.prop(scene, "yaf_cam_type2", text="Orthographic", toggle=True) split = layout.split() col = split.column() col.prop(scene, "yaf_cam_type3", text="Angular", toggle=True) col = split.column() col.prop(scene, "yaf_cam_type4", text="Architect", toggle=True) split = layout.split() split = layout.split() split = layout.split() if scene.yaf_cam_type2: split = layout.split() split.prop(scene, "yaf_cam_oscale" , text="Scale Orthographics") if scene.yaf_cam_type3: split = layout.split() col = split.column() col.prop(scene, "yaf_cam_ang1" , text="Angle ") col = split.column() col.prop(scene, "yaf_cam_ang2" , text="Max angle ") split = layout.split() col = split.column() col.prop(scene, "yaf_cam_opt1" , text="Mirrored" , toggle=True) col = split.column() col.prop(scene, "yaf_cam_opt2" , text="Circolar" , toggle=True) if scene.yaf_cam_type1 or scene.yaf_cam_type4: split = layout.split() col = split.column() col = split.column() col.prop(scene, "yaf_cam_aperture" , text="DOF Aperture") split = layout.split() col = split.column() col.label(text=" Depht of field") col = split.column() col.prop(scene, "yaf_cam_dof" , text="DOF distance") split = layout.split() col = split.column() col = split.column() col.prop(scene, "yaf_cam_brokeh" , text="Brokeh" ) split = layout.split() split = layout.split() col = split.column() col.label(text="Bokeh bias") col = split.column() col.prop(scene, "yaf_cam_bb1", text="Disk1", toggle=True) col = split.column() col.prop(scene, "yaf_cam_bb2", text="Disk2", toggle=True) col = split.column() col.prop(scene, "yaf_cam_bb3", text="Triangle", toggle=True) split = layout.split() col = split.column() col.prop(scene, "yaf_cam_bb4", text="Square", toggle=True) col = split.column() col.prop(scene, "yaf_cam_bb5", text="Pentagon", toggle=True) col = split.column() col.prop(scene, "yaf_cam_bb6", text="Hexagon", toggle=True) col = split.column() col.prop(scene, "yaf_cam_bb7", text="Ring", toggle=True ) split = layout.split() split.label(text=separator) split = layout.split() self.layout.prop(scene, "yaf_SKY_enable", text="Sky Light") if scene.yaf_SKY_enable: global SunLamp layout = self.layout scene = context.scene rd = scene.render layout.active = scene.yaf_SKY_enable split = layout.split() split = layout.split() col = split.column() col.prop(scene, "UseSkyLight") col = split.column() col.prop(scene, "yaf_SKY_samples", text="Samples") col = split.column() col.prop(scene, "yaf_SKY_power", text="Power") split = layout.split() split = layout.split() split = layout.split() col = split.column() col.prop(scene, "UseSun") if scene.UseSun: SunDir = (0,0,0) lamps=([l for l in scene.objects if l.type == 'LAMP']) for ob in lamps: lamp = ob.data if lamp.type == 'SUN' and lamp.name == 'SUN': SunLamp= lamp.sky matrix = ob.matrix SunDir = matrix[2] if SunDir == (0,0,0): layout.label(text="not found any direct lamp name SUN") layout.label(text="please make Sun lamp name SUN") else: layout.label(text=' SUN Direction: ', icon='OUTLINER_OB_LAMP') layout.label(text='X: %f Y: %f Z: %f' % (SunDir[0], SunDir[1], SunDir[2])) SunLamp.use_sky=True col.template_preview(lamp, "preview" ) row = layout.row() row.active = SunLamp.use_sky or SunLamp.use_atmosphere row.prop(SunLamp, "atmosphere_turbidity", slider=True, text="Turbidity") split = layout.split() col = split.column() sub = col.column() sub.prop(SunLamp, "sky_blend", slider=True, text="Factor") col.active = SunLamp.use_sky col.label(text="Horizon:") sub = col.column() sub.prop(SunLamp, "horizon_brightness", slider=True, text="A Brightness") sub.prop(SunLamp, "spread", slider=True, text="B Spread") col.label(text="Sun:") sub = col.column() sub.prop(SunLamp, "sun_brightness", slider=True, text="C Brightness") sub.prop(SunLamp, "sun_size", slider=True, text="D Size") sub.prop(SunLamp, "backscattered_light", slider=True, text="E Back Light") split = layout.split() split = layout.split() split = layout.split() split = layout.split() split = layout.split() split = layout.split() col = split.column() col.prop(scene , "yaf_mat_preview" , text='Preview Yafaray Sky', toggle=True) if scene.yaf_mat_preview: frame=1 render_preview(frame,ob,'sky') scene.yaf_mat_preview=False split = layout.split() split.label(text=separator) split = layout.split() yafaray= yaf_init() layout = self.layout layout.label(text="WARNING this is beta experimen 04-03-2010") layout.label(text="last modify 06-04-2010") split = layout.split() split = layout.split() layout.label(text="for Bug report and suggestions write me ") layout.label(text="silvio.falcinelli@rendering3d.net") split = layout.split() split = layout.split() split = layout.split() split = layout.split() layout.label(text="Author: Silvio Falcinelli") layout.label(text="KhonKaen Thailand") try: yaf_init() except: () classes = [ YafaRay, RENDER_yafaray_export, RENDER_PT_yafaray_MASTER, RENDER_yafaray_obj, RENDER_yafaray_mat ] def register(): register = bpy.types.register for cls in classes: register(cls) def unregister(): unregister = bpy.types.unregister for cls in classes: unregister(cls) if __name__ == "__main__": register()