#!BPY """Registration info for Blender menus: Name: 'V-Ray/Blender' Blender: 240 Group: 'Render' Tooltip: 'Export to V-Ray scene format (.vrscene)' """ ####################################################################### AUTHOR BLOCK # # V-Ray/Blender # # Started: 7 Feb 2008 # Last Modified: 3 Sep 2008 # # Author: Andrey M. Izrantsev (aka bdancer) # E-Mail: izrantsev@gmail.com # # This plugin is protected by the GPL: Gnu Public Licence # GPL - http://www.gnu.org/copyleft/gpl.html # # Special thanks to LuxBlend and MOSIAC authors - your code is great :) # GUI is based on LuxBlender exporter. # ####################################################################### GPL LICENSE BLOCK # Script Copyright (C) Andrey M. Izrantsev # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . ####################################################################### COPYRIGHT BLOCK # All Rights Reserved # V-Ray(R) is a registered trademark of Chaos Group ####################################################################### END BLOCKS import math import os import sys as osys import Blender import bpy from Blender import Mesh, Scene, Object, Material, Texture, Window, sys, Draw, BGL, Mathutils, Lamp from Blender.Scene import Render from Blender.Window import DrawProgressBar from math import sqrt from math import pi vrayblender_version = "0.9.8" scenefile = "" geomfile = "" matfile = "" sfile = "" gfile = "" mfile ="" scene = Scene.GetCurrent() exported_materials = [] exported_textures = [] exported_bitmaps = [] ERROR = 0 def setProperty(name, value): scene.properties[name] = value def ssp(name, value): scene.properties[name] = value def setProp(name): return lambda evt, val: setProperty(name, val) def getProperty(name): return scene.properties[name] def gsp(name): return scene.properties[name] def getProp(name, default): try: value = gsp(name) except: value = default scene.properties[name] = default return value def setObjProperty(obj, name, value): obj.properties[name] = value def sp(obj, name, value): obj.properties[name] = value def setObjProp(obj, name): return lambda evt, val: setObjProperty(obj, name, val) def gperty(obj, name): return obj.properties[name] def gp(obj, name, default): try: value = obj.properties[name] except: value = default sp(obj, name, value) return value def stripName(str): return str.replace(".","_").replace(":","_").replace(";","_").replace(" ","_").replace("-","_").replace("(","_").replace(")","_").replace("<","_").replace(">","_").replace("#","_").replace("+","__").replace("\\","_").replace("/","_") def getName(obj): return stripName(obj.getName()) def transformMatrix(matrix): str = "Transform (\n\t\tMatrix (\n\t\t\tVector(%f, %f, %f),\n\t\t\tVector(%f, %f, %f),\n\t\t\tVector(%f, %f, %f)\n\t\t),\n\t\tVector(%f, %f, %f)\n\t)"\ %(matrix[0][0], matrix[0][1], matrix[0][2],\ matrix[1][0], matrix[1][1], matrix[1][2],\ matrix[2][0], matrix[2][1], matrix[2][2],\ matrix[3][0], matrix[3][1], matrix[3][2]) return str ## ## GEOMETRY ## def exportMesh(obj_name, mesh): str = "" # Vertex array vertexArray = {} vertexListstr = "" i = 0 # Vertex index for vertex in mesh.verts: vertex_coord = "%.4f,%.4f,%.4f"%(vertex.co[0], vertex.co[1], vertex.co[2]) vertexArray[vertex_coord] = i # [vertex coord] => vertex index vertexListstr += "Vector(%s),"%(vertex_coord) i += 1 vertexListstr = vertexListstr[0:-1] # Face normals array normalsArray = {} normalsListstr = "" v = 0 # Normal index for face in mesh.faces: normal = face.no for vertex in face.verts: if (face.smooth): normal = vertex.no vertex_normal = "%.4f,%.4f,%.4f"%(normal[0], normal[1], normal[2]) normalsArray[vertex_normal] = v # [normal coord] => normal index v += 1 normalsListstr += "Vector(%s),"%(vertex_normal) normalsListstr = normalsListstr[0:-1] # UV array uvArray = {} mapchannelVertexList = "" u = 0 for face in mesh.faces: if mesh.faceUV: for uv in face.uv: uv_coord = "%.4f,%.4f,0"%(uv[0],uv[1]) uvArray[uv_coord] = u u += 1 u = 0 for uv in uvArray: uvArray[uv] = u mapchannelVertexList += "Vector(%s),"%(uv) u += 1 mapchannelVertexList = mapchannelVertexList[0:-1] mapchannelFaceList = "" for face in mesh.faces: if mesh.faceUV: if(len(face.uv) == 3): for uv in face.uv: uv_coord = "%.4f,%.4f,0"%(uv[0],uv[1]) mapchannelFaceList += "%i,"%(uvArray[uv_coord]) else: quvArray = {} v = 0 for uv in face.uv: uv_coord = "%.4f,%.4f,0"%(uv[0],uv[1]) quvArray[v] = uv_coord v += 1 for l in [0,1,2,2,3,0]: mapchannelFaceList += "%i,"%(uvArray[quvArray[l]]) mapchannelFaceList = mapchannelFaceList[0:-1] # Faces array faceListstr = "" facenormalListstr = "" face_matIDListstr = "" for face in mesh.faces: mat_id = face.mat normal = face.no face_matIDListstr += "%s,"%(mat_id) # Get material ID if(len(face.verts) == 3): for vertex in face.verts: if (face.smooth): normal = vertex.no vertex_normal = "%.4f,%.4f,%.4f"%(normal[0], normal[1], normal[2]) vertex_coord = "%.4f,%.4f,%.4f"%(vertex.co[0], vertex.co[1], vertex.co[2]) facenormalListstr += "%i,"%(normalsArray[vertex_normal]) # Get normal index in normals array faceListstr += "%i,"%(vertexArray[vertex_coord]) # Get vertex index in vertex array else: # Split 4-vertex face to 2 triangle faces face_matIDListstr += "%s,"%(mat_id) # Add one more ID for splitted face j = 0 qvArray = {} qnArray = {} for vertex in face.verts: if (face.smooth): normal = vertex.no qfv = "%.4f,%.4f,%.4f"%(vertex.co[0], vertex.co[1], vertex.co[2]) qfn = "%.4f,%.4f,%.4f"%(normal[0], normal[1], normal[2]) qvArray[j] = qfv # [vertex index] => vertex coord qnArray[j] = qfn # [normal index] => normal coord j += 1 for v in [0,1,2,2,3,0]: facenormalListstr += "%i,"%(normalsArray[qnArray[v]]) # Get normal index in normals array faceListstr += "%i,"%(vertexArray[qvArray[v]]) # Get vertex index in vertex array faceListstr = faceListstr[0:-1] facenormalListstr = facenormalListstr[0:-1] face_matIDListstr = face_matIDListstr[0:-1] str += "\nGeomStaticMesh GeomStaticMesh_%s {"%(obj_name) str += "\n\tvertices=ListVector(%s);"%(vertexListstr) str += "\n\tnormals=ListVector(%s);"%(normalsListstr) str += "\n\tfaces=ListInt(%s);"%(faceListstr) str += "\n\tfaceNormals=ListInt(%s);"%(facenormalListstr) str += "\n\tface_mtlIDs=ListInt(%s);"%(face_matIDListstr) if mesh.faceUV: str += "\n\tmap_channels = List(" str += "\n\t\tList(1," # the channel index str += "\n\t\tListVector(%s),"%(mapchannelVertexList) # the channel vertices str += "\n\t\tListInt(%s)"%(mapchannelFaceList) # the channel faces str += "\n\t\t)" str += "\n\t);" str += "\n}\n" return str def exportGeomDisplacedMesh(obj): obj_name = getName(obj) tex_name = gp(obj, "vr_displace_tex", "") str = "\nGeomDisplacedMesh GeomDisplacedMesh_%s {"%(obj_name) str += "\n\tmesh=GeomStaticMesh_%s;"%(obj_name) str += "\n\tdisplacement_tex_color=%s;"%(tex_name) str += "\n\tdisplacement_amount=%.5f;"%( gp(obj, "displacement_amount", 0.001) ) str += "\n\tdisplacement_shift=%.4f;"%( gp(obj, "displacement_shift", 0.0) ) str += "\n\tuse_globals=%d;"%( gp(obj, "displacement_use_globals",0) ) str += "\n\tview_dep=%d;"%( gp(obj, "displacement_view_dep", 1) ) str += "\n\tedge_length=%.4f;"%( gp(obj, "displacement_edge_length", 4.0) ) str += "\n\tmax_subdivs=%d;"%( gp(obj, "displacement_max_subdivs", 256) ) str += "\n\tkeep_continuity=%d;"%( gp(obj, "displacement_keep_continuity", 0) ) #str += "\n\twater_level=%.4f;"%( gp(obj, "displacement_water_level", 0) ) str += "\n}\n" return str ## ## MATERIALS ## def exportUVWGenEnvironment(name, envuvw_type): type = "" if envuvw_type == 0: type = "spherical" if envuvw_type == 1: type = "screen" if envuvw_type == 2: type = "mirror_ball" if envuvw_type == 3: type = "cubic" if envuvw_type == 4: type = "angular" uvw_name = "UVWGenEnvironment_%s"%(name) str = "\nUVWGenEnvironment %s {"%(uvw_name) str += "\n\tuvw_transform=Transform(" str += "\n\t\tMatrix(" str += "\n\t\tVector(1.0,0.0,0.0)," str += "\n\t\tVector(0.0,1.0,0.0)," str += "\n\t\tVector(0.0,0.0,1.0)" str += "\n\t\t)," str += "\n\t\tVector(0.0,0.0,0.0)" str += "\n\t);" str += "\n\tmapping_type=\"%s\";"%(type) str += "\n}\n" return uvw_name, str def exportUVWGenChannel(tex, name): uwv_name = "UVWGenChannel_%s"%(name) (xrepeat, yrepeat) = tex.repeat str = "\nUVWGenChannel %s {"%(uwv_name) str += "\n\tuvw_channel=1;" str += "\n\tuvw_transform=Transform(" str += "\n\t\tMatrix(" str += "\n\t\t\tVector(1.0,0.0,0.0)*%s,"%(xrepeat) str += "\n\t\t\tVector(0.0,1.0,0.0)*%s,"%(yrepeat) str += "\n\t\t\tVector(0.0,0.0,1.0)" str += "\n\t\t)," str += "\n\t\tVector(0.0,0.0,0.0)" str += "\n\t);" str += "\n}\n" return uwv_name, str def exportBitmapBuffer(tex): global exported_bitmaps str = "" bitmap = tex.image file = bitmap.filename (filepath,filename) = os.path.split(bitmap.filename) if (filepath[0:2] == "//"): filepath = filepath[2:] (currentdir,currentfile) = os.path.split(Blender.Get("filename")) file = os.path.join(currentdir,filepath,filename) bitmap_name = stripName(bitmap.name) buffer_name = "BitmapBuffer_%s"%(bitmap_name) if ( bitmap_name not in exported_bitmaps ): exported_bitmaps.append(bitmap_name) str += "\nBitmapBuffer %s {"%(buffer_name) str += "\n\tfile=\"%s\";"%(file) str += "\n\tfilter_type=1;" str += "\n\tfilter_blur=%.3f;"%(tex.filterSize) str += "\n\tgamma=%.4f;"%(getProp("vray_inputgamma",1.0)) str += "\n}\n" return buffer_name, str ### Textures def exportTexBitmap(name, bitmap, uvw): global exported_textures str = "" tex_name = "TexBitmap_%s"%(name) if ( name not in exported_textures ): exported_textures.append(name) str += "\nTexBitmap %s {"%(tex_name) str += "\n\tbitmap=%s;"%(bitmap) str += "\n\tuvwgen=%s;"%(uvw) str += "\n\tnouvw_color=AColor(0,0,0,0);" str += "\n}\n" return tex_name, str def exportTexSky(): global exported_textures str = "" tex_name = "VRaySky" if ( tex_name not in exported_textures ): exported_textures.append(tex_name) str += "\nTexSky VRaySky {" str += "\n\tsun=VRaySun;" if (not getProp("vray_sunsky_skyauto",1)): str += "\n\tturbidity=%.2f;"%(getProp("vray_sunsky_sky_turbidity", 3.0)) str += "\n\tozone=%.2f;"%(getProp("vray_sunsky_sky_ozone", 0.35)) str += "\n\tintensity_multiplier=%.2f;"%(getProp("vray_sunsky_sky_intensity", 1.0)) str += "\n\tsize_multiplier=%.2f;"%(getProp("vray_sunsky_sky_size_multiplier", 1.0)) str += "\n\tinvisible=%i;"%(getProp("vray_sunsky_sky_invisible",0)) str += "\n}\n" return str def exportTexInvert(name): str = "\nTexInvert %s_invert {"%(name) str += "\n\ttexture=%s;"%(name) str += "\n}\n" return str ### BRDF def exportBRDFDiffuseSSS(vraymat): str = "\nBRDFDiffuse_forSSS BRDFDiffuse_forSSS_%s {"%(vraymat["name"]) str += "\n\tcolor=%s;"%(vraymat["color"]) if (vraymat["color_tex"] != ""): str += "\n\tcolor_tex=%s;"%(vraymat["color_tex"]) str += "\n\tcolor_tex_mult=%.3f;"%(vraymat["color_tex_mult"]) str += "\n\ttransparency=%s;"%(vraymat["sss_transparency"]) if (vraymat["sss_transparency_tex"] != ""): str += "\n\ttransparency_tex=%s;"%(vraymat["sss_transparency_tex"]) str += "\n\tback_color=%s;"%(vraymat["sss_back_color"]) str += "\n}\n" return str def exportBRDFSSS(vraymat): str = "\nBRDFSSS BRDFSSS_%s {"%(vraymat["name"]) str += "\n\tcolor=%s;"%(vraymat["color"]) if (vraymat["color_tex"] != ""): str += "\n\tcolor_tex=%s;"%(vraymat["color_tex"]) str += "\n\tcolor_tex_mult=%.3f;"%(vraymat["color_tex_mult"]) str += "\n\ttranslucency=%s;"%(vraymat["sss_color"]) if (vraymat["sss_color_tex"] != ""): str += "\n\ttranslucency_tex=%s;"%(vraymat["sss_color_tex"]) str += "\n\tglossiness=%.4f;"%(vraymat["sss_glossiness"]) if (vraymat["sss_glossiness_tex"] != ""): str += "\n\tglossiness_tex=%s;"%(vraymat["sss_glossiness_tex"]) str += "\n\tsubdivs=%d;"%(vraymat["sss_subdivs"]) str += "\n\tthickness=%.4f;"%(vraymat["sss_thickness"]) str += "\n\tscatter_coeff=%.4f;"%(vraymat["sss_scatter_coeff"]) str += "\n\tscatter_direction=%.4f;"%(vraymat["sss_scatter_direction"]) str += "\n}\n" return str def exportBRDFLight(vraymat): str = "\nBRDFLight BRDFLight_%s {"%(vraymat["name"]) str += "\n\tcolor=%s;"%(vraymat["emit"]) str += "\n\ttransparency=Color(0.0,0.0,0.0);" str += "\n}\n" return str def exportBRDFDiffuse(vraymat): str = "\nBRDFDiffuse BRDFDiffuse_%s {"%(vraymat["name"]) str += "\n\tcolor=%s;"%(vraymat["color"]) if (vraymat["color_tex"] != ""): str += "\n\tcolor_tex=%s;"%(vraymat["color_tex"]) str += "\n\tcolor_tex_mult=%.3f;"%(vraymat["color_tex_mult"]) str += "\n\ttransparency=%s;"%(vraymat["alpha"]) if (vraymat["alpha_tex"] != ""): str += "\n\ttransparency_tex=%s;"%(vraymat["alpha_tex"]) str += "\n\ttransparency_tex_mult=1;" str += "\n}\n" return str def exportBRDFBump(vraymat,base_brdf): str = "\nBRDFBump BRDFBump_%s {"%(vraymat["name"]) str += "\n\tbase_brdf=%s;"%(base_brdf) str += "\n\tbump_tex_color=%s;"%(vraymat["bump_tex"]) str += "\n\tbump_tex_mult=%.4f;"%(vraymat["bump_amount"]) str += "\n}\n" return str def exportBRDFMirror(vraymat): str = "\nBRDFMirror BRDFMirror_%s {"%(vraymat["name"]) if (vraymat["reflection_tex"] != ""): str += "\n\ttransparency_tex=%s;"%(vraymat["reflection_tex"]) str += "\n\ttransparency_tex_mult=%.2f;"%(vraymat["blendermat"].rayMirr) else: str += "\n\ttransparency=%s;"%(vraymat["reflection_transparensy"]) if ( vraymat["blendermat"].mode & Material.Modes['RAYMIRROR'] ): str += "\n\ttrace_reflections=1;" else: str += "\n\ttrace_reflections=0;" str += "\n}\n" return str def exportBRDFGlossy(vraymat): mat = vraymat["blendermat"] if (mat.specShader == 1): str = "\nBRDFPhong BRDFPhong_%s {"%(vraymat["name"]) elif (mat.specShader == 4): str = "\nBRDFWard BRDFWard_%s {"%(vraymat["name"]) else: str = "\nBRDFBlinn BRDFBlinn_%s {"%(vraymat["name"]) if (vraymat["reflection_tex"] != ""): invert_tex = exportTexInvert(vraymat["reflection_tex"]) str = invert_tex + str str += "\n\ttransparency=Color(1.0, 1.0, 1.0);" str += "\n\ttransparency_tex=%s_invert;"%(vraymat["reflection_tex"]) str += "\n\ttransparency_tex_mult=%.2f;"%(mat.rayMirr) else: str += "\n\ttransparency=%s;"%(vraymat["reflection_transparensy"]) if (vraymat["reflectionGlossiness_tex"] != ""): str += "\n\treflectionGlossiness_tex=%s;"%(vraymat["reflectionGlossiness_tex"]) str += "\n\treflectionGlossiness_tex_mult=%.2f;"%(mat.glossMir) str += "\n\thilightGlossiness_tex=%s;"%(vraymat["reflectionGlossiness_tex"]) str += "\n\thilightGlossiness_tex_mult=%.2f;"%(mat.glossMir) else: str += "\n\treflectionGlossiness=%.2f;"%(vraymat["reflectionGlossiness"]) str += "\n\thilightGlossiness=%.2f;"%(vraymat["reflectionGlossiness"]) str += "\n\tsubdivs=%i;"%(vraymat["reflection_subdivs"]) if ( mat.mode & Material.Modes['RAYMIRROR'] ): str += "\n\ttrace_reflections=1;" else: str += "\n\ttrace_reflections=0;" str += "\n}\n" return str def exportBRDFGlass(vraymat): str = "\nBRDFGlass BRDFGlass_%s {"%(vraymat["name"]) if (vraymat["alpha_tex"] != ""): str += "\n\tcolor_tex=%s;"%(vraymat["alpha_tex"]) str += "\n\tior=%.4f;"%(vraymat["IOR"]) str += "\n\taffect_shadows=1;" if ( vraymat["blendermat"].mode & Material.Modes['RAYTRANSP'] ): str += "\n\ttrace_refractions=1;" else: str += "\n\ttrace_refractions=0;" str += "\n}\n" return str def exportBRDFGlassGlossy(vraymat): str = "\nBRDFGlassGlossy BRDFGlassGlossy_%s {"%(vraymat["name"]) if (vraymat["alpha_tex"] != ""): str += "\n\tcolor_tex=%s;"%(vraymat["alpha_tex"]) str += "\n\tglossiness=%.2f;"%(vraymat["refractionGlossiness"]) str += "\n\tsubdivs=%i;"%(vraymat["refraction_subdivs"]) str += "\n\tior=%.3f;"%(vraymat["IOR"]) str += "\n\taffect_shadows=1;" str += "\n\ttrace_refractions=1;" str += "\n}\n" return str def exportBRDFLayered(vraymat): mat = vraymat["blendermat"] mat_name = vraymat["name"] str_brdf = "" str = "\nBRDFLayered BRDFLayered_%s {"%(mat_name) str += "\n\tbrdfs=List(" if (mat.enableSSS): str_brdf += exportBRDFSSS(vraymat) str_brdf += exportBRDFDiffuseSSS(vraymat) str += "\n\t\tBRDFSSS_%s,"%(mat_name) str += "\n\t\tBRDFDiffuse_forSSS_%s,"%(mat_name) else: if (mat.glossMir < 1.0 or vraymat["reflectionGlossiness_tex"] != ""): str_brdf += exportBRDFGlossy(vraymat) if (mat.specShader == 1): str += "\n\t\tBRDFPhong_%s,"%(mat_name) elif (mat.specShader == 4): str += "\n\t\tBRDFWard_%s,"%(mat_name) else: str += "\n\t\tBRDFBlinn_%s,"%(mat_name) else: str_brdf += exportBRDFMirror(vraymat) str += "\n\t\tBRDFMirror_%s,"%(mat_name) str_brdf += exportBRDFDiffuse(vraymat) str += "\n\t\tBRDFDiffuse_%s,"%(mat_name) if ( mat.alpha < 1.0 ): if ( mat.glossTra < 1.0 ): str_brdf += exportBRDFGlassGlossy(vraymat) str += "\n\t\tBRDFGlassGlossy_%s,"%(mat_name) else: str_brdf += exportBRDFGlass(vraymat) str += "\n\t\tBRDFGlass_%s,"%(mat_name) str = str[0:-1] str += "\n\t);" str += "\n}\n" return str_brdf + str def exportVolumeFog(name, mat): if ( mat.mode & Material.Modes['RAYTRANSP'] ): if ( mat.alpha < 1.0 ): if ( mat.mirR < 0.999 or mat.mirG < 0.999 or mat.mirB < 0.999 ): str = "\nVolumeFog VolumeFog_%s {"%(name) str += "\n\tcolor=Color(%.4f, %.4f, %.4f);"%(mat.mirR,mat.mirG,mat.mirB) str += "\n\tcolor_mult=%.4f;"%(mat.translucency) str += "\n\tior=%.4f;"%(mat.IOR) str += "\n}\n" return 1, str return 0, "" def exportMtlSingleBRDF(obj, mat): global exported_materials global exported_textures global exported_bitmaps str = "" str_twoside = "" str_textures = "" str_disp = "" str_brdf = "" fog = 0 displace = 0 obj_name = getName(obj) mat_name = getName(mat) if (mat_name[0:6] == "2SIDED"): twosided = 1 mtl_name = "Mtl2Sided_%s"%(mat_name) else: twosided = 0 mtl_name = "MtlSingleBRDF_%s"%(mat_name) ( fog, str_fog ) = exportVolumeFog(mtl_name, mat) if (mat_name not in exported_materials): exported_materials.append(mat_name) vraymat = {} vraymat["name"] = mat_name vraymat["mat_name"] = "MtlSingleBRDF_%s"%(mat_name) vraymat["mtl_name"] = mtl_name vraymat["color"] = "Color(%.4f, %.4f, %.4f)"%(mat.R,mat.G,mat.B) vraymat["color_tex"] = "" vraymat["color_tex_mult"] = 1.0 vraymat["bump_tex"] = "" vraymat["bump_amount"] = 0 vraymat["displace_tex"] = "" sp(mat, "vr_displace", 0) vraymat["reflection"] = "Color(%.4f, %.4f, %.4f)"%(mat.rayMirr,mat.rayMirr,mat.rayMirr) vraymat["reflection_transparensy"] = "Color(%.4f, %.4f, %.4f)"%(1-mat.rayMirr,1-mat.rayMirr,1-mat.rayMirr) vraymat["reflection_tex"] = "" vraymat["reflectionGlossiness"] = mat.glossMir vraymat["reflectionGlossiness_tex"] = "" vraymat["reflection_subdivs"] = mat.sampGlossMir vraymat["reflection_depth"] = mat.rayMirrDepth vraymat["refractionGlossiness"] = mat.glossTra vraymat["refractionGlossiness_tex"] = "" vraymat["refraction_subdivs"] = mat.sampGlossTra vraymat["refraction_depth"] = mat.transDepth vraymat["cutoff"] = 0.01 vraymat["sss_color"] = "Color(%.4f, %.4f, %.4f)"%(mat.sssR,mat.sssG,mat.sssB) vraymat["sss_color_tex"] = "" vraymat["sss_back_color"] = "Color(%.4f, %.4f, %.4f)"%(mat.sssR,mat.sssG,mat.sssB) vraymat["sss_subdivs"] = mat.sampGlossMir vraymat["sss_transparency"] = "Color(%.4f, %.4f, %.4f)"%(mat.sssRadiusRed,mat.sssRadiusGreen,mat.sssRadiusBlue) vraymat["sss_transparency_tex"] = "" vraymat["sss_glossiness"] = mat.glossMir vraymat["sss_glossiness_tex"] = "" vraymat["sss_thickness"] = mat.sssScale vraymat["sss_scatter_coeff"] = mat.sssColorBlend vraymat["sss_scatter_direction"] = mat.sssIOR vraymat["alpha"] = "Color(%.4f, %.4f, %.4f)"%(1-mat.alpha,1-mat.alpha,1-mat.alpha) vraymat["alpha_tex"] = "" vraymat["IOR"] = mat.IOR vraymat["emit"] = "Color(%.4f, %.4f, %.4f)"%(mat.R*100*mat.emit,mat.G*100*mat.emit,mat.B*100*mat.emit) vraymat["blendermat"] = mat for texture in mat.getTextures(): if (texture != None): if (texture.tex.type == Texture.Types.IMAGE): file = texture.tex.image.filename if ( os.path.exists(file) ): (filepath,filename) = os.path.split(file) str_tex = "" str_uvw = "" str_bitmap = "" bitmap_name = stripName(filename) texture_name = stripName(texture.tex.name) ( buffer_name, str_bitmap ) = exportBitmapBuffer(texture.tex) ( uvw_name, str_uvw ) = exportUVWGenChannel(texture.tex, texture_name) ( tex_name, str_tex ) = exportTexBitmap(texture_name, buffer_name, uvw_name) str_textures += str_bitmap + str_uvw + str_tex if (texture.mapto & Texture.MapTo['COL']): vraymat["color_tex"] = tex_name vraymat["color_tex_mult"] = texture.colfac if (texture.mapto & Texture.MapTo['NOR']): vraymat["bump_tex"] = tex_name vraymat["bump_amount"] = texture.norfac/100 if (texture.mapto & Texture.MapTo['RAYMIR']): vraymat["reflection_tex"] = tex_name if (texture.mapto & Texture.MapTo['SPEC']): vraymat["reflectionGlossiness_tex"] = tex_name if (texture.mapto & Texture.MapTo['ALPHA']): vraymat["alpha_tex"] = tex_name if (texture.mapto & Texture.MapTo['DISP']): sp(mat, "displace_tex", tex_name) sp(mat, "vr_displace", 1) sp(obj, "vr_displace_tex", tex_name) else: print "Missing texture: %s"%(file) str += "\nMtlSingleBRDF MtlSingleBRDF_%s {"%(mat_name) str += "\n\tdouble_sided=1;" if ( mat.enableSSS ): str_brdf += exportBRDFLayered(vraymat) str += "\n\tbrdf=BRDFLayered_%s;"%(mat_name) else: if ( mat.emit > 0 ): str_brdf += exportBRDFLight(vraymat) str += "\n\tbrdf=BRDFLight_%s;"%(mat_name) elif ( mat.rayMirr > 0 or vraymat["reflection_tex"] != "" or mat.alpha < 1.0 or vraymat["alpha_tex"] != "" or vraymat["reflectionGlossiness_tex"] != "" ): str_brdf += exportBRDFLayered(vraymat) if ( vraymat["bump_tex"] != "" ): str_brdf += exportBRDFBump(vraymat,"BRDFLayered_%s"%(mat_name)) str += "\n\tbrdf=BRDFBump_%s;"%(mat_name) else: str += "\n\tbrdf=BRDFLayered_%s;"%(mat_name) else: str_brdf += exportBRDFDiffuse(vraymat) if ( vraymat["bump_tex"] != "" ): str_brdf += exportBRDFBump(vraymat,"BRDFDiffuse_%s"%(mat_name)) str += "\n\tbrdf=BRDFBump_%s;"%(mat_name) else: str += "\n\tbrdf=BRDFDiffuse_%s;"%(mat_name) str += "\n}\n" if ( twosided ): str += "\nMtl2Sided Mtl2Sided_%s {"%(mat_name) str += "\n\tfront=MtlSingleBRDF_%s;"%(mat_name) str += "\n\tback=MtlSingleBRDF_%s;"%(mat_name) str += "\n\ttranslucency=Color(%.4f, %.4f, %.4f);"%(mat.specR,mat.specG,mat.specB) str += "\n\tforce_1sided=1;" str += "\n}\n" sp(mat, "vr_volume_fog", fog) str = str_textures + str_disp + "\n\n//\n// Material: %s\n//"%(vraymat["name"]) + str_brdf + str_fog + str + str_twoside return mtl_name, gp(mat, "vr_volume_fog", 0), gp(mat, "vr_displace", 0), str def exportMtlMulti(obj, mats): str = "" str_mat = "" str_id = "" obj_name = getName(obj) mtl_name = "MtlMulti_%s"%(obj_name) fog = 0 displace = 0 i = 0 for mat in mats: ( name, fog, curr_displace, str_single ) = exportMtlSingleBRDF(obj, mat) str += str_single if ( curr_displace == 1 ): displace = 1 str_id += "%i,"%(i) str_mat += "%s,"%(name) i += 1 str += "\n\n//\n// Materials on object: %s\n//"%(obj_name) str += "\nMtlMulti %s {"%(mtl_name) str += "\n\tids_list=List(%s);"%(str_id[0:-1]) str += "\n\tmtls_list=List(%s);"%(str_mat[0:-1]) str += "\n}\n" return mtl_name, fog, displace, str """ Export Material Return: material name (string), fog (bool), displace (bool), material (string) """ def exportMtl(obj): global exported_materials fog = 0 displace = 0 str = "" mats = obj.data.getMaterials() if ( len(mats) == 0 or getProp("vray_mtl_overall", 0)): if ("EMPTY_TMPMAT" not in exported_materials): exported_materials.append("EMPTY_TMPMAT") str += "\n\n//\n// TMP Material\n//" str += "\nBRDFDiffuse BRDFDiffuse_Temp {" str += "\n\tcolor=Color(0.80, 0.80, 0.80);" str += "\n\ttransparency=Color(0.00, 0.00, 0.00);" str += "\n}\n" str += "\nMtlSingleBRDF MtlSingleBRDF_Temp {" str += "\n\tbrdf=BRDFDiffuse_Temp;" str += "\n\tdouble_sided=1;" str += "\n}\n" name = "MtlSingleBRDF_Temp" elif ( len(mats) == 1 ): (name, fog, displace, str) = exportMtlSingleBRDF(obj, mats[0]) else: (name, fog, displace, str) = exportMtlMulti(obj, mats) return name, fog, displace, str def exportNodes(): mfile = open(matfile, 'w') mfile.write("// V-Ray/Blender: Materials\n") global exported_bitmaps global exported_textures global exported_materials exported_bitmaps = [] exported_textures = [] exported_materials = [] str = "" for obj in scene.objects: if ( (obj.Layers & scene.Layers) > 0 ): if ( not obj.restrictRender ): if ( obj.getType() == "Mesh" ): if ( gp(obj, "vr_mesh_valid", 1) ): obj_name = getName(obj) ( mat_name, fog, displace, mat_str ) = exportMtl(obj) mfile.write(mat_str) str += "\nNode Node_%s {"%(obj_name) if ( displace ): str += "\n\tgeometry = GeomDisplacedMesh_%s;"%(obj_name) mfile.write( exportGeomDisplacedMesh(obj) ) else: str += "\n\tgeometry = GeomStaticMesh_%s;"%(obj_name) str += "\n\tmaterial = %s;"%(mat_name) if ( fog ): str += "\n\tvolume = VolumeFog_%s;"%(mat_name) str += "\n\ttransform = %s;"%(transformMatrix(obj.getMatrix())) str += "\n}\n" mfile.close() return str ## ## CAMERA ## def exportCamera(): global ERROR str = "" camera = scene.objects.camera imageX = scene.getRenderingContext().imageSizeX() imageY = scene.getRenderingContext().imageSizeY() aspect = float(imageX)/float(imageY) fov = camera.data.angle if ( aspect < 1 ): fov = fov*aspect focal_length = gp(camera,"vray_camera_focal_length", 50.0) film_width = 2 * focal_length * math.tan( ( math.pi * fov ) / 360.0 ) if camera != None: str += "\nSettingsOutput {" str += "\n\timg_width=%d;"%(imageX) str += "\n\timg_height=%d;"%(imageY) str += "\n}\n" str += "\nRenderView renderView {" str += "\n\ttransform = %s;"%(transformMatrix(camera.getMatrix())) str += "\n\tfov = %.4f;"%(math.radians(fov)) if ( gp(camera,"vray_camera_type", 0) != 4 ): str += "\n\tclipping = 1;" str += "\n\tclipping_near = %.4f;"%(camera.data.clipStart) str += "\n\tclipping_far = %.4f;"%(camera.data.clipEnd) if ( gp(camera,"vray_camera_type", 0) == 6 ): str += "\n\torthographic = 1;" str += "\n}\n" if gp(camera,"vray_camera_physical", 0): str += "\nCameraPhysical physicalCamera {" str += "\n\ttype=%i;"%(gp(camera,"vray_camera_physical_type", 0)) str += "\n\tfilm_width=%.4f;"%(film_width) str += "\n\tfocal_length=%.4f;"%(focal_length) str += "\n\tzoom_factor=%.2f;"%(gp(camera,"vray_camera_zoom_factor", 1.0)) str += "\n\tdistortion=0.0;" str += "\n\tf_number=%.1f;"%(gp(camera,"vray_camera_f_number", 8.0)) str += "\n\tlens_shift=%.4f;"%(gp(camera,"vray_camera_lens_shift", 0.0)) str += "\n\tshutter_speed=%.1f;"%(gp(camera,"vray_camera_shutter_speed", 15.0)) str += "\n\tshutter_angle=%.1f;"%(gp(camera,"vray_camera_shutter_angle", 180.0)) str += "\n\tshutter_offset=%.1f;"%(gp(camera,"vray_camera_shutter_offset", 0.0)) str += "\n\tlatency=0.0;" str += "\n\tISO=%.1f;"%(gp(camera,"vray_camera_ISO", 50.0)) str += "\n\texposure=1;" str += "\n\tvignetting=%i;"%(gp(camera,"vray_camera_vignetting", 1)) str += "\n\tuse_dof=%i;"%(gp(camera,"vray_camera_phys_use_dof",0)) if gp(camera,"vray_camera_phys_use_dof",0) and gp(camera,"vray_camera_phys_bokeh",0): str += "\n\tspecify_focus=1;" str += "\n\tfocus_distance=%.2f;"%(camera.data.dofDist) str += "\n\tblades_enable=%i;"%(gp(camera,"vray_camera_blades_enable",0)) str += "\n\tblades_num=%i;"%(gp(camera,"vray_camera_blades_num", 5)) str += "\n\tblades_rotation=%.2f;"%(gp(camera,"vray_camera_blades_rotation", 0)) str += "\n\tcenter_bias=%.2f;"%(gp(camera,"vray_camera_center_bias", 0.0)) str += "\n\tanisotropy=%.2f;"%(gp(camera,"vray_camera_anisotropy", 0.0)) str += "\n\tuse_moblur=%i;"%(gp(camera,"vray_camera_phys_use_moblur",0)) str += "\n\tsubdivs=%i;"%(gp(camera,"vray_camera_phys_subdivs", 6)) str += "\n}\n" else: str += "\nSettingsCamera {" str += "\n\ttype=%i;"%(gp(camera,"vray_camera_type", 0)) str += "\n\tfov=%.4f;"%(math.radians(fov)) if gp(camera,"vray_camera_type", 0) == 3: str += "\n\theight=%.2f;"%(gp(camera,"vray_camera_height", 0.4)) if gp(camera,"vray_camera_type", 0) == 5: str += "\n\tauto_fit=%i;"%(gp(camera,"vray_camera_auto_fit", 1)) str += "\n\tdist=%.2f;"%(gp(camera,"vray_camera_dist", 2.0)) str += "\n\tcurve=%.2f;"%(gp(camera,"vray_camera_curve", 1.0)) str += "\n}\n" if gp(camera,"vray_camera_phys_use_dof",0): str += "\nSettingsCameraDof {" str += "\n\ton=%i;"%(gp(camera,"vray_camera_phys_use_dof", 0)) str += "\n\tfocal_dist=%.2f;"%(camera.data.dofDist) str += "\n\taperture=5.0;" str += "\n\tsubdivs=%i;"%(gp(camera,"vray_camera_phys_subdivs", 6)) if gp(camera,"vray_camera_phys_use_dof",0) and gp(camera,"vray_camera_phys_bokeh",0): str += "\n\tcenter_bias=%.2f;"%(gp(camera,"vray_camera_center_bias", 0.0)) str += "\n\tanisotropy=%.2f;"%(gp(camera,"vray_camera_anisotropy", 0.0)) str += "\n\tsides_on=%i;"%(gp(camera,"vray_camera_blades_enable",0)) str += "\n\tsides_num=%i;"%(gp(camera,"vray_camera_blades_num", 5)) str += "\n\trotation=%.2f;"%(gp(camera,"vray_camera_blades_rotation", 0)) str += "\n}\n" else: ERROR = 1 print "No camera!" return str ## ## LIGHTS ## def setIES(obj, name): return lambda val: setObjProperty(obj, name, val) def LightDome(light): filename = "" str_tex = "" str_uvw = "" str_bitmap = "" try: texture = Texture.Get('IBL') (filepath,filename) = os.path.split(texture.image.filename) filename = stripName(filename) bitmap_name = stripName(filename) texture_name = stripName(texture.name) ( buffer_name, str_bitmap ) = exportBitmapBuffer(texture) ( uvw_name, str_uvw ) = exportUVWGenChannel(texture, texture_name) ( tex_name, str_tex ) = exportTexBitmap(texture_name, buffer_name, uvw_name) except: print "Dome light in texture mode, but no texture with name \"IBL\"." str = "\nLightDome LightDome_%s {"%(getName(light)) str += "\n\tenabled=1;" if ( filename != "" ): str += "\n\tuse_dome_tex=%d;"%(gp(light,"vray_light_use_dome_tex", 0)) str += "\n\tdome_tex=%s;"%(tex_name) #str += "\n\tdome_targetRadius: float = 100 #str += "\n\tdome_emitRadius: float = 150 #str += "\n\ttex_resolution: integer = 512 #str += "\n\ttex_adaptive: float = 1 else: str += "\n\tuse_dome_tex=0;" str += "\n\tdome_spherical=%d;"%(gp(light,"vray_light_dome_spherifical", 0)) str += "\n\tcolor=Color(%.4f, %.4f, %.4f);"%(light.data.R,light.data.G,light.data.B) str += "\n\tsubdivs=%i;"%(gp(light,"vray_light_subdivs", 8)) str += "\n\tcausticSubdivs=%i;"%(gp(light,"vray_light_caustics_subdivs", 1000)) str += "\n\tstoreWithIrradianceMap=%i;"%(gp(light,"vray_light_store", 0)) str += "\n\tinvisible=%i;"%(gp(light,"vray_light_invisible", 0)) str += "\n\tunits=%i;"%(gp(light,"vray_light_units", 0)) str += "\n\tintensity=%.4f;"%(gp(light,"vray_light_intensity", 30.0)) str += "\n\ttransform=%s;"%(transformMatrix(light.getMatrix())) str += "\n}\n" return str_bitmap + str_uvw + str_tex + str def LightRectangle(light): str = "\nLightRectangle LightRectangle_%s {"%(getName(light)) str += "\n\ttransform=%s;"%(transformMatrix(light.getMatrix())) str += "\n\tu_size=%.2f;"%(light.data.areaSizeX/2) if (light.data.areaSizeY == light.data.areaSizeX): str += "\n\tv_size=%.2f;"%(light.data.areaSizeX/2) else: str += "\n\tv_size=%.2f;"%(light.data.areaSizeY/2) if ( gp(light,"vray_light_portal", 0) ): str += "\n\tlightPortal=1;" str += "\n\tinvisible=1;" else: str += "\n\tcolor=Color(%.4f, %.4f, %.4f);"%(light.data.R,light.data.G,light.data.B) str += "\n\tstoreWithIrradianceMap=%i;"%(gp(light,"vray_light_store", 0)) str += "\n\tnoDecay=0;" str += "\n\tinvisible=%i;"%(gp(light,"vray_light_invisible", 0)) str += "\n\tunits=%i;"%(gp(light,"vray_light_units", 0)) str += "\n\tintensity=%.4f;"%(gp(light,"vray_light_intensity", 30.0)) str += "\n\tsubdivs=%i;"%(gp(light,"vray_light_subdivs", 8)) str += "\n\tcausticSubdivs=%i;"%(gp(light,"vray_light_caustics_subdivs", 1000)) str += "\n}\n" return str def LightSphere(light): str = "\nLightSphere LightSphere_%s {"%(getName(light)) str += "\n\tenabled=1;" str += "\n\tunits=%i;"%(gp(light,"vray_light_units", 0)) str += "\n\tintensity=%.4f;"%(gp(light,"vray_light_intensity", 30.0)) str += "\n\tcolor=Color(%.4f, %.4f, %.4f);"%(light.data.R,light.data.G,light.data.B) str += "\n\tinvisible=%i;"%(gp(light,"vray_light_invisible", 0)) str += "\n\tsubdivs=%i;"%(gp(light,"vray_light_subdivs", 8)) str += "\n\tcausticSubdivs=%i;"%(gp(light,"vray_light_caustics_subdivs", 1000)) str += "\n\tshadows=1;" str += "\n\tradius=%.4f;"%(gp(light,"vray_light_radius", 0.01)) str += "\n\ttransform=%s;"%(transformMatrix(light.getMatrix())) str += "\n}\n" return str def LightSpot(light): str = "\nLightSpot LightSpot_%s {"%(getName(light)) str += "\n\tenabled=1;" str += "\n\tunits=%i;"%(gp(light,"vray_light_units", 0)) str += "\n\tintensity=%.4f;"%(gp(light,"vray_light_intensity", 30.0)) str += "\n\ttransform=%s;"%(transformMatrix(light.getMatrix())) str += "\n\tcolor=Color(%.4f, %.4f, %.4f);"%(light.data.R,light.data.G,light.data.B) str += "\n\tshadows=1;" str += "\n\tcutoffThreshold=0.001;" str += "\n\tshadowSubdivs=%i;"%(gp(light,"vray_light_subdivs", 8)) str += "\n\tconeAngle=%.4f;"%(math.degrees(light.data.spotSize)) str += "\n\tcausticSubdivs=%i;"%(gp(light,"vray_light_caustics_subdivs", 1000)) str += "\n}\n" return str def LightIES(light): str = "\nLightIES LightIES_%s {"%(getName(light)) str += "\n\tenabled=1;" str += "\n\ttransform=%s;"%(transformMatrix(light.getMatrix())) str += "\n\tcolor=Color(%.4f, %.4f, %.4f);"%(light.data.R,light.data.G,light.data.B) str += "\n\tshadows=1;" str += "\n\tcutoffThreshold=0.001;" str += "\n\tshadowSubdivs=%i;"%(gp(light,"vray_light_subdivs", 8)) str += "\n\tcausticSubdivs=%i;"%(gp(light,"vray_light_caustics_subdivs", 1000)) str += "\n\ties_file=\"%s\";"%(gp(light,"vray_light_IES", 0)) str += "\n\tfilter_color=Color(1, 1, 1);" str += "\n\tsoft_shadows=%i;"%(gp(light,"vray_light_IES_soft_shadows", 0)) str += "\n}\n" return str def LightDirect(light): str = "" if ( gp(light,"vray_light_sun",0) ): str += "\nSunLight VRaySun {" str += "\n\tenabled=1;" str += "\n\ttransform = %s;"%(transformMatrix(light.getMatrix())) str += "\n\tshadowBias=%.4f;"%(getProp("vray_sunsky_shadow_bias", 0.002)) str += "\n\tturbidity=%.2f;"%(getProp("vray_sunsky_turbidity", 3.0)) str += "\n\tozone=%.2f;"%(getProp("vray_sunsky_ozone", 0.35)) str += "\n\tintensity_multiplier=%.2f;"%(getProp("vray_sunsky_intensity", 1.0)) str += "\n\tsize_multiplier=%.2f;"%(getProp("vray_sunsky_size_multiplier", 1.0)) str += "\n\tinvisible=%i;"%(getProp("vray_sunsky_invisible",0)) str += "\n\tshadow_subdivs=%i;"%(getProp("vray_sunsky_shadow_subdivs", 3)) str += "\n\tphoton_radius=%.2f;"%(getProp("vray_sunsky_photon_emit_radius", 50.0)) str += "\n\tphotonSubdivs=500;" str += "\n\tcausticSubdivs=%i;"%(gp(light,"vray_light_caustics_subdivs", 1000)) str += "\n\tup_vector=Vector(0,0,1);" str += "\n}\n" else: str += "\nLightDirect LightDirect_%s {"%(getName(light)) str += "\n\tenabled=1;" str += "\n\ttransform=%s;"%(transformMatrix(light.getMatrix())) str += "\n\tcolor=Color(%.4f, %.4f, %.4f);"%(light.data.R,light.data.G,light.data.B) str += "\n\tshadows=1;" #str += "\n\tshadowRadius=0; str += "\n\tshadowSubdivs=%i;"%(gp(light,"vray_light_subdivs", 8)) str += "\n\tphotonSubdivs=500;" str += "\n\tcausticSubdivs=%i;"%(gp(light,"vray_light_caustics_subdivs", 1000)) str += "\n\tcutoffThreshold=0.001;" str += "\n\tunits=%i;"%(gp(light,"vray_light_units", 0)) str += "\n\tintensity=%.4f;"%(gp(light,"vray_light_intensity", 30.0)) str += "\n\tbeamRadius=%.4f;"%(gp(light,"vray_light_beamradius", 30.0)) # 0.0 if the light has no beam radius str += "\n}\n" return str def exportLights(): str = "" for obj in scene.objects: if ( (obj.Layers & scene.Layers) > 0 ): if (obj.getType() == "Lamp"): if (obj.restrictRender == 0): # Lamp if obj.data.getType() == 0: str += LightSphere(obj) # Direct (Sun) if obj.data.getType() == 1: str += LightDirect(obj) # Spot if obj.data.getType() == 2: if (gp(obj,"vray_light_isIES",0)): str += LightIES(obj) else: str += LightSpot(obj) # Hemi -> Dome if obj.data.getType() == 3: str += LightDome(obj) # Area if obj.data.getType() == 4: str += LightRectangle(obj) return str ## ## SETTINGS ## def exportEnvBitmap(name): bitmap = Texture.Get(name) if ( type(bitmap) != 'NoneType' ): ( bitmap_name, str ) = exportBitmapBuffer(bitmap) return 1, bitmap_name, str return 0, "", "" def exportEnvironment(): str = "\nSettingsEnvironment {" # Background (ENV_BG) bg_color = Blender.World.Get()[0].getHor() str += "\n\tbg_color=Color(%.4f, %.4f, %.4f);"%(bg_color[0],bg_color[1],bg_color[2]) if ( getProp("vray_env_bg", 0) ): if getProp("vray_env_bg_sky",0): str += "\n\tbg_tex=VRaySky;" str = exportTexSky() + str else: bg_texture_name = "ENV_BG" ( bg_tex, bg_bitmap_name, bg_bitmap_str ) = exportEnvBitmap(bg_texture_name) if ( bg_tex ): ( bg_uvw_name, bg_uvw_str ) = exportUVWGenEnvironment( bg_texture_name, getProp("vray_env_bg_type",0) ) ( bg_tex_name, bg_tex_str ) = exportTexBitmap( bg_texture_name, bg_bitmap_name, bg_uvw_name ) str += "\n\tbg_tex=%s;"%(bg_tex_name) str += "\n\tbg_tex_mult=%.4f;"%(getProp("vray_env_bg_mult", 1.0)) str = bg_bitmap_str + bg_uvw_str + bg_tex_str + str # GI Override (ENV_GI) if ( getProp("vray_envover_gi", 0) ): gi_color = Blender.World.Get()[0].getZen() str += "\n\tgi_color=Color(%.4f, %.4f, %.4f);"%(gi_color[0],gi_color[1],gi_color[2]) if getProp("vray_envover_gi_sky",0): str += "\n\tgi_tex=VRaySky;" str = exportTexSky() + str else: gi_texture_name = "ENV_GI" ( gi_tex, gi_bitmap_name, gi_bitmap_str ) = exportEnvBitmap(gi_texture_name) if ( gi_tex ): ( gi_uvw_name, gi_uvw_str ) = exportUVWGenEnvironment( gi_texture_name, getProp("vray_envover_gi_type",0) ) ( gi_tex_name, gi_tex_str ) = exportTexBitmap( gi_texture_name, gi_bitmap_name, gi_uvw_name ) str += "\n\tgi_tex=%s;"%(gi_tex_name) str += "\n\tgi_tex_mult=%.4f;"%(getProp("vray_envover_gi_mult", 1.0)) str = gi_bitmap_str + gi_uvw_str + gi_tex_str + str # Rerlect Override (ENV_REFLECT) if ( getProp("vray_envover_reflect", 0) ): rr_color = Blender.World.Get()[0].getAmb() str += "\n\treflect_color=Color(%.4f, %.4f, %.4f);"%(rr_color[0],rr_color[1],rr_color[2]) if getProp("vray_envover_reflect_sky",0): str += "\n\treflect_tex=VRaySky;" str = exportTexSky() + str else: reflect_texture_name = "ENV_REFLECT" ( reflect_tex, reflect_bitmap_name, reflect_bitmap_str ) = exportEnvBitmap(reflect_texture_name) if ( reflect_tex ): ( reflect_uvw_name, reflect_uvw_str ) = exportUVWGenEnvironment( reflect_texture_name, getProp("vray_envover_reflect_type",0) ) ( reflect_tex_name, reflect_tex_str ) = exportTexBitmap( reflect_texture_name, reflect_bitmap_name, reflect_uvw_name ) str += "\n\treflect_tex=%s;"%(reflect_tex_name) str += "\n\treflect_tex_mult=%.4f;"%(getProp("vray_envover_reflect_mult", 1.0)) str = reflect_bitmap_str + reflect_uvw_str + reflect_tex_str + str # Refract Override (ENV_REFRACT) if ( getProp("vray_envover_refract", 0) ): str += "\n\trefract_color=Color(%.4f, %.4f, %.4f);"%(bg_color[0],bg_color[1],bg_color[2]) if getProp("vray_envover_refract_sky",0): str += "\n\trefract_tex=VRaySky;" str = exportTexSky() + str else: refract_texture_name = "ENV_REFRACT" ( refract_tex, refract_bitmap_name, refract_bitmap_str ) = exportEnvBitmap(refract_texture_name) if ( refract_tex ): ( refract_uvw_name, refract_uvw_str ) = exportUVWGenEnvironment( refract_texture_name, getProp("vray_env_refract_type",0) ) ( refract_tex_name, refract_tex_str ) = exportTexBitmap( refract_texture_name, refract_bitmap_name, refract_uvw_name ) str += "\n\trefract_tex=%s;"%(refract_tex_name) str += "\n\trefract_tex_mult=%.4f;"%(getProp("vray_env_refract_mult", 1.0)) str = refract_bitmap_str + refract_uvw_str + refract_tex_str + str str += "\n}\n" return str def settingsUnitsInfo(): str = "\nSettingsUnitsInfo {" str += "\n\tmeters_scale=%f;"%(getProp("vray_metric_scale",1.0)) str += "\n\tphotometric_scale=%.4f;"%(getProp("vray_photometric_scale",0.002)) str += "\n}\n" return str def settingsISampler(): str = "\nSettingsImageSampler {" str += "\n\ttype=%i;"%(getProp("vray_imageSamplerType",1)) if getProperty("vray_imageSamplerType") == 0: str += "\n\tfixed_subdivs=%i;"%(getProp("vray_FixedRate",1)) if getProperty("vray_imageSamplerType") == 1: str += "\n\tdmc_minSubdivs=%i;"%(getProp("vray_dmc_minSubdivs",1)) str += "\n\tdmc_maxSubdivs=%i;"%(getProp("vray_dmc_maxSubdivs",4)) str += "\n\tdmc_threshold=%.4f;"%(getProp("vray_dmc_threshold", 0.01)) if getProperty("vray_imageSamplerType") == 2: str += "\n\tsubdivision_minRate=%i;"%(getProp("vray_subdivision_minRate",-1)) str += "\n\tsubdivision_maxRate=%i;"%(getProp("vray_subdivision_maxRate",2)) str += "\n\tsubdivision_threshold=%.2f;"%(getProp("vray_subdivision_threshold", 0.15)) #str += "\n\tsubdivision_jitter=1;" str += "\n\tsubdivision_edges=%i;"%(getProp("vray_subdivision_edges",0)) str += "\n\tsubdivision_normals=%i;"%(getProp("vray_subdivision_normals",0)) str += "\n\tsubdivision_normals_threshold=%.4f;"%(getProp("vray_subdivision_normals_threshold", 0.1)) str += "\n}\n" type = getProp("vray_aa_filter_type",0) if type != 0: if type == 1: str += "\nFilterArea {" if type == 2: str += "\nFilterBox {" if type == 3: str += "\nFilterTriangle {" if type == 4: str += "\nFilterLanczos {" if type == 5: str += "\nFilterSinc {" if type == 6: str += "\nFilterGaussian {" str += "\n\tsize=%.2f;"%(getProp("vray_aa_filter_size", 1.5)) str += "\n}\n" return str def settingsColorMapping(): str = "\nSettingsColorMapping {" str += "\n\ttype=%s;"%(getProp("vray_cm_type",0)) if getProperty("vray_cm_type") == 6: str += "\n\tbright_mult=%.1f;"%(getProp("vray_dark_mult",1.0)) str += "\n\tdark_mult=%.1f;"%(getProp("vray_bright_mult",1.0)) else: str += "\n\tbright_mult=%.1f;"%(getProp("vray_bright_mult",1.0)) str += "\n\tdark_mult=%.1f;"%(getProp("vray_dark_mult",1.0)) str += "\n\tgamma=%.4f;"%(getProp("vray_gamma",2.2)) str += "\n\tsubpixel_mapping=%i;"%(getProp("vray_subpixel_mapping",0)) str += "\n\tclamp_output=%i;"%(getProp("vray_clamp_output",1)) str += "\n\tadaptation_only=%i;"%(getProp("vray_adaptation_only",0)) str += "\n}\n" return str def settingsGIIrrmap(): str = "\nSettingsIrradianceMap {" str += "\n\tmin_rate=%i;"%(getProp("vray_im_min_rate",-3)) str += "\n\tmax_rate=%i;"%(getProp("vray_im_max_rate",0)) str += "\n\tsubdivs=%i;"%(getProp("vray_im_subdivs",50)) str += "\n\tinterp_samples=%i;"%(getProp("vray_im_interp_samples",20)) str += "\n\tcalc_interp_samples=%i;"%(getProp("vray_im_calc_interp_samples",10)) str += "\n\tcolor_threshold=%.4f;"%(getProp("vray_im_color_threshold",0.3)) str += "\n\tnormal_threshold=%.4f;"%(getProp("vray_im_normal_threshold",0.1)) str += "\n\tdistance_threshold=%.4f;"%(getProp("vray_im_distance_threshold",0.1)) str += "\n\tdetail_enhancement=%i;"%(getProp("vray_im_detail_enhancement",0)) if getProperty("vray_im_detail_enhancement"): str += "\n\tdetail_radius=%.4f;"%(getProp("vray_im_detail_radius", 0.06)) str += "\n\tdetail_subdivs_mult=%.4f;"%(getProp("vray_im_detail_subdivs_mult", 0.3)) str += "\n\tdetail_scale=%i;"%(getProp("vray_im_detail_scale",0)) str += "\n\tinterpolation_mode=%i;"%(getProp("vray_im_interpolationType",1)) str += "\n\tlookup_mode=%i;"%(getProp("vray_im_lookupType",2)) str += "\n\tshow_calc_phase=%i;"%(getProp("vray_im_show_calc_phase",0)) str += "\n\tshow_direct_light=%i;"%(getProp("vray_im_show_direct_light",0)) str += "\n\tshow_samples=%i;"%(getProp("vray_im_show_samples",0)) str += "\n\tmultipass=%i;"%(getProp("vray_im_multipass",1)) str += "\n\tcheck_sample_visibility=%i;"%(getProp("vray_im_check_sample_visibility",0)) str += "\n\trandomize_samples=%i;"%(getProp("vray_im_randomize_samples",1)) str += "\n\tmode=0;" str += "\n\tdont_delete=0;" str += "\n}\n" return str def settingsGIBruteForce(): str = "\nSettingsDMCGI {" str += "\n\tsubdivs=%i;"%(getProp("vray_dmcgi_subdivs",8)) str += "\n\tdepth=%i;"%(getProp("vray_dmcgi_depth",3)) str += "\n}\n" return str def settingsGILightCache(): str = "\nSettingsLightCache {" str += "\n\tsubdivs=%i;"%(getProp("vray_lc_subdivs",1000)) str += "\n\tsample_size=%.4f;"%(getProp("vray_lc_sample_size",0.02)) str += "\n\tnum_passes=%i;"%(getProp("vray_lc_num_passes",4)) str += "\n\tfilter_type=%i;"%(getProp("vray_lc_filter_type",0)) if (getProperty("vray_lc_filter_type") != 0): str += "\n\tfilter_samples=%i;"%(getProp("vray_lc_filter_samples",10)) str += "\n\tfilter_size=%.4f;"%(getProp("vray_lc_filter_size",0.02)) str += "\n\tprefilter=%i;"%(getProp("vray_lc_prefilter",1)) if (getProperty("vray_lc_prefilter") == 1): str += "\n\tprefilter_samples=%i;"%(getProp("vray_lc_prefilter_samples",100)) str += "\n\tshow_calc_phase=%i;"%(getProp("vray_lc_show_calc_phase",1)) str += "\n\tstore_direct_light=%i;"%(getProp("vray_lc_store_direct_light",1)) str += "\n\tuse_for_glossy_rays=%i;"%(getProp("vray_lc_use_for_glossy_rays",1)) str += "\n\tworld_scale=%i;"%(getProp("vray_lc_scale",0)) str += "\n\tadaptive_sampling=%i;"%(getProp("vray_lc_adaptive_sampling",0)) str += "\n\tmode=0;" str += "\n\tdont_delete=0;" str += "\n}\n" return str def settingsGIPhotonMap(): str = "\nSettingsPhotonMap {" str += "\n\tbounces=%i;"%(getProp("vray_pm_bounces", 10)) str += "\n\tsearch_distance=%.2f;"%(getProp("vray_pm_search_distance", 20.0)) str += "\n\tauto_search_distance=%i;"%(getProp("vray_pm_auto_search_distance",0)) str += "\n\tmax_photons=%i;"%(getProp("vray_pm_max_photons", 30)) str += "\n\tprefilter=%i;"%(getProp("vray_pm_prefilter",0)) str += "\n\tprefilter_samples=%i;"%(getProp("vray_pm_prefilter_samples", 10)) str += "\n\tmultiplier=%.2f;"%(getProp("vray_pm_multiplier", 1.0)) str += "\n\tconvex_hull_estimate=%i;"%(getProp("vray_pm_convex_hull_estimate",0)) str += "\n\tstore_direct_light=%i;"%(getProp("vray_pm_store_direct_light",1)) str += "\n\tretrace_corners=%.2f;"%(getProp("vray_pm_retrace_corners", 0.0)) str += "\n\tretrace_bounces=%i;"%(getProp("vray_pm_retrace_bounces", 10)) str += "\n\tmax_density=%.2f;"%(getProp("vray_pm_max_density", 0.0)) str += "\n\tdont_delete=0;" str += "\n}\n" return str def settingsGI(): str = "\nSettingsGI {" str += "\n\ton=%s;"%(getProp("vray_gi_on",0)) if getProperty("vray_gi_on") == 1: str += "\n\tprimary_engine=%s;"%(getProp("vray_primary_engine",0)) str += "\n\tprimary_multiplier=%s;"%(getProp("vray_primary_multiplier",1.0)) str += "\n\tsecondary_engine=%s;"%(getProp("vray_secondary_engine",3)) str += "\n\tsecondary_multiplier=%s;"%(getProp("vray_secondary_multiplier",1.0)) str += "\n\treflect_caustics=%s;"%(getProp("vray_reflect_caustics",0)) str += "\n\trefract_caustics=%s;"%(getProp("vray_refract_caustics",1)) str += "\n\tsaturation=%.4f;"%(getProp("vray_saturation",1.0)) str += "\n\tcontrast=%.4f;"%(getProp("vray_contrast",1.0)) str += "\n\tcontrast_base=%.4f;"%(getProp("vray_contrast_base",0.5)) str += "\n}\n" if getProperty("vray_gi_on") == 1: if getProperty("vray_primary_engine") == 0: str += settingsGIIrrmap() if getProperty("vray_primary_engine") == 1: str += settingsGIPhotonMap() if getProperty("vray_primary_engine") == 2: str += settingsGIBruteForce() if getProperty("vray_primary_engine") == 3: str += settingsGILightCache() if getProperty("vray_secondary_engine") == 1: str += settingsGIPhotonMap() if getProperty("vray_secondary_engine") == 2: str += settingsGIBruteForce() if getProperty("vray_secondary_engine") == 3: str += settingsGILightCache() return str def settingsDMCSampler(): str = "\nSettingsDMCSampler {" str += "\n\ttime_dependent=%s;"%(getProp("vray_time_dependent",1)) str += "\n\tadaptive_amount=%.4f;"%(getProp("vray_adaptive_amount",0.85)) str += "\n\tadaptive_threshold=%.4f;"%(getProp("vray_adaptive_threshold",0.01)) str += "\n\tadaptive_min_samples=%s;"%(getProp("vray_adaptive_min_samples",8)) str += "\n\tsubdivs_mult=%.4f;"%(getProp("vray_subdivs_mult",1.0)) str += "\n}\n" return str def settingsCaustics(): str = "\nSettingsCaustics {" if ( getProp("vray_caustics_on",0) ): str += "\n\ton=1;" str += "\n\tmax_photons=%i;"%(getProp("vray_caustics_max_photons", 30)) str += "\n\tsearch_distance=%.4f;"%(getProp("vray_caustics_search_distance", 0.05)) str += "\n\tmax_density=%.2f;"%(getProp("vray_caustics_max_density", 0.0)) str += "\n\tmultiplier=%.4f;"%(getProp("vray_caustics_multiplier", 1.0)) str += "\n\tmode=0;" else: str += "\n\ton=0;" str += "\n}\n" return str def settingsSystem(): str = "\nSettingsRaycaster {" str += "\n\tmaxLevels=%s;"%(getProp("vray_maxLevels",60)) str += "\n\tminLeafSize=%s;"%(getProp("vray_minLeafSize",0.0)) str += "\n\tfaceLevelCoef=%s;"%(getProp("vray_faceLevelCoef",2.0)) str += "\n\tdynMemLimit=%s;"%(getProp("vray_dynMemLimit",500)) str += "\n\toptLevel=0;" str += "\n}\n" str += "\nSettingsRegionsGenerator {" str += "\n\txc=%s;"%(getProp("vray_xc",32)) str += "\n\tyc=%s;"%(getProp("vray_xc",32)) str += "\n\txymeans=0;" str += "\n\tseqtype=4;" str += "\n\treverse=0;" str += "\n}\n" str += "\nSettingsOptions {" str += "\n\tgeom_backfaceCull=%i;"%(getProp("vray_geom_backfaceCull",0)) str += "\n\tgeom_displacement=%i;"%(getProp("vray_geom_displacement",1)) str += "\n\tgeom_doHidden=%i;"%(getProp("vray_geom_doHidden",0)) str += "\n\tlight_doLights=%i;"%(getProp("vray_light_doLights",1)) str += "\n\tlight_doDefaultLights=%i;"%(getProp("vray_light_doDefaultLights",0)) str += "\n\tlight_doHiddenLights=%i;"%(getProp("vray_light_doHiddenLights",0)) str += "\n\tlight_doShadows=%i;"%(getProp("vray_light_doShadows",1)) str += "\n\tmtl_reflectionRefraction=%i;"%(getProp("vray_mtl_reflectionRefraction",1)) str += "\n\tmtl_glossy=%i;"%(getProp("vray_mtl_glossy",1)) str += "\n\tmtl_limitDepth=%i;"%(getProp("vray_mtl_limitDepth",0)) str += "\n\tmtl_maxDepth=%i;"%(getProp("vray_mtl_maxDepth", 5)) #str += "\n\tmtl_override_on=;"%() #str += "\n\tmtl_doMaps=;"%() #str += "\n\tmtl_filterMaps=;"%() str += "\n\tmtl_transpMaxLevels=%i;"%(getProp("vray_mtl_transpMaxLevels", 50)) str += "\n\tmtl_transpCutoff=%.4f;"%(getProp("vray_mtl_transpCutoff", 0.001)) #str += "\n\tray_bias=%.4f;"%(getProp("vray_ray_bias", 0.0)) str += "\n}\n" str += "\nSettingsDefaultDisplacement {" str += "\n\toverride_on=1;" str += "\n\tedgeLength=%.4f;"%(getProp("vray_displace_edgeLength",4.0)) str += "\n\tmaxSubdivs=%d;"%(getProp("vray_displace_maxSubdivs",256)) str += "\n\tamount=%.4f;"%(getProp("vray_displace_amount",0.001)) str += "\n\tviewDependent=%d;"%(getProp("vray_displace_viewDependent",1)) str += "\n\ttightBounds=%d;"%(getProp("vray_displace_tightBounds",1)) str += "\n\trelative=%d;"%(getProp("vray_displace_relative",0)) str += "\n}\n" return str def settingsChannels(): str = "" if getProp("vray_renderchannel_velocity",0) == 1: str += "\nRenderChannelVelocity {" str += "\n\tname=\"Velocity\";" str += "\n}\n" if getProp("vray_renderchannel_renderid",0) == 1: str += "\nRenderChannelRenderID {" str += "\n\tname=\"RenderID\";" str += "\n}\n" if getProp("vray_renderchannel_normals",0) == 1: str += "\nRenderChannelNormals {" str += "\n\tname=\"Normals\";" str += "\n}\n" if getProp("vray_renderchannel_zdepth",0) == 1: str += "\nRenderChannelZDepth {" str += "\n\tname=\"ZDepth\";" str += "\n\tdepth_black=%.4f;"%(getProp("vray_zdepth_near", 0.0)) str += "\n\tdepth_white=%.4f;"%(getProp("vray_zdepth_far", 10.0)) str += "\n}\n" if getProp("vray_renderchannel_color",0) == 1: str += "\nRenderChannelColor {" str += "\n\tname=\"ColorChannel\";" str += "\n}\n" return str def renderBakeView(): str = "\nUVWGenObject BakeView_uvwgen {" str += "\n\tuvw_transform=Transform(" str += "\n\t\tMatrix(" str += "\n\t\tVector(1.0,0.0,0.0)," str += "\n\t\tVector(0.0,1.0,0.0)," str += "\n\t\tVector(0.0,0.0,1.0)" str += "\n\t\t)," str += "\n\t\tVector(0.0,0.0,0.0)" str += "\n\t);" str += "\n}\n" str += "\nBakeView {" str += "\n\tbake_node=node_%s;"%(getName( Blender.Object.GetSelected()[0] )) str += "\n\tbake_uvwgen=BakeView_uvwgen;" str += "\n\tdilation=2;" str += "\n\tflip_derivs=0;" str += "\n}\n" return str ## ## CREATE FILES & LAUNCH RENDER ## def updateRegistry(): globals = {} globals["binary"] = getProperty("vray_binary") globals["wine"] = getProperty("vray_wine") Blender.Registry.SetKey('VRay', globals, True) vray_globals = Blender.Registry.GetKey('VRay', True) if vray_globals: try: setProperty("vray_binary", vray_globals["binary"]) setProperty("vray_wine", vray_globals["wine"]) except: updateRegistry() def getFilenames(): global scenefile global geomfile global matfile global scene scene = Scene.GetCurrent() (filepath,filename) = os.path.split(Blender.Get("filename")) if (filename == ""): filename = "default" else: filename = filename[0:-6] basename = os.path.join(filepath,filename) scenefile = basename + ".vrscene" geomfile = basename + "_geometry.vrscene" matfile = basename + "_material.vrscene" def writeMesh(obj, file, progress): mesh = Mesh.New('') mesh.getFromObject(obj, 0, 1) DrawProgressBar(progress, "Exporting %s..."%(obj.name)) if ( len(mesh.faces) > 0 ): sp(obj, "vr_mesh_valid", 1) file.write(exportMesh(getName(obj), mesh)) else: sp(obj, "vr_mesh_valid", 0) print "Incorrect mesh: %s"%(obj.name) def writeGeometry(): gfile = open(geomfile, 'w') gfile.write("// V-Ray/Blender: Geometry\n") progress = 0.0 progress_step = 1.0/len(scene.objects) for obj in scene.objects: if ( obj.getType() == "Mesh" ): if ( getProp("vray_export_active", 0 ) ): if ( (obj.Layers & scene.Layers) > 0 ): if ( not obj.restrictRender ): writeMesh(obj, gfile, progress) progress = progress + progress_step else: writeMesh(obj, gfile, progress) progress = progress + progress_step DrawProgressBar(1.0, "") gfile.close() def writeScene(): if ( getProp("vray_export_lock", 0 ) ): writeGeometry() sfile = open(scenefile, 'w') sfile.write("// V-Ray/Blender: Scene file\n") sfile.write("#include \"%s\"\n"%(geomfile)) sfile.write("#include \"%s\"\n"%(matfile)) sfile.write(exportNodes()) sfile.write(exportCamera()) sfile.write(exportLights()) sfile.write(exportEnvironment()) sfile.write(settingsCaustics()) sfile.write(settingsISampler()) sfile.write(settingsGI()) sfile.write(settingsDMCSampler()) sfile.write(settingsColorMapping()) sfile.write(settingsSystem()) sfile.write(settingsUnitsInfo()) sfile.write(settingsChannels()) #sfile.write(renderBakeView()) sfile.close() def launchVRay(): global ERROR vray_threads = scene.getRenderingContext().threads ostype = osys.platform if getProp("vray_binary", "") == "": print "V-Ray binary is not set!" else: vray_binary = getProperty("vray_binary") if ( getProp("vray_run",1) ): if ERROR == 0: if ostype == "linux2": if (getProp("vray_wine",0) == 1): cmd = "(xterm -T V-Ray -geometry 150x10 -e \"wine %s -numThreads=%d -scenefile=\"%s\"\")&"%(vray_binary, vray_threads, scenefile) elif (getProp("vray_log_window",1) == 1): cmd = "(xterm -T V-Ray -geometry 150x10 -e \"%s -numThreads=%d -scenefile=\"%s\"\")&"%(vray_binary, vray_threads, scenefile) else: cmd = "(%s -numThreads=%d -scenefile=\"%s\")&"%(vray_binary, vray_threads, scenefile) if ostype == "win32": cmd = "start /b /belownormal %s -numThreads=%d -scenefile=\"%s\""%(vray_binary, vray_threads, scenefile) os.system(cmd) else: print "\nEnable Run option to start V-Ray automatically after export...\n" ## ## GUI ## evtNoEvt = 0 evtRedraw = 1 evtExport = 2 evtExportGeom = 3 evtDrawVFB = 10 evtDrawSampler = 11 evtDrawGI = 12 evtDrawCM = 13 evtDrawUtils = 14 evtDrawSystem = 15 evtDrawEnv = 16 evtDrawPhysical = 17 evtExit = 100 ### Buttons def drawButtons(): BGL.glColor3f(0.25,0.25,0.25) BGL.glRectf(0,0,660,450) BGL.glColor3f(0.9,0.9,0.9) BGL.glRasterPos2i(10,430) Draw.Text("V-Ray/Blender %s"%(vrayblender_version),"small") BGL.glColor3f(1.0,0.5,0.4) Draw.Button("Render", evtDrawVFB, 10, 405, 80, 16, "") if getProperty("vray_gui_screen") == 0: BGL.glRectf(10,400,90,403) Draw.Button("Sampler", evtDrawSampler, 90, 405, 80, 16, "") if getProperty("vray_gui_screen") == 1: BGL.glRectf(90,400,170,403) Draw.Button("GI", evtDrawGI, 170, 405, 80, 16, "") if getProperty("vray_gui_screen") == 2: BGL.glRectf(170,400,250,403) Draw.Button("CM", evtDrawCM, 250, 405, 80, 16, "") if getProperty("vray_gui_screen") == 4: BGL.glRectf(250,400,330,403) Draw.Button("Displace", evtDrawEnv, 330, 405, 80, 16, "") if getProperty("vray_gui_screen") == 6: BGL.glRectf(330,400,410,403) Draw.Button("Caustics", evtDrawUtils, 410, 405, 80, 16, "") if getProperty("vray_gui_screen") == 3: BGL.glRectf(410,400,490,403) Draw.Button("System", evtDrawSystem, 490, 405, 80, 16, "") if getProperty("vray_gui_screen") == 5: BGL.glRectf(490,400,570,403) Draw.Button("Phys", evtDrawPhysical, 570, 405, 80, 16, "") if getProperty("vray_gui_screen") == 7: BGL.glRectf(570,400,650,403) if (len(scene.objects) != 0): Draw.Button("Render", evtExport, 10, 10, 100, 30, "Render scene") Draw.Button("Export Meshes", evtExportGeom, 115, 10, 100, 30, "Export scene geometry") Draw.Toggle("L", evtNoEvt, 220, 10, 20, 14, getProp("vray_export_lock", 0), "Run Export Meshes before Render", setProp("vray_export_lock")) Draw.Toggle("A", evtNoEvt, 220, 26, 20, 14, getProp("vray_export_active", 0), "Export only renderable objects from active layers", setProp("vray_export_active")) Draw.Button("Exit", evtExit, 570, 10, 80, 30, "Exit") ### V-Ray: VFB def drawVFB(): drawButtons() BGL.glColor3f(0.9,0.9,0.9) BGL.glRasterPos2i(10,380) Draw.Text("Passes:") Draw.Toggle("Z-Depth", evtRedraw, 20, 351, 110, 16, getProp("vray_renderchannel_zdepth", 0), "", setProp("vray_renderchannel_zdepth")) if getProperty("vray_renderchannel_zdepth") == 1: Draw.Number("Near:", evtNoEvt, 135, 350, 75, 18, getProp("vray_zdepth_near", 0.0), 0, 1000, "", setProp("vray_zdepth_near")) Draw.Number("Far:", evtNoEvt, 215, 350, 75, 18, getProp("vray_zdepth_far", 10.0), 0, 1000, "", setProp("vray_zdepth_far")) Draw.Toggle("Render ID", evtNoEvt, 20, 326, 70, 16, getProp("vray_renderchannel_renderid", 0), "", setProp("vray_renderchannel_renderid")) Draw.Toggle("Velocity", evtNoEvt, 95, 326, 70, 16, getProp("vray_renderchannel_velocity", 0), "", setProp("vray_renderchannel_velocity")) Draw.Toggle("Color", evtNoEvt, 170, 326, 50, 16, getProp("vray_renderchannel_color", 0), "", setProp("vray_renderchannel_color")) Draw.Toggle("Normals", evtNoEvt, 225, 326, 65, 16, getProp("vray_renderchannel_normals", 0), "", setProp("vray_renderchannel_normals")) uvwenv_menu = "Type: %t| Angular %x4| Cubic %x3| Mirror ball %x2| Screen %x1| Spherical %x0" BGL.glRasterPos2i(10,305) Draw.Text("Environment:") Draw.Toggle("BG", evtRedraw, 20, 276, 70, 16, getProp("vray_env_bg", 0), "Map name: ENV_BG", setProp("vray_env_bg")) if ( gsp("vray_env_bg") ): Draw.Toggle("S", evtRedraw, 95, 276, 30, 16, getProp("vray_env_bg_sky", 0), "Use VRaySky", setProp("vray_env_bg_sky")) if ( gsp("vray_env_bg_sky") == 0 ): Draw.Number("Mult:", evtNoEvt, 130, 275, 75, 18, getProp("vray_env_bg_mult", 1.0), 0, 1000, "", setProp("vray_env_bg_mult")) Draw.Menu(uvwenv_menu, evtNoEvt, 210, 275, 90, 18, getProp("vray_env_bg_type", 0), "", setProp("vray_env_bg_type")) Draw.Toggle("GI", evtRedraw, 20, 251, 70, 16, getProp("vray_envover_gi", 0), "Map name: ENV_GI", setProp("vray_envover_gi")) if ( gsp("vray_envover_gi") ): Draw.Toggle("S", evtRedraw, 95, 251, 30, 16, getProp("vray_envover_gi_sky", 0), "Use VRaySky", setProp("vray_envover_gi_sky")) if ( gsp("vray_envover_gi_sky") == 0 ): Draw.Number("Mult:", evtNoEvt, 130, 250, 75, 18, getProp("vray_envover_gi_mult", 1.0), 0, 1000, "", setProp("vray_envover_gi_mult")) Draw.Menu(uvwenv_menu, evtNoEvt, 210, 250, 90, 18, getProp("vray_envover_gi_type", 0), "", setProp("vray_envover_gi_type")) Draw.Toggle("Reflect", evtRedraw, 20, 226, 70, 16, getProp("vray_envover_reflect", 0), "Map name: ENV_REFLECT", setProp("vray_envover_reflect")) if ( gsp("vray_envover_reflect") ): Draw.Toggle("S", evtRedraw, 95, 226, 30, 16, getProp("vray_envover_reflect_sky", 0), "Use VRaySky", setProp("vray_envover_reflect_sky")) if ( gsp("vray_envover_reflect_sky") == 0 ): Draw.Number("Mult:", evtNoEvt, 130, 225, 75, 18, getProp("vray_envover_reflect_mult", 1.0), 0, 1000, "", setProp("vray_envover_reflect_mult")) Draw.Menu(uvwenv_menu, evtNoEvt, 210, 225, 90, 18, getProp("vray_envover_reflect_type", 0), "", setProp("vray_envover_reflect_type")) Draw.Toggle("Refract", evtRedraw, 20, 201, 70, 16, getProp("vray_envover_refract", 0), "Map name: ENV_REFRACT", setProp("vray_envover_refract")) if ( gsp("vray_envover_refract") ): Draw.Toggle("S", evtRedraw, 95, 201, 30, 16, getProp("vray_envover_refract_sky", 0), "Use VRaySky", setProp("vray_envover_refract_sky")) if ( gsp("vray_envover_refract_sky") == 0 ): Draw.Number("Mult:", evtNoEvt, 130, 200, 75, 18, getProp("vray_envover_refract_mult", 1.0), 0, 1000, "", setProp("vray_envover_refract_mult")) Draw.Menu(uvwenv_menu, evtNoEvt, 210, 200, 90, 18, getProp("vray_envover_refract_type", 0), "", setProp("vray_envover_refract_type")) BGL.glRasterPos2i(330,380) Draw.Text("Geometry:") Draw.Toggle("Displacement", evtNoEvt, 340, 351, 110, 18, getProp("vray_geom_displacement",1), "", setProp("vray_geom_displacement")) Draw.Toggle("Backface cull ", evtNoEvt, 455, 351, 110, 18, getProp("vray_geom_backfaceCull",0), "", setProp("vray_geom_backfaceCull")) Draw.Number("Ray bias:", evtNoEvt, 340, 326, 225, 18, getProp("vray_ray_bias", 0.0), 0, 1.0, "", setProp("vray_ray_bias")) BGL.glRasterPos2i(330,305) Draw.Text("Lighting:") Draw.Toggle("Lights", evtNoEvt, 340, 276, 110, 18, getProp("vray_light_doLights",1), "", setProp("vray_light_doLights")) Draw.Toggle("Shadows", evtNoEvt, 340, 251, 110, 18, getProp("vray_light_doShadows",1), "", setProp("vray_light_doShadows")) Draw.Toggle("Default lights", evtNoEvt, 455, 276, 110, 18, getProp("vray_light_doDefaultLights",0), "", setProp("vray_light_doDefaultLights")) Draw.Toggle("Hidden lights", evtNoEvt, 455, 251, 110, 18, getProp("vray_light_doHiddenLights",0), "", setProp("vray_light_doHiddenLights")) BGL.glRasterPos2i(330,230) Draw.Text("Materials:") Draw.Toggle("Reflect/refract", evtNoEvt, 340, 201, 110, 18, getProp("vray_mtl_reflectionRefraction",1), "", setProp("vray_mtl_reflectionRefraction")) Draw.Toggle("Glossy", evtNoEvt, 455, 201, 110, 18, getProp("vray_mtl_glossy",1), "", setProp("vray_mtl_glossy")) Draw.Toggle("Limit raydepth", evtRedraw, 340, 176, 110, 18, getProp("vray_mtl_limitDepth",0), "", setProp("vray_mtl_limitDepth")) if getProperty("vray_mtl_limitDepth"): Draw.Number("Depth:", evtNoEvt, 455, 176, 110, 18, getProp("vray_mtl_maxDepth", 5), 1, 100, "", setProp("vray_mtl_maxDepth")) Draw.Number("Max. transp levels:", evtNoEvt, 340, 151, 180, 18, getProp("vray_mtl_transpMaxLevels", 50), 0, 1000, "", setProp("vray_mtl_transpMaxLevels")) Draw.Number("Transp. cutoff:", evtNoEvt, 340, 126, 180, 18, getProp("vray_mtl_transpCutoff", 0.001), 0, 1.0, "", setProp("vray_mtl_transpCutoff")) Draw.Toggle("Material override", evtNoEvt, 340, 101, 180, 18, getProp("vray_mtl_overall", 0), "", setProp("vray_mtl_overall")) ### V-Ray: Image sampler (Antialiasing) def drawSampler(): drawButtons() BGL.glColor3f(0.9,0.9,0.9) BGL.glRasterPos2i(10,380) Draw.Text("Image sampler:") Draw.Menu("Type %t| Adaptive subdivision %x2| DMC %x1| Fixed %x0", evtRedraw, 110, 375, 140, 18, getProp("vray_imageSamplerType", 1), "", setProp("vray_imageSamplerType")) if getProperty("vray_imageSamplerType") == 0: Draw.Number("Rate:", evtNoEvt, 110, 350, 140, 18, getProp("vray_FixedRate", 1), 0, 100, "Fixed rate", setProp("vray_FixedRate")) if getProperty("vray_imageSamplerType") == 1: Draw.Number("Min:", evtNoEvt, 110, 350, 140, 18, getProp("vray_dmc_minSubdivs", 1), 1, 100, "DMC minimus subdivisions", setProp("vray_dmc_minSubdivs")) Draw.Number("Max:", evtNoEvt, 255, 350, 140, 18, getProp("vray_dmc_maxSubdivs", 4), getProp("vray_dmc_minSubdivs", 1)+1, 100, "DMC maximum subdivisions", setProp("vray_dmc_maxSubdivs")) Draw.Number("Thresh:", evtNoEvt, 110, 325, 140, 18, getProp("vray_dmc_threshold", 0.01), 0, 1.0, "", setProp("vray_dmc_threshold")) if getProperty("vray_imageSamplerType") == 2: Draw.Number("Min:", evtNoEvt, 110, 350, 140, 18, getProp("vray_subdivision_minRate", -1), -10, 100, "Min rate", setProp("vray_subdivision_minRate")) Draw.Number("Max:", evtNoEvt, 255, 350, 140, 18, getProp("vray_subdivision_maxRate", 2), getProp("vray_subdivision_minRate", 1)+1, 100, "Max rate", setProp("vray_subdivision_maxRate")) Draw.Number("Thresh:", evtNoEvt, 400, 350, 140, 18, getProp("vray_subdivision_threshold", 0.15), 0, 1.0, "Max rate", setProp("vray_subdivision_threshold")) Draw.Toggle("Edges", evtNoEvt, 110, 325, 65, 18, getProp("vray_subdivision_edges",0), "", setProp("vray_subdivision_edges")) Draw.Toggle("Normals", evtRedraw, 180, 325, 70, 18, getProp("vray_subdivision_normals",0), "", setProp("vray_subdivision_normals")) if getProperty("vray_subdivision_normals"): Draw.Number("Nrm. tresh:", evtNoEvt, 255, 325, 140, 18, getProp("vray_subdivision_normals_threshold", 0.1), 0, 1.0, "", setProp("vray_subdivision_normals_threshold")) BGL.glRasterPos2i(10,280) Draw.Text("Antialiasing filter:") menu_filter = "Type %t| Gaussian %x6| Sinc %x5| Lanczos %x4| Triangle %x3| Box %x2| Area %x1| None %x0" Draw.Menu(menu_filter, evtRedraw, 110, 275, 140, 18, getProp("vray_aa_filter_type", 0), "", setProp("vray_aa_filter_type")) if getProperty("vray_aa_filter_type") != 0: Draw.Number("Size:", evtNoEvt, 110, 250, 140, 18, getProp("vray_aa_filter_size", 1.5), 0.01, 20.0, "Filter width", setProp("vray_aa_filter_size")) BGL.glRasterPos2i(10,205) Draw.Text("DMC Sampler:") Draw.Number("Adaptive amount:", evtNoEvt, 110, 200, 200, 18, getProp("vray_adaptive_amount", 0.85), 0.0, 1.0, "", setProp("vray_adaptive_amount")) Draw.Number("Noise threshold:", evtNoEvt, 110, 175, 200, 18, getProp("vray_adaptive_threshold", 0.01), 0.001, 1.0, "", setProp("vray_adaptive_threshold")) Draw.Number("Min. samples:", evtNoEvt, 110, 150, 200, 18, getProp("vray_adaptive_min_samples", 8), 0, 100, "", setProp("vray_adaptive_min_samples")) Draw.Number("Subdivs mult:", evtNoEvt, 110, 125, 200, 18, getProp("vray_subdivs_mult", 1.0), 0.0, 100.0, "", setProp("vray_subdivs_mult")) Draw.Toggle("Time independent", evtNoEvt, 110, 100, 110, 18, getProp("vray_time_dependent",1), "", setProp("vray_time_dependent")) def drawPhotonMap(x): c1 = x+10 c2 = x+160 BGL.glRasterPos2i(x,280) Draw.Text("Photon map:") Draw.Number("Bounces:", evtNoEvt, c1, 250, 140, 18, getProp("vray_pm_bounces", 10), 1, 1000, "", setProp("vray_pm_bounces")) Draw.Toggle("Auto dist", evtRedraw, c1, 226, 55, 16, getProp("vray_pm_auto_search_distance",0), "", setProp("vray_pm_auto_search_distance")) if getProperty("vray_pm_auto_search_distance") == 0: Draw.Number("Dist:", evtNoEvt, c1+60, 225, 80, 18, getProp("vray_pm_search_distance", 20.0), 0, 1000.0, "", setProp("vray_pm_search_distance")) Draw.Number("Max. photons:", evtNoEvt, c1, 200, 140, 18, getProp("vray_pm_max_photons", 30), 1, 1000, "", setProp("vray_pm_max_photons")) Draw.Number("Multiplier:", evtNoEvt, c1, 175, 140, 18, getProp("vray_pm_multiplier", 1.0), 0, 100.0, "", setProp("vray_pm_multiplier")) Draw.Number("Max density:", evtNoEvt, c1, 150, 140, 18, getProp("vray_pm_max_density", 0.0), 0, 10.0, "", setProp("vray_pm_max_density")) Draw.Toggle("Convert to IM", evtRedraw, c2, 251, 140, 16, getProp("vray_pm_prefilter",0), "", setProp("vray_pm_prefilter")) if getProperty("vray_pm_prefilter"): Draw.Number("Interp samples:", evtNoEvt, c2, 225, 140, 18, getProp("vray_pm_prefilter_samples", 10), 0, 1000, "", setProp("vray_pm_prefilter_samples")) Draw.Toggle("Convex hull area", evtNoEvt, c2, 200, 140, 16, getProp("vray_pm_convex_hull_estimate",0), "", setProp("vray_pm_convex_hull_estimate")) Draw.Toggle("Store direct light", evtNoEvt, c2, 175, 140, 16, getProp("vray_pm_store_direct_light",1), "", setProp("vray_pm_store_direct_light")) Draw.Number("Rtr thresh:", evtNoEvt, c2, 150, 140, 18, getProp("vray_pm_retrace_corners", 0.0), 0, 1.0, "", setProp("vray_pm_retrace_corners")) Draw.Number("Rtr bounces:", evtNoEvt, c2, 125, 140, 18, getProp("vray_pm_retrace_bounces", 20), 0, 1000, "", setProp("vray_pm_retrace_bounces")) def drawLightCache(x): c1 = x+10 c3 = x+260 BGL.glColor3f(0.9,0.9,0.9) BGL.glRasterPos2i(x,280) Draw.Text("Light Cache:") Draw.Number("Subdivs:", evtNoEvt, c1, 250, 140, 18, getProp("vray_lc_subdivs", 1000), 1, 65535, "", setProp("vray_lc_subdivs")) Draw.Number("Sample size:", evtNoEvt, c1, 225, 160, 18, getProp("vray_lc_sample_size", 0.02), 0, 1.0, "", setProp("vray_lc_sample_size")) menu_lc_scale = "Scale %t| World %x1| Screen %x0" Draw.Menu(menu_lc_scale, evtRedraw, c1+165, 225, 80, 18, getProp("vray_lc_scale", 0), "", setProp("vray_lc_scale")) Draw.Number("Passes:", evtNoEvt, c1, 200, 140, 18, getProp("vray_lc_num_passes", 4), 1, 128, "", setProp("vray_lc_num_passes")) Draw.Toggle("Pre-filter", evtRedraw, c1, 176, 120, 16, getProp("vray_lc_prefilter", 0), "", setProp("vray_lc_prefilter")) if (getProperty("vray_lc_prefilter") == 1): Draw.Number("", evtNoEvt, c1+125, 175, 55, 18, getProp("vray_lc_prefilter_samples", 10), 1, 1000, "", setProp("vray_lc_prefilter_samples")) BGL.glRasterPos2i(c1,155) Draw.Text("Filter:") menu_lc_filter = "Type %t| Fixed %x2| Nearest %x1| None %x0" Draw.Menu(menu_lc_filter, evtRedraw, c1+50, 150, 80, 18, getProp("vray_lc_filter_type", 0), "", setProp("vray_lc_filter_type")) if (getProperty("vray_lc_filter_type") == 1): Draw.Number("Samples", evtNoEvt, c1+140, 150, 100, 18, getProp("vray_lc_filter_samples", 10), 1, 1000, "", setProp("vray_lc_filter_samples")) if (getProperty("vray_lc_filter_type") == 2): Draw.Number("Size", evtNoEvt, c1+140, 150, 100, 18, getProp("vray_lc_filter_size", 0.02), 0, 1.0, "", setProp("vray_lc_filter_size")) Draw.Toggle("Store", evtRedraw, c3, 250, 50, 16, getProp("vray_lc_store_direct_light",1), "", setProp("vray_lc_store_direct_light")) Draw.Toggle("Show", evtRedraw, c3, 225, 50, 16, getProp("vray_lc_show_calc_phase",0), "", setProp("vray_lc_show_calc_phase")) Draw.Toggle("Glossy", evtRedraw, c3, 200, 50, 16, getProp("vray_lc_use_for_glossy_rays",0), "", setProp("vray_lc_use_for_glossy_rays")) Draw.Toggle("Adapt", evtRedraw, c3, 175, 50, 16, getProp("vray_lc_adaptive_sampling",0), "", setProp("vray_lc_adaptive_sampling")) def drawBruteForce(x, sb): c1 = x+10 BGL.glRasterPos2i(x,280) Draw.Text("Brute force:") Draw.Number("Subdivs:", evtNoEvt, c1, 250, 140, 18, getProp("vray_dmcgi_subdivs",8), 1, 256, "", setProp("vray_dmcgi_subdivs")) if (sb == 1): Draw.Number("Depth:", evtNoEvt, c1, 225, 140, 18, getProp("vray_dmcgi_depth",3), 1, 256, "", setProp("vray_dmcgi_depth")) ### V-Ray: Global Illumination def drawGI(): drawButtons() BGL.glColor3f(0.9,0.9,0.9) BGL.glRasterPos2i(10,380) Draw.Text("Global illumination:") Draw.Toggle("On", evtRedraw, 20, 351, 81, 16, getProp("vray_gi_on",0), "", setProp("vray_gi_on")) if getProperty("vray_gi_on") == 1: Draw.Toggle("Refl", evtRedraw, 110, 351, 60, 16, getProp("vray_reflect_caustics",0), "Reflect caustics", setProp("vray_reflect_caustics")) Draw.Toggle("Refr", evtRedraw, 175, 351, 60, 16, getProp("vray_refract_caustics",1), "Refract caustics", setProp("vray_refract_caustics")) Draw.Number("Sat:", evtNoEvt, 250, 350, 120, 18, getProp("vray_saturation", 1.0), 0, 1.0, "", setProp("vray_saturation")) Draw.Number("Contrast:", evtNoEvt, 375, 350, 120, 18, getProp("vray_contrast", 1.0), 0, 10.0, "", setProp("vray_contrast")) Draw.Number("Base:", evtNoEvt, 500, 350, 120, 18, getProp("vray_contrast_base", 0.5), 0, 10.0, "", setProp("vray_contrast_base")) BGL.glColor3f(0.9,0.9,0.9) BGL.glRasterPos2i(10,330) Draw.Text("Primary bounces:") menu_gi_pe = "Engine %t| Light Cache %x3| Brute force %x2| Photon map %x1| Irradiance map %x0" Draw.Number("", evtNoEvt, 20, 300, 60, 18, getProp("vray_primary_multiplier", 1.0), 0, 100.0, "", setProp("vray_primary_multiplier")) Draw.Menu(menu_gi_pe, evtRedraw, 90, 300, 140, 18, getProp("vray_primary_engine", 0), "", setProp("vray_primary_engine")) BGL.glColor3f(0.9,0.9,0.9) BGL.glRasterPos2i(335,330) Draw.Text("Secondary bounces:") menu_gi_se = "Engine %t| Light Cache %x3| Brute force %x2| Photon map %x1| None %x0" Draw.Number("", evtNoEvt, 345, 300, 60, 18, getProp("vray_secondary_multiplier", 1.0), 0, 1.0, "", setProp("vray_secondary_multiplier")) Draw.Menu(menu_gi_se, evtRedraw, 415, 300, 140, 18, getProp("vray_secondary_engine", 3), "", setProp("vray_secondary_engine")) # Irradiance map if getProperty("vray_primary_engine") == 0: BGL.glRasterPos2i(10,280) Draw.Text("Irradiance map:") Draw.Number("Min. rate:", evtRedraw, 20, 250, 140, 18, getProp("vray_im_min_rate", -3), -10, 10, "", setProp("vray_im_min_rate")) Draw.Number("Max. rate:", evtNoEvt, 20, 225, 140, 18, getProp("vray_im_max_rate", 0), getProperty("vray_im_min_rate"), 10.0, "", setProp("vray_im_max_rate")) Draw.Number("HSph. subdivs:", evtNoEvt, 20, 200, 140, 18, getProp("vray_im_subdivs", 50), 1, 300.0, "", setProp("vray_im_subdivs")) Draw.Number("Interp. samples:", evtNoEvt, 20, 175, 140, 18, getProp("vray_im_interp_samples", 20), 1, 300.0, "", setProp("vray_im_interp_samples")) Draw.Number("Clr tresh:", evtNoEvt, 170, 250, 140, 18, getProp("vray_im_color_threshold", 0.3), 0, 1.0, "", setProp("vray_im_color_threshold")) Draw.Number("Nrm tresh:", evtNoEvt, 170, 225, 140, 18, getProp("vray_im_normal_threshold", 0.1), 0, 1.0, "", setProp("vray_im_normal_threshold")) Draw.Number("Dst tresh:", evtNoEvt, 170, 200, 140, 18, getProp("vray_im_distance_threshold", 0.1), 0, 1.0, "", setProp("vray_im_distance_threshold")) Draw.Toggle("Show", evtRedraw, 170, 176, 40, 16, getProp("vray_im_show_calc_phase",1), "", setProp("vray_im_show_calc_phase")) if getProperty("vray_im_show_calc_phase"): Draw.Toggle("Direct", evtNoEvt, 215, 176, 45, 16, getProp("vray_im_show_direct_light",0), "", setProp("vray_im_show_direct_light")) Draw.Toggle("Samples", evtNoEvt, 265, 176, 45, 16, getProp("vray_im_show_samples",0), "", setProp("vray_im_show_samples")) BGL.glColor3f(0.9,0.9,0.9) BGL.glRasterPos2i(20,155) Draw.Text("Interpolation type:") menu_im_interpolationType = "Type %t| Least squares with Voronoi weights %x3| Delone triangulation %x2| Least squares fit %x1| Weighted average %x0" Draw.Menu(menu_im_interpolationType, evtNoEvt, 140, 150, 170, 18, getProp("vray_im_interpolationType", 1), "", setProp("vray_im_interpolationType")) BGL.glColor3f(0.9,0.9,0.9) BGL.glRasterPos2i(20,130) Draw.Text("Sample lookup:") menu_im_lookupType = "Type %t| Density-based %x3| Overlapping %x2| Nearest %x1| Quad-balanced %x0" Draw.Menu(menu_im_lookupType, evtNoEvt, 140, 125, 170, 18, getProp("vray_im_lookupType", 2), "", setProp("vray_im_lookupType")) Draw.Number("Calc. pass samples:", evtNoEvt, 125, 100, 185, 18, getProp("vray_im_calc_interp_samples", 10), 1, 200, "", setProp("vray_im_calc_interp_samples")) Draw.Toggle("M", evtNoEvt, 20, 101, 25, 16, getProp("vray_im_multipass",1), "Multipass", setProp("vray_im_multipass")) Draw.Toggle("R", evtNoEvt, 55, 101, 25, 16, getProp("vray_im_randomize_samples",1), "Randomize samples", setProp("vray_im_randomize_samples")) Draw.Toggle("C", evtNoEvt, 90, 101, 25, 16, getProp("vray_im_check_sample_visibility",0), "Check sample visibility", setProp("vray_im_check_sample_visibility")) Draw.Toggle("DE", evtRedraw, 20, 76, 30, 16, getProp("vray_im_detail_enhancement",0), "Detail enhancement", setProp("vray_im_detail_enhancement")) if getProperty("vray_im_detail_enhancement"): Draw.Number("Radius:", evtNoEvt, 55, 75, 110, 18, getProp("vray_im_detail_radius", 0.06), 0, 1.0, "Radius", setProp("vray_im_detail_radius")) Draw.Number("Subdivs:", evtNoEvt, 170, 75, 110, 18, getProp("vray_im_detail_subdivs_mult", 0.3), 0, 1.0, "Subdivs multiplier", setProp("vray_im_detail_subdivs_mult")) Draw.Toggle("W", evtNoEvt, 285, 76, 25, 16, getProp("vray_im_detail_scale",0), "World scale", setProp("vray_im_detail_scale")) if getProperty("vray_primary_engine") == 1 and getProperty("vray_secondary_engine") == 1: drawPhotonMap(160) else: if getProperty("vray_primary_engine") == 1: drawPhotonMap(10) if getProperty("vray_secondary_engine") == 1: drawPhotonMap(335) if getProperty("vray_primary_engine") == 2 and getProperty("vray_secondary_engine") == 2: drawBruteForce(220,1) else: if getProperty("vray_primary_engine") == 2: drawBruteForce(10,0) if getProperty("vray_secondary_engine") == 2: drawBruteForce(335,1) if getProperty("vray_primary_engine") == 3 and getProperty("vray_secondary_engine") == 3: drawLightCache(160) else: if getProperty("vray_primary_engine") == 3: drawLightCache(10) if getProperty("vray_secondary_engine") == 3: drawLightCache(335) ### V-Ray: Displacement def drawEnv(): drawButtons() BGL.glColor3f(0.9,0.9,0.9) BGL.glRasterPos2i(10,380) Draw.Text("Displacement:") Draw.Number("Edge length:", evtNoEvt, 110, 375, 140, 18, getProp("vray_displace_edgeLength", 4.0), 0, 100.0, "", setProp("vray_displace_edgeLength")) Draw.Number("Max. subdivs:", evtNoEvt, 110, 350, 140, 18, getProp("vray_displace_maxSubdivs", 256), 1, 1000, "", setProp("vray_displace_maxSubdivs")) Draw.Number("Amount mult.:", evtNoEvt, 110, 325, 140, 18, getProp("vray_displace_amount", 1.0), 0, 100.0, "", setProp("vray_displace_amount")) Draw.Toggle("View dependent", evtNoEvt, 275, 375, 120, 18, getProp("vray_displace_viewDependent",1), "", setProp("vray_displace_viewDependent")) Draw.Toggle("Tight bounds", evtNoEvt, 275, 350, 120, 18, getProp("vray_displace_tightBounds",1), "", setProp("vray_displace_tightBounds")) Draw.Toggle("Relative", evtNoEvt, 275, 325, 120, 18, getProp("vray_displace_relative",0), "", setProp("vray_displace_relative")) selected = Blender.Object.GetSelected() if (len(selected) == 1 and selected[0].getType() == "Mesh"): BGL.glRasterPos2i(10,280) Draw.Text("Selected:") Draw.Number("Amount:", evtNoEvt, 110, 275, 160, 18, gp(selected[0],"displacement_amount", 0.01), -1, 1.0, "", setObjProp(selected[0],"displacement_amount")) Draw.Number("Shift:", evtNoEvt, 110, 250, 160, 18, gp(selected[0],"displacement_shift", 0.0), 0, 100.0, "", setObjProp(selected[0],"displacement_shift")) Draw.Toggle("Use globals", evtRedraw, 295, 275, 120, 18, gp(selected[0],"displacement_use_globals", 0), "", setObjProp(selected[0],"displacement_use_globals")) if ( gp(selected[0],"displacement_use_globals", 0) == 0 ): Draw.Number("Edge length:", evtNoEvt, 110, 225, 160, 18, gp(selected[0],"displacement_edgeLength", 4.0), 0, 100.0, "", setObjProp(selected[0],"displacement_edgeLength")) Draw.Number("Max. subdivs:", evtNoEvt, 110, 200, 160, 18, gp(selected[0],"displacement_maxSubdivs", 256), 1, 1000, "", setObjProp(selected[0],"displacement_maxSubdivs")) Draw.Toggle("View dependent", evtNoEvt, 295, 250, 120, 18, gp(selected[0],"displacement_view_dep", 1), "", setObjProp(selected[0],"displacement_view_dep")) Draw.Toggle("Keep continuity", evtNoEvt, 295, 225, 120, 18, gp(selected[0],"displacement_keep_continuity", 0), "", setObjProp(selected[0],"displacement_keep_continuity")) else: BGL.glRasterPos2i(10,280) Draw.Text("Select mesh") ### V-Ray: Color mapping def drawCM(): drawButtons() BGL.glColor3f(0.9,0.9,0.9) BGL.glRasterPos2i(10,380) Draw.Text("Color mapping:") menu_cm = "Type %t| Reinhard %x6| Intensity gamma %x5| Gamma correction %x4| Intensity exponential %x3| HSV exponential %x2| Exponential %x1| Linear %x0" Draw.Menu(menu_cm, evtRedraw, 110, 375, 140, 18, getProp("vray_cm_type", 0), "", setProp("vray_cm_type")) if getProperty("vray_cm_type") == 0 or getProperty("vray_cm_type") == 1 or getProperty("vray_cm_type") == 2 or getProperty("vray_cm_type") == 3: Draw.Number("Bright mult:", evtNoEvt, 110, 350, 140, 18, getProp("vray_bright_mult", 1.0), 0, 100.0, "", setProp("vray_bright_mult")) Draw.Number("Dark mult:", evtNoEvt, 110, 325, 140, 18, getProp("vray_dark_mult", 1.0), 0, 100.0, "", setProp("vray_dark_mult")) if getProperty("vray_cm_type") == 4 or getProperty("vray_cm_type") == 5: Draw.Number("Multiplier:", evtNoEvt, 110, 350, 140, 18, getProp("vray_bright_mult", 1.0), 0, 100.0, "", setProp("vray_bright_mult")) Draw.Number("Inverse gamma:", evtNoEvt, 110, 325, 140, 18, getProp("vray_dark_mult", 1.0), 0, 100.0, "", setProp("vray_dark_mult")) if getProperty("vray_cm_type") == 6: Draw.Number("Multiplier:", evtNoEvt, 110, 350, 140, 18, getProp("vray_bright_mult", 1.0), 0, 100.0, "", setProp("vray_bright_mult")) Draw.Number("Burn:", evtNoEvt, 110, 325, 140, 18, getProp("vray_dark_mult", 1.0), 0, 100.0, "", setProp("vray_dark_mult")) Draw.Number("Gamma:", evtNoEvt, 110, 300, 140, 18, getProp("vray_gamma", 2.2), 0, 10.0, "", setProp("vray_gamma")) Draw.Number("Input gamma:", evtNoEvt, 110, 275, 140, 18, getProp("vray_inputgamma",1.0), 0, 10.0, "", setProp("vray_inputgamma")) Draw.Toggle("Subpixel", evtNoEvt, 255, 325, 80, 18, getProp("vray_subpixel_mapping",0), "", setProp("vray_subpixel_mapping")) Draw.Toggle("Clamp", evtNoEvt, 255, 300, 80, 18, getProp("vray_clamp_output",0), "", setProp("vray_clamp_output")) Draw.Toggle("Adapt only", evtNoEvt, 255, 275, 80, 18, getProp("vray_adaptation_only",0), "", setProp("vray_adaptation_only")) ### V-Ray: Caustics def drawDMCUtils(): drawButtons() BGL.glColor3f(0.9,0.9,0.9) BGL.glRasterPos2i(10,380) Draw.Text("Caustics") Draw.Toggle("On", evtRedraw, 70, 376, 40, 16, getProp("vray_caustics_on",0), "", setProp("vray_caustics_on")) if getProperty("vray_caustics_on"): Draw.Number("Multiplier:", evtNoEvt, 20, 350, 140, 18, getProp("vray_caustics_multiplier", 1.0), 0, 100.0, "", setProp("vray_caustics_multiplier")) Draw.Number("Search dist:", evtNoEvt, 20, 325, 140, 18, getProp("vray_caustics_search_distance", 0.05), 0, 10.0, "", setProp("vray_caustics_search_distance")) Draw.Number("Max photons:", evtNoEvt, 20, 300, 140, 18, getProp("vray_caustics_max_photons", 30), 1, 10000, "", setProp("vray_caustics_max_photons")) Draw.Number("Max density:", evtNoEvt, 20, 275, 140, 18, getProp("vray_caustics_max_density", 0.0), 0, 1000.0, "", setProp("vray_caustics_max_density")) def setVRayBinary(): return lambda val: setProperty("vray_binary", val) ### V-Ray: System def drawSystem(): drawButtons() BGL.glColor3f(0.9,0.9,0.9) BGL.glRasterPos2i(10,380) Draw.Text("Raycaster:") Draw.Number("Max. levels:", evtNoEvt, 110, 375, 200, 18, getProp("vray_maxLevels", 80), 0, 100, "", setProp("vray_maxLevels")) Draw.Number("Min. leaf size:", evtNoEvt, 110, 350, 200, 18, getProp("vray_minLeafSize", 0.0), 0.0, 10.0, "", setProp("vray_minLeafSize")) Draw.Number("Face/level coef.:", evtNoEvt, 110, 325, 200, 18, getProp("vray_faceLevelCoef", 1.0), 0.0, 10.0, "", setProp("vray_faceLevelCoef")) Draw.Number("Dynamic memory limit:", evtNoEvt, 110, 300, 200, 18, getProp("vray_dynMemLimit", 400), 0, 10000, "", setProp("vray_dynMemLimit")) BGL.glRasterPos2i(350,380) Draw.Text("1.0 Blender Unit = 1.0 Meter") Draw.Number("Metric scale:", evtNoEvt, 360, 350, 200, 18, getProp("vray_metric_scale", 1.0), 0.0, 100.0, "", setProp("vray_metric_scale")) Draw.Number("Photometric scale:", evtNoEvt, 360, 325, 200, 18, getProp("vray_photometric_scale", 0.002), 0.0, 1.0, "", setProp("vray_photometric_scale")) BGL.glRasterPos2i(10,255) Draw.Text("Render region:") Draw.Number("Bucket size:", evtNoEvt, 110, 250, 200, 18, getProp("vray_xc", 32), 0, 1024, "", setProp("vray_xc")) BGL.glRasterPos2i(10,205) Draw.Text("Renderer:") Draw.String("V-Ray binary: "+getProp("vray_binary", ""), evtNoEvt, 110, 200, 400, 18, "", 300, "") Draw.Button("...", evtRedraw, 515, 200, 20, 18, "", lambda e,v:Window.FileSelector(setVRayBinary(), "Select V-Ray binary")) Draw.Button("Save", evtNoEvt, 540, 200, 40, 18, "", lambda e,v:updateRegistry()) Draw.Toggle("Use wine", evtNoEvt, 110, 175, 165, 18, getProp("vray_wine",0), "", setProp("vray_wine")) Draw.Toggle("Log window", evtNoEvt, 110, 150, 80, 18, getProp("vray_log_window",1), "", setProp("vray_log_window")) Draw.Toggle("Run", evtNoEvt, 110, 125, 80, 18, getProp("vray_run",1), "", setProp("vray_run")) ### V-Ray: Lights, physical Sun/Sky, physical camera def drawDOF(x,y,obj): Draw.Toggle("DOF", evtRedraw, x, y+1, 40, 16, gp(obj,"vray_camera_phys_use_dof",0), "", setObjProp(obj,"vray_camera_phys_use_dof")) Draw.Toggle("Motion blur", evtRedraw, x+45, y+1, 95, 16, gp(obj,"vray_camera_phys_use_moblur",0), "", setObjProp(obj,"vray_camera_phys_use_moblur")) if gperty(obj,"vray_camera_phys_use_dof") or gperty(obj,"vray_camera_phys_use_moblur"): Draw.Number("Subdivs:", evtNoEvt, x, y-25, 140, 18, gp(obj,"vray_camera_phys_subdivs", 6), 0, 1024, "", setObjProp(obj,"vray_camera_phys_subdivs")) if gperty(obj,"vray_camera_phys_use_dof"): Draw.Toggle("Bokeh effects", evtRedraw, x, y-50+1, 110, 16, gp(obj,"vray_camera_phys_bokeh",0), "", setObjProp(obj,"vray_camera_phys_bokeh")) if gperty(obj,"vray_camera_phys_bokeh"): Draw.Number("Center bias:", evtNoEvt, x+10, y-75, 130, 18, gp(obj,"vray_camera_center_bias", 0.0), -10.0, 10.0, "", setObjProp(obj,"vray_camera_center_bias")) Draw.Number("Anisotropy:", evtNoEvt, x+10, y-100, 130, 18, gp(obj,"vray_camera_anisotropy", 0.0), -10.0, 10.0, "", setObjProp(obj,"vray_camera_anisotropy")) Draw.Toggle("Blades", evtRedraw, x+10, y-125+1, 110, 16, gp(obj,"vray_camera_blades_enable",0), "", setObjProp(obj,"vray_camera_blades_enable")) if gperty(obj,"vray_camera_blades_enable"): Draw.Number("Number:", evtNoEvt, x+20, y-150, 120, 18, gp(obj,"vray_camera_blades_num", 5), 0, 20, "", setObjProp(obj,"vray_camera_blades_num")) Draw.Number("Rotation:", evtNoEvt, x+20, y-175, 120, 18, gp(obj,"vray_camera_blades_rotation", 0), 0, 20, "", setObjProp(obj,"vray_camera_blades_rotation")) def drawCommonLight(x,y,obj): Draw.Number("Subdivs:", evtNoEvt, x, y, 120, 18, gp(obj,"vray_light_subdivs", 8), 1, 200, "", setObjProp(obj,"vray_light_subdivs")) if gp(obj,"vray_light_portal",0) == 0: Draw.Toggle("Invisible", evtNoEvt, x, y-25, 58, 18, gp(obj,"vray_light_invisible",1), "", setObjProp(obj,"vray_light_invisible")) Draw.Toggle("Store", evtNoEvt, x+62, y-25, 58, 18, gp(obj,"vray_light_store",0), "", setObjProp(obj,"vray_light_store")) BGL.glRasterPos2i(x,y-50+5) Draw.Text("Units:") menu_light_units = "Units: %t| Watt/m %x4| Watts %x3| Lumen/m %x2| Lumen %x1| Default %x0" Draw.Menu(menu_light_units, evtNoEvt, x+40, y-50, 80, 18, gp(obj,"vray_light_units", 0), "", setObjProp(obj,"vray_light_units")) Draw.Number("Intensity:", evtNoEvt, x, y-75, 120, 18, gp(obj,"vray_light_intensity", 30.0), 0, 100000.0, "", setObjProp(obj,"vray_light_intensity")) if getProp("vray_caustics_on",0): Draw.Number("Caustics subdivs:", evtNoEvt, x+125, y, 160, 18, gp(obj,"vray_light_caustics_subdivs", 1000), 0, 1000000, "", setObjProp(obj,"vray_light_caustics_subdivs")) def DrawPhysical(): drawButtons() BGL.glColor3f(0.9,0.9,0.9) selected = Blender.Object.GetSelected() # Light if (len(selected) == 1 and selected[0].getType() == "Lamp"): BGL.glRasterPos2i(10,380) Draw.Text("Light settings") # Direct or Sun if selected[0].data.getType() == 1: Draw.Toggle("Sun", evtRedraw, 90, 377, 40, 14, gp(selected[0],"vray_light_sun",0), "", setObjProp(selected[0],"vray_light_sun")) if gp(selected[0],"vray_light_sun",0): if getProp("vray_caustics_on",0): Draw.Number("Caustics subdivs:", evtNoEvt, 20, 350, 160, 18, gp(selected[0],"vray_light_caustics_subdivs", 1000), 0, 1000000, "", setObjProp(selected[0],"vray_light_caustics_subdivs")) else: Draw.Number("Beam radius:", evtNoEvt, 20, 350, 120, 18, gp(selected[0],"vray_light_beamradius", 0.5), 0, 1000.0, "", setObjProp(selected[0],"vray_light_beamradius")) drawCommonLight(20,325,selected[0]) # Dome if selected[0].data.getType() == 3: drawCommonLight(20,350,selected[0]) Draw.Toggle("Full dome", evtNoEvt, 20, 250, 120, 18, gp(selected[0],"vray_light_dome_spherifical",0), "", setObjProp(selected[0],"vray_light_dome_spherifical")) Draw.Toggle("Use texture", evtRedraw, 20, 225, 120, 18, gp(selected[0],"vray_light_use_dome_tex",0), "", setObjProp(selected[0],"vray_light_use_dome_tex")) if gp(selected[0],"vray_light_use_dome_tex",0) == 1: BGL.glRasterPos2i(20,205) Draw.Text("Type:") ibl_map_menu = "Type: %t| Angular %x4| Cubic %x3| Mirror ball %x2| Screen %x1| Spherical %x0" Draw.Menu(ibl_map_menu, evtNoEvt, 60, 200, 80, 18, getProp("vray_IBL_mapping_type", 0), "", setProp("vray_IBL_mapping_type")) # Sphere if selected[0].data.getType() == 0: Draw.Number("Radius:", evtNoEvt, 20, 350, 120, 18, gp(selected[0],"vray_light_radius", 0.01), 0, 300.0, "", setObjProp(selected[0],"vray_light_radius")) drawCommonLight(20,325,selected[0]) # Spot if selected[0].data.getType() == 2: Draw.Toggle("IES", evtRedraw, 90, 377, 40, 14, gp(selected[0],"vray_light_isIES",0), "", setObjProp(selected[0],"vray_light_isIES")) drawCommonLight(20,350,selected[0]) if (gperty(selected[0],"vray_light_isIES")): Draw.Toggle("Soft shadows", evtNoEvt, 20, 250, 100, 18, gp(selected[0],"vray_light_IES_soft_shadows",0), "", setObjProp(selected[0],"vray_light_IES_soft_shadows")) Draw.Button("File...", evtNoEvt, 20, 225, 100, 18, "Select IES file [%s]"%(gp(selected[0],"vray_light_IES","None")), lambda e,v:Window.FileSelector(setIES(selected[0],"vray_light_IES"), "Select IES file")) # Rectangle if selected[0].data.getType() == 4: Draw.Toggle("Skylight portal", evtRedraw, 90, 377, 110, 14, gp(selected[0],"vray_light_portal",0), "", setObjProp(selected[0],"vray_light_portal")) drawCommonLight(20,350,selected[0]) # Camera elif (len(selected) == 1 and selected[0].getType() == "Camera"): BGL.glRasterPos2i(10,380) Draw.Text("Camera") Draw.Toggle("Physical", evtRedraw, 65, 377, 60, 14, gp(selected[0],"vray_camera_physical",0), "", setObjProp(selected[0],"vray_camera_physical")) if (gperty(selected[0],"vray_camera_physical")): BGL.glRasterPos2i(20,355) Draw.Text("Type:") menu_camera_phys_type = "Type %t| Video %x2| Movie %x1| Still %x0" Draw.Menu(menu_camera_phys_type,evtNoEvt, 60, 350, 100, 18, gp(selected[0],"vray_camera_physical_type", 0), "", setObjProp(selected[0],"vray_camera_physical_type")) Draw.Number("F-number:", evtNoEvt, 20, 325, 140, 18, gp(selected[0],"vray_camera_f_number", 8.0), 0, 100.0, "", setObjProp(selected[0],"vray_camera_f_number")) Draw.Number("Shutter speed:", evtNoEvt, 20, 300, 140, 18, gp(selected[0],"vray_camera_shutter_speed", 15.0), 0, 1000.0, "", setObjProp(selected[0],"vray_camera_shutter_speed")) Draw.Number("ISO:", evtNoEvt, 20, 275, 140, 18, gp(selected[0],"vray_camera_ISO", 50.0), 0, 10000.0, "", setObjProp(selected[0],"vray_camera_ISO")) Draw.Number("Focal length:", evtNoEvt, 20, 250, 140, 18, gp(selected[0],"vray_camera_focal_length", 40.0), 0, 200.0, "", setObjProp(selected[0],"vray_camera_focal_length")) Draw.Number("Zoom factor:", evtNoEvt, 20, 225, 140, 18, gp(selected[0],"vray_camera_zoom_factor", 1.0), 0, 1.0, "", setObjProp(selected[0],"vray_camera_zoom_factor")) Draw.Number("Lens shift:", evtNoEvt, 20, 200, 140, 18, gp(selected[0],"vray_camera_lens_shift", 0.0), -1.0, 1.0, "", setObjProp(selected[0],"vray_camera_lens_shift")) Draw.Toggle("Vignetting", evtNoEvt, 20, 176, 140, 16, gp(selected[0],"vray_camera_vignetting",1), "", setObjProp(selected[0],"vray_camera_vignetting")) drawDOF(170,350,selected[0]) else: BGL.glRasterPos2i(20,355) Draw.Text("Type:") menu_camera_type = "Type %t| Orthographic %x6| Fish eye %x5| Box %x4| Cylindrical (ortho) %x3| Cylindrical (point) %x2| Spherical %x1| Standard %x0" Draw.Menu(menu_camera_type, evtRedraw, 60, 350, 140, 18, gp(selected[0],"vray_camera_type", 0), "", setObjProp(selected[0],"vray_camera_type")) if gperty(selected[0],"vray_camera_type") == 3: Draw.Number("Height:", evtNoEvt, 20, 325, 140, 18, gp(selected[0],"vray_camera_height", 0.4), 0, 1000.0, "", setObjProp(selected[0],"vray_camera_height")) drawDOF(20,300,selected[0]) elif gperty(selected[0],"vray_camera_type") == 5: Draw.Toggle("Auto-fit", evtRedraw, 20, 326, 60, 16, gp(selected[0],"vray_camera_auto_fit",1), "", setObjProp(selected[0],"vray_camera_auto_fit")) if gperty(selected[0],"vray_camera_auto_fit") == 0: Draw.Number("Dist:", evtNoEvt, 85, 325, 75, 18, gp(selected[0],"vray_camera_dist", 2.0), 0, 1000.0, "", setObjProp(selected[0],"vray_camera_dist")) Draw.Number("Curve:", evtNoEvt, 20, 300, 140, 18, gp(selected[0],"vray_camera_curve", 1.0), 0, 10.0, "", setObjProp(selected[0],"vray_camera_curve")) drawDOF(20,275,selected[0]) else: drawDOF(20,325,selected[0]) else: BGL.glRasterPos2i(10,380) Draw.Text("Select light or camera") # Sun/Sky BGL.glRasterPos2i(320,380) Draw.Text("Physical Sun/Sky settings") BGL.glRasterPos2i(340,355) Draw.Text("Sun:") Draw.Number("Turbidity:", evtNoEvt, 350, 325, 150, 18, getProp("vray_sunsky_turbidity", 3.0), 2, 20.0, "", setProp("vray_sunsky_turbidity")) Draw.Number("Ozone:", evtNoEvt, 350, 300, 150, 18, getProp("vray_sunsky_ozone", 0.35), 0, 1.0, "", setProp("vray_sunsky_ozone")) Draw.Number("Intensity:", evtNoEvt, 350, 275, 150, 18, getProp("vray_sunsky_intensity", 1.0), 0, 10.0, "", setProp("vray_sunsky_intensity")) Draw.Number("Size:", evtNoEvt, 350, 250, 150, 18, getProp("vray_sunsky_size_multiplier", 1.0), 0, 10.0, "", setProp("vray_sunsky_size_multiplier")) Draw.Number("Shadow subdivs:", evtNoEvt, 350, 225, 150, 18, getProp("vray_sunsky_shadow_subdivs", 3), 1, 64, "", setProp("vray_sunsky_shadow_subdivs")) Draw.Number("Shadow bias:", evtNoEvt, 350, 200, 150, 18, getProp("vray_sunsky_shadow_bias", 0.002), 0, 1.0, "", setProp("vray_sunsky_shadow_bias")) Draw.Number("Photon radius:", evtNoEvt, 350, 175, 150, 18, getProp("vray_sunsky_photon_emit_radius", 50.0), 0, 1000.0, "", setProp("vray_sunsky_photon_emit_radius")) Draw.Toggle("Invisible", evtNoEvt, 350, 150, 150, 18, getProp("vray_sunsky_invisible",0), "", setProp("vray_sunsky_invisible")) BGL.glRasterPos2i(515,355) Draw.Text("Sky:") Draw.Toggle("Auto", evtRedraw, 545, 352, 60, 14, getProp("vray_sunsky_skyauto",1), "", setProp("vray_sunsky_skyauto")) if (getProperty("vray_sunsky_skyauto") == 0): Draw.Number("Turbidity:", evtNoEvt, 525, 325, 120, 18, getProp("vray_sunsky_sky_turbidity", 3.0), 0, 20.0, "", setProp("vray_sunsky_sky_sky_turbidity")) Draw.Number("Ozone:", evtNoEvt, 525, 300, 120, 18, getProp("vray_sunsky_sky_ozone", 0.35), 0, 1.0, "", setProp("vray_sunsky_sky_ozone")) Draw.Number("Intensity:", evtNoEvt, 525, 275, 120, 18, getProp("vray_sunsky_sky_intensity", 1.0), 0, 10.0, "", setProp("vray_sunsky_sky_intensity")) Draw.Number("Size:", evtNoEvt, 525, 250, 120, 18, getProp("vray_sunsky_sky_size_multiplier", 1.0), 0, 10.0, "", setProp("vray_sunsky_sky_size_multiplier")) Draw.Toggle("Invisible", evtNoEvt, 525, 225, 120, 18, getProp("vray_sunsky_sky_invisible",0), "", setProp("vray_sunsky_sky_invisible")) ### GUI Drawing def drawGUI(): if getProperty("vray_gui_screen") == 0: drawVFB() if getProperty("vray_gui_screen") == 1: drawSampler() if getProperty("vray_gui_screen") == 2: drawGI() if getProperty("vray_gui_screen") == 3: drawDMCUtils() if getProperty("vray_gui_screen") == 4: drawCM() if getProperty("vray_gui_screen") == 5: drawSystem() if getProperty("vray_gui_screen") == 6: drawEnv() if getProperty("vray_gui_screen") == 7: DrawPhysical() ### Button events def buttonEvt(evt): if evt == evtExit: Draw.Exit() if evt == evtDrawVFB: setProperty("vray_gui_screen", 0) Draw.Redraw() if evt == evtDrawSampler: setProperty("vray_gui_screen", 1) Draw.Redraw() if evt == evtDrawGI: setProperty("vray_gui_screen", 2) Draw.Redraw() if evt == evtDrawUtils: setProperty("vray_gui_screen", 3) Draw.Redraw() if evt == evtDrawCM: setProperty("vray_gui_screen", 4) Draw.Redraw() if evt == evtDrawSystem: setProperty("vray_gui_screen", 5) Draw.Redraw() if evt == evtDrawEnv: setProperty("vray_gui_screen", 6) Draw.Redraw() if evt == evtDrawPhysical: setProperty("vray_gui_screen", 7) Draw.Redraw() if evt == evtRedraw: Draw.Redraw() if evt == evtExportGeom: getFilenames() writeGeometry() if evt == evtExport: getFilenames() writeScene() launchVRay() # if evt == evtBake: # bakeView(scenefile) ### Keyboard and mouse events def event(evt, val): if evt == Draw.ESCKEY: Draw.Exit() return Screen = getProp("vray_gui_screen", 0) Draw.Register(drawGUI, event, buttonEvt)