( /* ####################################################################################################################### Copyright (C) 2021 Martin Geupel (http://www.racoon-artworks.de) , All Rights Reserved Permission is hereby granted, free of charge, to any person obtaining a copy of this software (the "Software"), to use, copy, and/or distribute the software, subject to the following conditions: - The above copyright notice and this permission notice shall be included in all copies of the Software. - You may not misrepresent the name of the Original Author or the name of the Software. - You can distribute the Software only free of charge, you may not sell and/or rent the Software. - You may add functionality and/or modify existent functionaly if it is then clearly marked and noted in this Header. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ########################################################################################################################## supported materials: - Standardmaterial - VrayMtl - VRayLightMtl - VRayBlendMtl - VRay2SidedMtl - VRayOverrideMtl - VRayCarPaintMtl (basic) - VRayBumpMtl (basic) - VRayFastSSS (basic) - VRayFastSSS2 - VRaySkinMtl - CoronaMtl - CoronaLightMtl - CoronaLayeredMtl - CoronaRaySwitchMtl supported maps: - VRayHdri - VRayColor - VRayCompTex - VRayDirt - VRayNormalMap - VRayEdgesTex - VRaySky - VRayTriplanarTex - VRayGLSLTex (basic) - VRaySoftbox (basic) - VRayUserColor - VRayUserScalar - VRayColor2Bump - VRayBump2Normal (basic) - Normal_Bump - CoronaAO - CoronaBitmap - CoronaBumpConverter - CoronaColor - CoronaFrontBack - CoronaMix - CoronaNormal - CoronaSky - CoronaRaySwitch - CoronaRoundEdges - CoronaWire - CoronaTriplanar supported lights: - VRayLight - VRayIES - VRaySun - CoronaSun - CoronaLight TODO: - corona color correct - fix VrayColor gamma conversion - support animated color and intensity in lights - VRayALSurfaceMtl - VRayHairMtl - CoronaHairMtl - CoronaSkinMtl * VrayLight intensities revamp TODO Opt: * VrayDomelight o solve CoronaNormal gamma differences? o automatic bump tex addition? o CoronaOutput map? o VRayCurvature map (unsure how to deal with concave and convex) - add option to skip conversion of standard/arch materials - VrayBlend: multiply opacity on texturemap? - VRayMtlWrapper - CoronaShadowCatcherMtl - CoronaVolumeMtl - CoronaPortalMtl changelog: *v0.30 - [2021/06/24]------------------------------------------------------------------------------ - fixed BitmapTexture conversion for new ColorSpace feature - added .psd support for BitmapTexture conversion *v0.29 - [2019/04/27]------------------------------------------------------------------------------ - fixed colorRefract property error in standardmaterial conversion *v0.28 - [2019/04/02]------------------------------------------------------------------------------ - added an option for performing a more deep map class search (fixes missed maps in light sources) - added a simple tool for fixing normal map gamma *v0.27 - [2019/02/19]------------------------------------------------------------------------------ - fixed Arch___Design__mi conversion errors *v0.26 - [2019/02/13]------------------------------------------------------------------------------ - added a link to the forum discussion thread - fixed VrayOverrideMtl conversion crash *v0.25 - [2018/11/07]------------------------------------------------------------------------------ - added a link to the download page - RS_Bump_Map maps will now be used for the Bump slots in VrayNormalMap, Normal_Bump, CoronaNormal conversions - added a tool that adds RS_Bump_Map nodes to RS_Material, RS_Skin, RS_SSS material's bump slots if missing *v0.24 - [2018/10/15]------------------------------------------------------------------------------ - refactored class names to changes in 2.6.24 *v0.23 - [2018/10/08]------------------------------------------------------------------------------ - added proper Vray/Corona mapped reflection ior conversion - added proper Vray/Corona mapped refraction ior conversion - added support for VrayLight/CoronaLight include/exclude lists - completed VrayCompTex conversion modes - added CoronaMix divide mode conversion *v0.22 - [2018/08/13]------------------------------------------------------------------------------ - added tool for converting BitmapTextures to RedshiftBitmaps (jitter not supported) *v0.21 - [2018/07/24]------------------------------------------------------------------------------ - added directionality conversion of VrayLight and CoronaLight *v0.20 - [2018/07/23]------------------------------------------------------------------------------ - adapted script to new light class names in 2.6.16 *v0.19 - [2018/06/21]------------------------------------------------------------------------------ - fixed version check *v0.18 - [2018/04/24]------------------------------------------------------------------------------ - fixed VrayUserColor and VrayUserScalar conversions when no attribute name was specified *v0.17 - [2018/01/28]------------------------------------------------------------------------------ - fixed conversion of Vray Lights with meshes - was not a bug, I'm just stupid *v0.16 - [2018/01/28]------------------------------------------------------------------------------ - changed CoronaNormal conversion to use new RedshiftBumpMap functionality - changed Normal_Bump conversion to use new RedshiftBumpMap functionality - changed VrayNormalMap conversion to use new RedshiftBumpMap functionality - disabled conversion for Vray Lights with meshes due to a bug in the current Vray version *v0.15 - [2018/01/22]------------------------------------------------------------------------------ - fixed a bug in CoronaLight conversion when converting from lumen or lux - fixed standard mtl spec to refl option *v0.14 - [2018/01/11]------------------------------------------------------------------------------ - added button to convert opacity mapped RS_Materials to RS_Sprite Materials (experimental) - fixed crashes and all sorts of issues with relative/self-resolving texture map paths (like from an archived max scene) *v0.13 - [2017/12/10]------------------------------------------------------------------------------ - fixed map channel bug and improved CoronaNormal texture (added non-bitmap normal conversion) - improved VRayNormalMap texture (added non-bitmap normal conversion) *v0.12 - [2017/12/09]------------------------------------------------------------------------------ - fixed CoronaMtl opacity conversion - fixed skipping of CoronaSky conversion *v0.11 - [2017/12/04]------------------------------------------------------------------------------ - fixed enabled states in VrayOverrideMtl conversion *v0.10 - [2017/12/01]------------------------------------------------------------------------------ - fixed CoronaLight conversion: sphere type radius - added option for explicit glossiness conversion *v0.09 - [2017/11/23]------------------------------------------------------------------------------ - fixed maxscript error when converting maps displayed in active Material Editor slot (RS bug?) - added online check button - added CoronaRaySwitch conversion - added CoronaRoundEdges conversion - added CoronaWire conversion - added CoronaTriplanar conversion - added CoronaSun conversion - added CoronaLight conversion *v0.08 - [2017/11/21]------------------------------------------------------------------------------ - fixed class name collision of Redshift Physical light in max 2016+ *v0.07 - [2017/11/21]------------------------------------------------------------------------------ - added VrayHDRI UDIM conversion - fixed VrayDirt unoccluded texturemap wiring - added CoronaMtl conversion - added CoronaLightMtl conversion - added CoronaLayeredMtl conversion - added CoronaRaySwitchMtl conversion - added CoronaAO conversion - added CoronaBitmap conversion - added CoronaBumpConverter conversion - added CoronaColor conversion - added CoronaFrontBack conversion - added CoronaMix conversion - added CoronaNormal conversion - added CoronaSky conversion *v0.06 - [2017/11/17]------------------------------------------------------------------------------ - added very basic VRayFastSSS conversion - added VRayFastSSS2 conversion - added VRaySkinMtl conversion *v0.05 - [2017/11/16]------------------------------------------------------------------------------ - added "same object only" conversion for VrayDirt and VRayEdgesTex - added Redshift version check - added GI engine conversion - added basic VRayBumpMtl conversion - changed VRayColor2Bump conversion to use RS_Bump_Map - added basic VRayBump2Normal conversion *v0.04 - [2017/11/14]------------------------------------------------------------------------------ - fixed VrayMtl conversion error with missing roughness-glossiness switch in older Vray installations - fixed VRayBlendMtl conversion: blend texturemap slot was ignored *v0.03 - [2017/11/14]------------------------------------------------------------------------------ - added VRayColor2Bump conversion - fixed VRayNormalMap conversion error when bitmap does not exist - added support for bias, falloff and distribution conversion in VrayDirt - fixed max distance conversion for VrayDirt *v0.02 - [2017/11/13]------------------------------------------------------------------------------ - added Standardmaterial conversion - added basic VRayCarPaintMtl conversion (will be improved later) - added conversion functions for: VRaySky, VRayTriplanarTex, VRayUserColor, VRayUserScalar, Normal_Bump - added basic conversion functions for: VRayGLSLTex, VRaySoftbox *v0.01 - [2017/11/13]------------------------------------------------------------------------------ - Initial release known limitations: - BUMP MAPPING: Currently Vray/Corona use UV-space based bump height whereas Redshift bump height is world-space. This is a problem that can not be solved via script and requires assistance of the developers. - VrayMtl: Anisotropy orientation is not correct when texturemapped due to missing mod math op - VrayMtl: no translucency conversion yet - VrayMtl/CoronaMtl: mapped IOR is ignored due to missing inverse ior mapping in RS - VrayMtl/CoronaMtl: displacement maps are converted but turned off, due to Redshifts dependency on tesselation modifier - VRayBlendMtl: only 6 slots are currently converted (redshift blend limit), may implement nested blends - TODO: Vray2SidedMtl: currently only frontMtl supported. If BackMtl is specified it will be ignored. Will be added later. - VrayCompTex: conversion to Composite map. Unfortunately there is no Divide mode -_- . Major problem. - TODO: VrayNormalMap: No support for real-world-scale UVs (yet!) - TODO: VrayNormalMap: Only supports bitmaptexture inputs (yet) - TODO: VrayLight: Dome conversion - VRayLight: No include/exclude of objects due to missing maxscript access - show texture map in VP tools don't work with Redshift Materials, bug in RS - CoronaLight: Cylinder lights are offsetted by half of their height, need to add custom rule to deal with that ######################################################################################################################## */ global RSConverterSuppressGui global RSConverter struct RSConverterStr ( converterVersion = "0.30", -- miscellaneous functions converterSettings =( struct converterSettings ( standardMatSpecToRefl = true, vrayUseAdvBlinnToRedshiftGgxConversion = true, explicitGlossinessConversion = false, bitmapTextureToCoronaBitmap = false, addRedshiftPrefix = false, userPrefixStr = "RS.", clampDisp = false, clampDispAmount = 5.0, clampIor = false, clampIorAmount = 25.0, convertProxies = false, switchRenderEngine = false, miLightsToCrnLights = false, showMapsInVPselectedOnly = false, printInfo = true, silent = false, useTryCatchBugReporting = true, uiLinkColor = (if (colorMan.getColor #background).x < 0.5 then color 150 180 210 else color 0 80 200), -- colors for dark and light ui exposeDebugSettings = false, processChildNodes = false, -- used by getclassinstances in maps loop dialogPosX = 0, dialogPosY = 0, iniPath = "$plugcfg\\RedshiftConverter.ini", requiredBuildNumber = #(2, 6, 24), vrayBumpMultiplier = 0.3, gave3046__3047_clrSpaceWarning = false, vrayDirectionalityToCoronaDirectionality = #([1.0,1.0],[0.99,0.96],[0.98,0.88],[0.97,0.82],[0.96,0.78],[0.95,0.74],[0.94,0.72], [0.93,0.69],[0.92,0.68],[0.91,0.66],[0.9,0.65],[0.89,0.63],[0.88,0.62],[0.87,0.61],[0.86,0.6],[0.85,0.6],[0.84,0.59], [0.83,0.58],[0.82,0.57],[0.81,0.57],[0.8,0.56],[0.79,0.56],[0.78,0.55],[0.77,0.55],[0.76,0.54],[0.75,0.54],[0.74,0.53], [0.73,0.53],[0.72,0.52],[0.71,0.52],[0.7,0.51],[0.69,0.51],[0.68,0.51],[0.67,0.5],[0.66,0.5],[0.65,0.5],[0.64,0.49], [0.63,0.49],[0.62,0.49],[0.61,0.49],[0.6,0.48],[0.59,0.48],[0.58,0.48],[0.57,0.47],[0.56,0.47],[0.55,0.47],[0.54,0.47], [0.53,0.46],[0.52,0.46],[0.51,0.46],[0.5,0.46],[0.49,0.45],[0.48,0.45],[0.47,0.45],[0.46,0.45],[0.45,0.44],[0.44,0.44], [0.43,0.44],[0.42,0.44],[0.41,0.44],[0.4,0.43],[0.39,0.43],[0.38,0.43],[0.37,0.43],[0.36,0.42],[0.35,0.42],[0.34,0.42], [0.33,0.42],[0.32,0.41],[0.31,0.41],[0.3,0.41],[0.29,0.41],[0.28,0.41],[0.27,0.4],[0.26,0.4],[0.25,0.4],[0.24,0.4], [0.23,0.4],[0.22,0.39],[0.21,0.39],[0.2,0.39],[0.19,0.38],[0.18,0.38],[0.17,0.38],[0.16,0.38],[0.15,0.37],[0.14,0.37], [0.13,0.37],[0.12,0.36],[0.11,0.36],[0.1,0.36],[0.09,0.35],[0.08,0.35],[0.07,0.35],[0.06,0.34],[0.05,0.33],[0.04,0.33], [0.03,0.32],[0.02,0.31],[0.01,0.3],[0.0,0.0]), vrayBlinnToRedshiftGgxTable = #([1.0,1.0],[0.99,0.99],[0.98,09.98],[0.97,0.97],[0.96,0.95],[0.95,0.93],[0.94,0.91],[0.93,0.89], [0.92,0.88],[0.91,0.86],[0.9,0.85],[0.89,0.83],[0.88,0.82],[0.87,0.8],[0.86,0.79],[0.85,0.78],[0.84,0.76],[0.83,0.75], [0.82,0.74],[0.81,0.72],[0.8,0.71],[0.79,0.7],[0.78,0.68],[0.77,0.67],[0.76,0.66],[0.75,0.65],[0.74,0.63],[0.73,0.62], [0.72,0.61],[0.71,0.6],[0.7,0.59],[0.69,0.57],[0.68,0.56],[0.67,0.55],[0.66,0.54],[0.65,0.53],[0.64,0.51],[0.63,0.5], [0.62,0.49],[0.61,0.48],[0.6,0.47],[0.59,0.45],[0.58,0.44],[0.57,0.43],[0.56,0.42],[0.55,0.41],[0.54,0.4],[0.53,0.39], [0.52,0.37],[0.51,0.36],[0.5,0.35],[0.49,0.34],[0.48,0.33],[0.47,0.32],[0.46,0.31],[0.45,0.3],[0.44,0.28],[0.43,0.27], [0.42,0.26],[0.41,0.25],[0.4,0.24],[0.39,0.23],[0.38,0.22],[0.37,0.21],[0.36,0.2],[0.35,0.18],[0.34,0.17],[0.33,0.16], [0.32,0.15],[0.31,0.14],[0.3,0.13],[0.29,0.12],[0.28,0.11],[0.27,0.1],[0.26,0.09],[0.25,0.08],[0.24,0.06],[0.23,0.05], [0.22,0.04],[0.21,0.03],[0.2,0.02],[0.19,0.01],[0.18,0.01],[0.17,0.01],[0.16,0.01],[0.15,0.01],[0.14,0.01],[0.13,0.01], [0.12,0.01],[0.11,0.01],[0.1,0.01],[0.09,0.01],[0.08,0.01],[0.07,0.01],[0.06,0.01],[0.05,0.01],[0.04,0.01],[0.03,0.01], [0.02,0.01],[0.01,0.01]) ) converterSettings() ), fn getRedshiftBuildNumber =( try( rsVersion() )catch( #(0, 0, 0) ) ), converterTempData =( struct converterTempData ( owner, -- used to determine which classes will be converted, important supportedMtlClasses = #("Standardmaterial", "VRayMtl", "VRayLightMtl", "VRayBlendMtl", "VRay2SidedMtl", "VRayOverrideMtl", \ "VRayCarPaintMtl", "VRayBumpMtl", "VRayFastSSS", "VRayFastSSS2", "VRaySkinMtl", \ "CoronaMtl", "CoronaLightMtl", "CoronaLayeredMtl", "CoronaRaySwitchMtl"), supportedMapClasses = #("VRayHdri", "VRayColor", "VRayCompTex", "VRayDirt", "VRayNormalMap", "VRayEdgesTex", "VRaySky", \ "VRayTriplanarTex", "VRayGLSLTex", "VRaySoftbox", "VRayUserColor", "VRayUserScalar", "VRayColor2Bump", \ "VRayBump2Normal", "Normal_Bump",\ "CoronaAO", "CoronaBitmap", "CoronaBumpConverter", "CoronaColor", "CoronaFrontBack", "CoronaMix", \ "CoronaNormal", "CoronaSky", "CoronaRaySwitch", "CoronaRoundEdges", "CoronaWire", "CoronaTriplanar"), -- NOT used to determine which classes will be converted, just for information purposes supportedLightClasses = #("VRayLight", "VRayIES", "VRaySun", "CoronaSun", "CoronaLight"), glossyConversionOutputMapVrayBlinnRedshiftClGgx = undefined, glossyConversionOutputMapVrayGgxCoronaClGgx = undefined, AD_mats_found = false, foundPortals = false, orig_mtls=#(), new_mtls=#(), orig_maps=#(), new_maps=#(), orig_lights=#(), new_lights=#(), crnSkyPortalMtl, foundAdskMtls=#(), errorBuffer=#(), conversionTimeInfo = #(), redshiftBuildNumber = owner.getRedshiftBuildNumber() ) converterTempData owner:this ), fn isRedshiftVersionOfDateOrHigher =( instRsBuild = converterTempData.redshiftBuildNumber -- installed corona build reqRsBuild = converterSettings.requiredBuildNumber if instRsBuild[1] > reqRsBuild[1] do return true if instRsBuild[2] > reqRsBuild[2] do return true if instRsBuild[3] >= reqRsBuild[3] do return true false ), converterTools =( struct converterTools ( owner, private fn collectMaterialClasses =( myString = "" as stringstream showclass "*:material*" to:myString rawClass = filterstring (myString as string) "\n" rawClass = for elem in rawClass collect (filterstring elem ": ")[1] sort rawClass rawClass ), private fn recursiveShowMaps orig_mtl mode =( local sub_count=getNumSubMtls orig_mtl if sub_count >= 1 then ( for i=1 to sub_count do ( submtl = getSubMtl orig_mtl i if submtl != undefined do ( recursiveShowMaps submtl mode ) ) ) else( if classof orig_mtl == RS_Material then( try(showTextureMap orig_mtl mode)catch() ) ) ), private fn convertFrom_VrayDisplacementMod orig =( crnMod = CoronaDisplacementMod() crnMod.mapSource = 1 crnMod.texmap = orig.texmap local amount = orig.amount local shift = orig.shift local waterLvl = orig.waterLevelValue crnMod.levelMax = amount + shift crnMod.levelMin = shift if orig.waterLevelOn then( crnMod.useWaterLevel = true crnMod.waterLevel = (waterLvl - shift) / amount -- ((amount + shift) - shift) ) crnMod ), public fn showMapsInVP mode selected:false =( if not selected then( for o in (getclassinstances RS_Material) do( try(showTextureMap o mode)catch() ) ) else( for o in selection do( if o.material != undefined do( recursiveShowMaps o.material mode ) ) ) ), fn resetMtlEdit =( for i = 1 to 24 do( meditmaterials[i] = RS_Material name:((formattedPrint i format:".2d") + " - RedshiftMtl") ) ), fn convertVrayDisplacementMods =( local allMods = (getclassinstances VRayDisplacementMod) for dsplMod in allMods where (classof dsplMod == VRayDisplacementMod) do( replaceInstances dsplMod (convertFrom_VrayDisplacementMod dsplMod) ) ), fn getVersion =( owner.converterVersion ), fn convertOpacityToSpriteMtl =( rsMtls = getclassinstances RS_Material processAllAnimatables:false processChildren:false asTrackViewPick:false for mtl in rsMtls where (classof mtl == RS_Material) do ( if mtl.opacity_color_mapenable AND (classof mtl.opacity_color_map == bitmaptexture) AND mtl.opacity_color_mapamount > 99.0 do( sprMtl = RS_Sprite() sprMtl.name = (mtl.name + "_Spr") sprMtl.tex0 = mtl.opacity_color_map.bitmap --openBitMap mtl.opacity_color_map.fileName sprMtl.repeats_x = mtl.opacity_color_map.coords.U_Tiling sprMtl.repeats_y = mtl.opacity_color_map.coords.V_Tiling sprMtl.tspace_id = mtl.opacity_color_map.coords.mapChannel mtl.opacity_color_map = undefined mtl.opacity_color = white replaceInstances mtl sprMtl sprMtl.input_map = mtl ) ) ), fn convertBitmapToRSbitmap =( if classof renderers.current != Redshift_Renderer do( if queryBox "Redshift needs to be assigned as a renderer to properly convert ColorSpaces. Switch the renderer to Redshift?" then( local saveSettings = RSConverter.converterSettings.switchRenderEngine RSConverter.converterSettings.switchRenderEngine = true RSConverter.additionalSceneSetup() RSConverter.converterSettings.switchRenderEngine = saveSettings ) ) if classof renderers.current == Redshift_Renderer do( bitmapTexs = getclassinstances BitmapTexture processAllAnimatables:false processChildren:false asTrackViewPick:false for map in bitmapTexs where (classof map == BitmapTexture) do ( replacement = RSConverter.mapConvMethods.convertFrom_BitmapTexture map if replacement != #NoReplacement do( replaceInstances map (RSConverter.mapConvMethods.convertFrom_BitmapTexture map) ) ) ) ), fn addRsBumpMapToSlots =( rsMtls = getclassinstances RS_Material rsSSS = getclassinstances RS_SSS rsSkinMtl = getclassinstances RS_Skin allMtls = #() join allMtls rsMtls join allMtls rsSSS join allMtls rsSkinMtl for mtl in allMtls do( if mtl.bump_input_map != undefined do( case (classof mtl.bump_input_map) of ( RS_Bump_Map: () RS_Bump_Blender: () RS_Normal_Map: () default: mtl.bump_input_map = RS_Bump_Map input_map:mtl.bump_input_map ) ) ) ), fn checkForNewVersion =( if not owner.converterSettings.silent then ( rollout CheckOnlineRoll "Online version check" width:210 height:124 ( local publicVersion = undefined local dailyBuildsVersion = undefined local lastpos = [8,8] label lbl0 "This script version: " pos:(lastpos += [8,0]) align:#left label lbl1 "Latest versions on " pos:(lastpos += [0,20]) align:#left hyperlink hypDwnld "Converter website:" address:"http://www.racoon-artworks.de/RedshiftConverter/RedshiftConverter.html" pos:(lastpos += [92,0]) visitedColor:(color 150 180 210) color:(color 150 180 210) label lbl2 "public version: error" pos:(lastpos += [-92,20]) align:#left -- label lbl3 "daily builds version: error" pos:(lastpos += [0,20]) align:#left button btnClose "Close" pos:(lastpos += [39,24]) width:80 on btnClose pressed do destroyDialog CheckOnlineRoll on CheckOnlineRoll open do ( try( publicVersion = ((dotNetObject "System.Net.WebClient").downloadString "http://www.racoon-artworks.de/RedshiftConverter/version.txt") -- dailyBuildsVersion = ((dotNetObject "System.Net.WebClient").downloadString "http://www.racoon-artworks.de/RedshiftConverter/version_dailyBuilds.txt") lbl0.text = ("This script version: v" + owner.converterTools.getVersion()) lbl2.text = ("public version: v" + publicVersion) -- lbl3.text = ("daily builds version: v" + dailyBuildsVersion) )catch() ) ) createDialog CheckOnlineRoll #(#("public", CheckOnlineRoll.publicVersion), #("daily", CheckOnlineRoll.dailyBuildsVersion)) ) else( try( publicVersion = ((dotNetObject "System.Net.WebClient").downloadString "http://www.racoon-artworks.de/RedshiftConverter/version.txt") -- dailyBuildsVersion = ((dotNetObject "System.Net.WebClient").downloadString "http://www.racoon-artworks.de/RedshiftConverter/version_dailyBuilds.txt") -- #(#("public", publicVersion), #("daily", dailyBuildsVersion)) #(#("public", publicVersion)) )catch(undefined) ) ), fn fixNormalMapGamma map =( if classof map == RS_Bump_Map then( case classof map.input_map of( Bitmaptexture: ( if map.input_map.bitmap.gamma != 1.0 then ( map.input_map.bitmap = openBitmap map.input_map.bitmap.filename gamma:1.0 ) ) RS_Bitmap: ( if map.input_map.tex0.gamma != 1.0 then ( map.input_map.tex0_gammaoverride = true map.input_map.tex0_gamma = 1.0 ) ) ) ) ) ) converterTools owner:this ), fn scenematerialsUpdateHack =( -- DIRTY HACK to force max to save something and re-evaluate the scenematerials tree, so no "dead" classes will remain somewhere. -- if not done, e.g. Autodesk_Material warnings will pop up all the time if there was a Adsk mtl because it's still referenced somehwere. start = timeStamp() tempFile = GetDir #temp + "/_tempSceneMaterialsHack.max" saveNodes #() tempFile deleteFile tempFile end = timeStamp() if converterSettings.printInfo do format "INFO: UpdateFix took % seconds to complete\n" ((end - start) / 1000.0) ), fn createErrorReports =( rollout ErrorReportRollout "Error Report" width:400 height:500 ( local owner = if owner != undefined do owner local report label lbl1 "Conversion finished but one or more errors occured!" label lbl2 " Please save the ErrorReport.txt below and post it here:" hyperLink lnk "https://www.redshift3d.com/forums/viewthread/15634/" address:"https://www.redshift3d.com/forums/viewthread/15634/" color:owner.converterSettings.uiLinkColor visitedColor:owner.converterSettings.uiLinkColor offset:[50,0] dotNetControl edxErr "System.Windows.Forms.TextBox" pos:[0,60] width:400 height:400 button btnCopy "Save ErrorReport.txt" height:30 on ErrorReportRollout open do( edxErr.Multiline = true edxErr.ReadOnly = true edxErr.backcolor = edxErr.backcolor.FromArgb 60 60 60 edxErr.foreColor = edxErr.foreColor.FromArgb 255 120 0 rsV = owner.converterTempData.redshiftBuildNumber if not converterSettings.silent do( report = "" report += ">>> SCENE Info: <<<\r\n" report += "Redshift version: " + rsV[1] as string + "." + rsV[2] as string + "." + rsV[3] as string + "\r\n" report += "Converter version: " + owner.converterTools.getVersion() + "\r\n" report += "Max version: " + (maxversion())[1] as string + "\r\n" report += "Installed Vray plugins: " for i in RendererClass.classes where substring (i as string) 1 5 == "V_Ray" do report += i as string + " " report += "\r\n" for i in converterTempData.conversionTimeInfo do report += ("# " + i + "\r\n") report += "\r\n" for i in converterTempData.errorBuffer do report += (i + "\r\n\r\n") ErrorReportRollout.edxErr.text = report ) ) on btnCopy pressed do ( loc = getSavePath "Location to store ErrorReport.txt" if loc != undefined do ( file = createFile (pathConfig.appendPath loc "ErrorReport.txt") if file != undefined do format report to:file --edxErr.text close file ) ) ) ErrorReportRollout.owner = this if converterTempData.errorBuffer.count != 0 do ( createDialog ErrorReportRollout ) converterTempData.errorBuffer=#() converterTempData.conversionTimeInfo=#() ), fn errorCatching functionName orig =( errcls = classof orig if converterSettings.useTryCatchBugReporting then( try( out = functionName orig )catch( append converterTempData.errorBuffer ("Error occured in " + errcls as string + " : " + orig as string + "\r\n" + getCurrentException() ) out = orig ) )else( out = functionName orig ) out ), fn getGlossyConversionOutputMap type =( /* Most of the code in this function is taken from the cg-talk thread "Is it possible To Create and Edit Output Map Curve?" http://forums.cgsociety.org/showthread.php?f=98&t=993502 Thanks goes to denisT for sharing these great tech tips. */ outputmap = undefined backupMtl = undefined selectedSlot = undefined isEditOpen = undefined try(destroydialog easyCCurve) catch() rollout easyCCurve "Easy CCurve" width:208 height:215 ( fn mouseWindowMove hwnd x y sx sy = ( fn makeParam LoWord HiWord = ( bit.or (bit.shift HiWord 16) (bit.and LoWord 0xFFFF) ) WM_LBUTTONDOWN = 0x0201 WM_LBUTTONUP = 0x0202 WM_MOUSEMOVE = 0x0200 MK_LBUTTON = 0x0001 p0 = makeParam x y p1 = makeParam (x+sx) (y+sy) uiaccessor.sendmessage hwnd WM_LBUTTONDOWN 0 p0 uiaccessor.sendmessage hwnd WM_MOUSEMOVE MK_LBUTTON p1 uiaccessor.sendmessage hwnd WM_LBUTTONUP 0 p1 ) curveControl cc numcurves:1 width:200 height:200 pos:[4,4] \ zoomvalues:[200,100] scrollvalues:[4,2] uiFlags:#() rcmFlags:#() ) createdialog easyCCurve style:#() pos:[-1000,300] with redraw off ( d_hwnd = (windows.getChildHWND 0 easyCCurve.title)[1] c_hwnd = for w in (windows.getChildrenHWND d_hwnd) where w[4] == "DefCurveWindow" do exit with w[1] cc = easyCCurve.cc.curves[1] cc.color = black cc.numpoints = 4 pp = easyCCurve.cc.curves[1].points pp.selected = on case type of ( #VrayGgxToClampedGgx: ( -- depreciated cc.numpoints = 4 pp = easyCCurve.cc.curves[1].points pp.selected = on pp[1].value = [0,0.017] pp[2].value = [0.38,0.01] pp[2].outtangent = [0.01,0.135] pp[3].value = [0.65,0.375] pp[3].intangent = [-0.25,-0.175] pp[3].outtangent = [0.25,0.175] pp[4].value = [1.0,1.0] pp[4].intangent = [-0.06,-0.06] ) default: ( -- vray blinn to redshift ggx (new) cc.numpoints = 3 pp = easyCCurve.cc.curves[1].points pp.selected = on pp[1].value = [0,0.01] pp[2].value = [0.19,0.01] pp[2].outtangent = [0.45,0.48] pp[3].value = [1.0,1.0] pp[3].intangent = [-0.16,-0.25] ) ) -- make backups backupMtl = meditmaterials[1] selectedSlot = medit.GetActiveMtlSlot() isEditOpen = MatEditor.isOpen() matEditorMode = MatEditor.mode --mateditor.close() if matEditorMode == #advanced then ( MatEditor.mode = #basic ) -- Make Output Map outputmap = output name:"GlossyConversionBlinnToGGX" medit.PutMtlToMtlEditor outputmap 1 medit.SetActiveMtlSlot 1 on -- Init Mono_Color_Map mateditor.open() c = windows.getchildhwnd (windows.getchildhwnd 0 ("Material Editor - " + outputmap.name))[1] "Enable Color Map" BM_SETCHECKED = 0x00F1 UIAccessor.SendMessage c[1] BM_SETCHECKED 1 0 UIAccessor.PressButton c[1] -- Replace Curve replaceinstances outputmap.output.Mono_Color_Map.curve_1 easyCCurve.cc.curves[1][1].parent --medit.SetActiveMtlSlot 1 on -- restore backups medit.PutMtlToMtlEditor backupMtl 1 medit.SetActiveMtlSlot selectedSlot on if not isEditOpen do MatEditor.Close() MatEditor.mode = matEditorMode ) destroydialog easyCCurve free easyCCurve outputmap ), -- structs containing conversion methods for mtl, map, light classes matConvMethods =( struct matConvMethods ( owner, -- ############## Create Default Redshift Material ################ fn CreateDefaultRedshiftMtl origMtl =( r=RS_Material() r.name=(if owner.converterSettings.addRedshiftPrefix then owner.converterSettings.userPrefixStr else "") + origMtl.name r.refl_weight = 0 r ), -- ############## Standard Material ################ fn convertFrom_Standard origMtl =( r=RS_Material() r.name=(if owner.converterSettings.addRedshiftPrefix then owner.converterSettings.userPrefixStr else "") + origMtl.name origMtl.shaderType = 1 -- make sure standard mat shader type is set to default blinn --Diffuse r.diffuse_color=origMtl.diffuse r.diffuse_color_map=origMtl.diffuseMap if r.diffuse_color_map != undefined then( r.diffuse_color_mapenable=origMtl.diffuseMapEnable r.diffuse_color_mapamount=origMtl.diffuseMapAmount ) --Reflection if owner.converterSettings.standardMatSpecToRefl then( r.refl_weight = (if origMtl.specularLevel > 100.0 then 1.0 else origMtl.specularLevel / 100.0) r.refl_color = origMtl.specular r.refl_isGlossiness = true r.refl_roughness = sqrt (origMtl.glossiness / 100.0) if owner.converterSettings.explicitGlossinessConversion then( r.refl_isGlossiness = false r.refl_roughness = 1.0 - r.refl_roughness ) r.refl_color_map = origMtl.specularLevelMap -- default: uses specular level for reflection.. if r.refl_color_map != undefined then( r.refl_color_mapenable = origMtl.specularLevelMapEnable r.refl_color_mapamount = origMtl.specularLevelMapAmount ) if origMtl.reflectionMap != undefined do ( -- but will override if reflection map is supplied r.refl_color_map = origMtl.reflectionMap if r.refl_color_map != undefined then( r.refl_color_mapenable = origMtl.reflectionMapEnable r.refl_color_mapamount = origMtl.reflectionMapAmount ) ) r.refl_roughness_map = origMtl.glossinessMap if r.refl_roughness_map != undefined then( r.refl_roughness_mapenable = origMtl.glossinessMapEnable r.refl_roughness_mapamount = origMtl.glossinessMapAmount if owner.converterSettings.explicitGlossinessConversion then( r.refl_roughness_map = output MAP1:r.refl_roughness_map name:"glossiness_to_roughness" r.refl_roughness_map.output.invert = true ) ) if r.refl_roughness_map == undefined and r.refl_color_map == undefined and r.refl_weight == 0.0 and abs(origMtl.glossiness - 10.0) < 0.01 then( r.refl_roughness = 1.0 if owner.converterSettings.explicitGlossinessConversion then r.refl_roughness = 0.0 ) )else( r.refl_weight = 0.0 ) --Refraction r.refr_use_base_IOR = false r.refr_color_map = origMtl.refractionMap if r.refr_color_map != undefined then( r.refr_weight = 1.0 r.refr_color = color 0 0 0 r.refr_color_mapenable = origMtl.refractionMapEnable r.refr_color_mapamount = origMtl.refractionMapAmount ) r.refr_ior = if origMtl.ior < 1.0 then 1.0 else origMtl.ior --Bumpmap r.bump_input_map=origMtl.bumpMap if r.bump_input_map != undefined then( r.bump_input_mapenable=origMtl.bumpMapEnable r.bump_input_mapamount= origMtl.bumpMapAmount ) --Opacity r.opacity_color_map=origMtl.opacityMap if r.opacity_color_map != undefined then( r.opacity_color_mapenable=origMtl.opacityMapEnable r.opacity_color_mapamount=origMtl.opacityMapAmount ) --Emission r.emission_weight = if origMtl.useSelfIllumColor then 1.0 else (origMtl.selfIllumAmount / 100.0) r.emission_color = if origMtl.useSelfIllumColor then origMtl.selfIllumColor else r.diffuse_color r.emission_color_map = origMtl.selfillumMap if r.emission_color_map != undefined then( r.emission_color_mapenable = origMtl.selfillumMapEnable r.emission_color_mapamount = origMtl.selfillumMapAmount ) else( if origMtl.useSelfIllumColor == false AND origMtl.selfIllumAmount != 0 then( r.emission_color = r.diffuse_color if r.diffuse_color_mapenable then(r.emission_color_map = r.diffuse_color_map; r.emission_color_mapenable = true) ) ) --Displacement r.displacement_input_map=origMtl.displacementMap if r.displacement_input_map != undefined then( r.displacement_input_mapenable=false ) r ), -------------------------------------------- ------------------- VRAY ------------------- -------------------------------------------- -- ############## Vray Material ################ fn convertFrom_VrayMtl origMtl =( fn getMaxIOR =( if owner.converterSettings.clampIor then( owner.converterSettings.clampIorAmount )else( 100.0 ) ) fn getRedshiftGlossiness vrGlossVal curve =( local out local run = true local closest = 100.0 if vrGlossVal < 0.0 then( out = 0.0; run = false) if vrGlossVal > 1.0 then( out = 1.0; run = false) for dataPoint in curve while run do( local diff = (abs (vrGlossVal - dataPoint.x)) if diff > closest then( run = false )else( closest = diff out = dataPoint.y ) ) out ) fn createReflIorTree iormap =( local mixmap = Mix() mixmap.map1 = RS_Rcp input_map:iormap mixmap.map2 = iormap mixmap.mask = RS_Floor input_map:iormap mixmap ) r=RS_Material() r.name=(if owner.converterSettings.addRedshiftPrefix then owner.converterSettings.userPrefixStr else "") + origMtl.name --Diffuse r.diffuse_weight = 1.0 r.diffuse_color = origMtl.diffuse r.diffuse_color_map = origMtl.texmap_diffuse if r.diffuse_color_map != undefined then( r.diffuse_color_mapenable = origMtl.texmap_diffuse_on r.diffuse_color_mapamount = origMtl.texmap_diffuse_multiplier ) r.diffuse_roughness = origMtl.diffuse_roughness r.diffuse_roughness_map = origMtl.texmap_roughness if r.diffuse_roughness_map != undefined then( r.diffuse_roughness_mapenable = origMtl.texmap_roughness_on r.diffuse_roughness_mapamount = origMtl.texmap_roughness_multiplier ) --Reflection Clr/IOR if origMtl.reflection == black and origMtl.texmap_reflection == undefined then( -- to preserve Redshift defaults r.refl_weight = 0.0 r.refl_color = white )else( -- for all other cases, set reflection level to 1.0 r.refl_weight = 1.0 r.refl_color = origMtl.reflection ) r.refl_color_map = origMtl.texmap_reflection if r.refl_color_map != undefined then( r.refl_color_mapenable = origMtl.texmap_reflection_on r.refl_color_mapamount = origMtl.texmap_reflection_multiplier ) if origMtl.reflection_lockIOR then( r.refl_ior = if origMtl.refraction_ior < 1.0 then 1.0 else origMtl.refraction_ior ) else( r.refl_ior = if origMtl.reflection_ior < 1.0 then 1.0 else origMtl.reflection_ior ) if origMtl.reflection_fresnel == false then( r.refl_ior = getMaxIOR() -- normally 100.0 for non-fresnel-activated mats --can be overridden by user ) if origMtl.texmap_reflectionIOR != undefined then( r.refl_ior_map = createReflIorTree origMtl.texmap_reflectionIOR ) if r.refl_ior_map != undefined then( r.refl_ior_mapenable = origMtl.texmap_reflectionIOR_on r.refl_ior_mapamount = origMtl.texmap_reflectionIOR_multiplier ) --Reflection Roughness r.refl_brdf = 1 -- set to GGX by default r.refl_isGlossiness = true if hasProperty origMtl "brdf_useRoughness" then( if origMtl.brdf_useRoughness then( -- if vray is set to use roughness instead of glossiness r.refl_isGlossiness = false ) ) if origMtl.brdf_type == 4 then( -- Vray GGX r.refl_roughness = origMtl.reflection_glossiness )else( -- all others -> default Blinn if owner.converterSettings.vrayUseAdvBlinnToRedshiftGgxConversion then( r.refl_roughness = getRedshiftGlossiness origMtl.reflection_glossiness owner.converterSettings.vrayBlinnToRedshiftGgxTable r.refl_roughness = (r.refl_roughness * 100) as integer / 100.0 -- clamps to 2 decimals )else( r.refl_roughness = origMtl.reflection_glossiness ) ) r.refl_roughness_map = origMtl.texmap_reflectionGlossiness if r.refl_roughness_map != undefined then( if origMtl.brdf_type != 4 and owner.converterSettings.vrayUseAdvBlinnToRedshiftGgxConversion then( -- everything not vray ggx outmp if owner.converterTempData.glossyConversionOutputMapVrayBlinnRedshiftClGgx == undefined do( owner.converterTempData.glossyConversionOutputMapVrayBlinnRedshiftClGgx = owner.getGlossyConversionOutputMap #VrayBlinnToRedshiftGgx ) outmp = copy owner.converterTempData.glossyConversionOutputMapVrayBlinnRedshiftClGgx outmp.map1 = r.refl_roughness_map r.refl_roughness_map = outmp ) r.refl_roughness_mapenable = origMtl.texmap_reflectionGlossiness_on r.refl_roughness_mapamount = origMtl.texmap_reflectionGlossiness_multiplier if r.refl_isGlossiness and owner.converterSettings.explicitGlossinessConversion then( r.refl_roughness_map = output MAP1:r.refl_roughness_map name:"glossiness_to_roughness" r.refl_roughness_map.output.invert = true ) ) if r.refl_isGlossiness and owner.converterSettings.explicitGlossinessConversion then( r.refl_isGlossiness = false r.refl_roughness = 1.0 - r.refl_roughness ) --Refraction if origMtl.refraction == black and origMtl.texmap_refraction == undefined then( -- to preserve Redshift defaults r.refr_weight = 0.0 r.refr_color = white )else( -- for all other cases, set refraction level to 1.0 r.refr_weight = 1.0 r.refr_color = origMtl.refraction ) r.refr_color_map = origMtl.texmap_refraction if r.refr_color_map != undefined then( r.refr_color_mapenable = origMtl.texmap_refraction_on r.refr_color_mapamount = origMtl.texmap_refraction_multiplier ) r.refr_use_base_IOR = false -- unlock refr and refl iors r.refr_ior = if origMtl.refraction_ior < 1.0 then 1.0 else(if origMtl.refraction_ior > 2.5 then 2.5 else origMtl.refraction_ior) if origMtl.texmap_refractionIOR != undefined then( r.refr_ior_map = createReflIorTree origMtl.texmap_refractionIOR ) if r.refr_ior_map != undefined then( r.refr_ior_mapenable = origMtl.texmap_refractionIOR_on r.refr_ior_mapamount = origMtl.texmap_refractionIOR_multiplier ) -- Refraction Glossiness r.refr_isGlossiness = true if hasProperty origMtl "brdf_useRoughness" then( if origMtl.brdf_useRoughness then( -- if vray is set to use roughness instead of glossiness r.refr_isGlossiness = false ) ) if origMtl.brdf_type == 4 then( -- Vray GGX r.refr_roughness = origMtl.refraction_glossiness )else( -- all others -> default Blinn if owner.converterSettings.vrayUseAdvBlinnToRedshiftGgxConversion then( r.refr_roughness = getRedshiftGlossiness origMtl.refraction_glossiness owner.converterSettings.vrayBlinnToRedshiftGgxTable r.refr_roughness = (r.refr_roughness * 100) as integer / 100.0 -- clamps to 2 decimals ) else( r.refr_roughness = origMtl.refraction_glossiness ) ) r.refr_roughness_map = origMtl.texmap_refractionGlossiness if r.refr_roughness_map != undefined then( if origMtl.brdf_type != 4 and owner.converterSettings.vrayUseAdvBlinnToRedshiftGgxConversion then ( outmp if owner.converterTempData.glossyConversionOutputMapVrayBlinnRedshiftClGgx == undefined do( owner.converterTempData.glossyConversionOutputMapVrayBlinnRedshiftClGgx = owner.getGlossyConversionOutputMap #VrayBlinnToRedshiftGgx ) outmp = copy owner.converterTempData.glossyConversionOutputMapVrayBlinnRedshiftClGgx outmp.map1 = r.refr_roughness_map r.refr_roughness_map = outmp ) r.refr_roughness_mapenable = origMtl.texmap_refractionGlossiness_on r.refr_roughness_mapamount = origMtl.texmap_refractionGlossiness_multiplier if r.refr_isGlossiness and owner.converterSettings.explicitGlossinessConversion then( r.refr_roughness_map = output MAP1:r.refr_roughness_map name:"glossiness_to_roughness" r.refr_roughness_map.output.invert = true ) ) if r.refr_isGlossiness and owner.converterSettings.explicitGlossinessConversion then( r.refr_isGlossiness = false r.refr_roughness = 1.0 - r.refr_roughness ) --Opacity r.opacity_color = (color 255 255 255) r.opacity_color_map = origMtl.texmap_opacity if r.opacity_color_map != undefined then( r.opacity_color_mapenable = origMtl.texmap_opacity_on r.opacity_color_mapamount = origMtl.texmap_opacity_multiplier ) --Bumpmap r.bump_input_map = origMtl.texmap_bump if r.bump_input_map != undefined then( local texmapClass = classof r.bump_input_map local isNormalMap = (texmapClass == VrayNormalMap or texmapClass == CoronaNormal or texmapClass == Normal_Bump) r.bump_input_mapenable = origMtl.texmap_bump_on r.bump_input_mapamount = origMtl.texmap_bump_multiplier * (if isNormalMap then 1.0 else owner.converterSettings.vrayBumpMultiplier) ) --Absorption if origMtl.refraction_fogColor != white OR origMtl.texmap_refraction_fog != undefined then( r.refr_transmittance = origMtl.refraction_fogColor r.refr_absorption_scale = origMtl.refraction_fogMult ) r.refr_transmittance_map = origMtl.texmap_refraction_fog if r.refr_transmittance_map != undefined then( r.refr_transmittance_mapenable = origMtl.texmap_refraction_fog_on r.refr_transmittance_mapamount = origMtl.texmap_refraction_fog_multiplier ) --Translucency --TODO --Anisotropy r.refl_aniso = origMtl.anisotropy / 2.0 if origMtl.texmap_anisotropy != undefined then( r.refl_aniso_map = output name:"VrayAdaption" map1:origMtl.texmap_anisotropy output_amount:0.5 ) if r.refl_aniso_map != undefined then( r.refl_aniso_mapenable = origMtl.texmap_anisotropy_on r.refl_aniso_mapamount = origMtl.texmap_anisotropy_multiplier ) --Anisotropy Rotation r.refl_aniso_rotation = mod (origMtl.anisotropy_rotation + 0.25) 1.0 -- add 0.25 to rotate 90 degrees (different axis in redshift) r.refl_aniso_rotation_map = origMtl.texmap_anisotropy_rotation -- currently ignoring the 0.25 offset from above due to missing mod math operator if r.refl_aniso_rotation_map != undefined then( r.refl_aniso_rotation_mapenable = origMtl.texmap_anisotropy_rotation_on r.refl_aniso_rotation_mapamount = origMtl.texmap_anisotropy_rotation_multiplier ) r.anisotropy_tangentChannel = origMtl.anisotropy_channel --Displacement r.displacement_input_map = origMtl.texmap_displacement if r.displacement_input_map != undefined then( -- r.displacement_input_mapenable = origMtl.texmap_displacement_on r.displacement_input_mapenable = false ) --SelfIllumination if hasProperty origMtl #selfIllumination then( if origMtl.selfIllumination == black and origMtl.texmap_self_illumination == undefined then() else( r.emission_weight = origMtl.selfIllumination_multiplier r.emission_color = origMtl.selfIllumination r.emission_color_map = origMtl.texmap_self_illumination if r.emission_color_map != undefined then( r.emission_color_mapenable = origMtl.texmap_self_illumination_on r.emission_color_mapamount = origMtl.texmap_self_illumination_multiplier ) ) ) r ), -- ############## VrayLight Material ################ fn convertFrom_VrayLightMtl origMtl =( r=RS_Incandescent() r.name=(if owner.converterSettings.addRedshiftPrefix then owner.converterSettings.userPrefixStr else "") + origMtl.name r.applyExposureCompensation = origMtl.compensate_exposure r.DoubleSided = origMtl.twoSided r.color = origMtl.color r.intensity = origMtl.multiplier if origMtl.texmap != undefined then( r.color_mapenable = origMtl.texmap_on r.color_Map = origMtl.texmap ) if origMtl.opacity_texmap != undefined then( r.alpha_mapenable = origMtl.opacity_texmap_on r.alpha_map = origMtl.opacity_texmap ) r ), -- ############## VrayBlend Material ################ fn convertFrom_VrayBlendMtl origMtl =( r=RS_Material_Blender() r.name=(if owner.converterSettings.addRedshiftPrefix then owner.converterSettings.userPrefixStr else "") + origMtl.name r.baseColor_map = origMtl.baseMtl r.layerColor1_map = origMtl.coatMtl[1] r.blendColor1 = origMtl.Blend[1] r.blendColor1_map = origMtl.texmap_blend[1] r.layerColor2_map = origMtl.coatMtl[2] r.blendColor2 = origMtl.Blend[2] r.blendColor2_map = origMtl.texmap_blend[2] r.layerColor3_map = origMtl.coatMtl[3] r.blendColor3 = origMtl.Blend[3] r.blendColor3_map = origMtl.texmap_blend[3] r.layerColor4_map = origMtl.coatMtl[4] r.blendColor4 = origMtl.Blend[4] r.blendColor4_map = origMtl.texmap_blend[4] r.layerColor5_map = origMtl.coatMtl[5] r.blendColor5 = origMtl.Blend[5] r.blendColor5_map = origMtl.texmap_blend[5] r.layerColor6_map = origMtl.coatMtl[6] r.blendColor6 = origMtl.Blend[6] r.blendColor6_map = origMtl.texmap_blend[6] if origMtl.additiveMode then( r.additiveMode1 = true r.additiveMode2 = true r.additiveMode3 = true r.additiveMode4 = true r.additiveMode5 = true r.additiveMode6 = true ) if hasProperty origMtl #coatMtl_enable then( -- Vray 3.3 layerColor1_mapenable = origMtl.coatMtl_enable[1] layerColor2_mapenable = origMtl.coatMtl_enable[2] layerColor3_mapenable = origMtl.coatMtl_enable[3] layerColor4_mapenable = origMtl.coatMtl_enable[4] layerColor5_mapenable = origMtl.coatMtl_enable[5] layerColor6_mapenable = origMtl.coatMtl_enable[6] ) r ), -- ############## Vray2Sided Material ################ fn convertFrom_Vray2sidedMtl origMtl =( r = undefined if origMtl.Translucency == black and origMtl.texmap_translucency == undefined and not origMtl.backMtlOn then( r=RS_Ray_Switch_Material() r.name=(if owner.converterSettings.addRedshiftPrefix then owner.converterSettings.userPrefixStr else "") + origMtl.name r.cameraSwitchFrontBack = true r.cameraColor_map = origMtl.frontMtl r.cameraColorBack_map = origMtl.backMtl )else( r = origMtl.frontMtl if classof r == RS_Material then( r.transl_weight = 1.0 r.transl_color = origMtl.Translucency r.transl_color_map = origMtl.texmap_translucency r.transl_color_mapamount = origMtl.texmap_translucency_multiplier -- TODO: rayswitch maps for back/front --if not origMtl.backMtlOn then()else() ) ) r ), -- ############## VrayOverrideMtl Material ################ fn convertFrom_VrayOverrideMtl origMtl =( r=RS_Ray_Switch_Material() r.name=(if owner.converterSettings.addRedshiftPrefix then owner.converterSettings.userPrefixStr else "") + origMtl.name r.cameraColor_map = origMtl.baseMtl r.giColor_map = origMtl.giMtl r.giSwitch = r.giColor_map != undefined and origMtl.giMtl_on r.reflectionColor_map = origMtl.reflectMtl r.reflectionSwitch = r.reflectionColor_map != undefined and origMtl.reflectMtl_on r.refractionColor_map = origMtl.refractMtl r.refractionSwitch = r.refractionColor_map != undefined and origMtl.refractMtl_on r ), -- ############## VrayBumpMtl Material ################ fn convertFrom_VrayBumpMtl origMtl =( r=origMtl.base_mtl r ), -- ############## VRayCarpaint Material ################ fn convertFrom_VRayCarPaintMtl origMtl =( r=RS_Car_Paint() r.name=(if owner.converterSettings.addRedshiftPrefix then owner.converterSettings.userPrefixStr else "") + origMtl.name r.base_color = origMtl.base_color r.base_color_map = origMtl.base_color_shortmap if r.base_color_map != undefined then( r.base_color_mapenable = origMtl.texmap_base_color_on r.base_color_mapamount = origMtl.texmap_base_color_multiplier ) r.spec_gloss = origMtl.base_glossiness r.clearcoat_gloss = origMtl.coat_glossiness r.bump_input_map = origMtl.texmap_base_bump if r.bump_input_map != undefined then( r.bump_input_mapenable = origMtl.texmap_base_bump_on r.bump_input_mapamount = origMtl.texmap_base_bump_multiplier * owner.converterSettings.vrayBumpMultiplier ) r ), -- ############## VRayFastSSS Material ################ fn convertFrom_VRayFastSSS origMtl =( r=RS_Material() r.name=(if owner.converterSettings.addRedshiftPrefix then owner.converterSettings.userPrefixStr else "") + origMtl.name r.diffuse_color = origMtl.shallow_color r.refl_weight = 0 r ), -- ############## VRayFastSSS2 Material ################ fn convertFrom_VRayFastSSS2 origMtl =( r=RS_SSS() r.name=(if owner.converterSettings.addRedshiftPrefix then owner.converterSettings.userPrefixStr else "") + origMtl.name r.scale = origMtl.scale r.ior = origMtl.ior -- SSS r.sub_surface_color = origMtl.sub_surface_color r.sub_surface_color_map = origMtl.texmap_sss_color if r.sub_surface_color_map != undefined then( r.sub_surface_color_mapenable = origMtl.texmap_sss_color_on r.sub_surface_color_mapamount = origMtl.texmap_sss_color_multiplier ) r.scatter_color = origMtl.scatter_color r.scatter_color_map = origMtl.texmap_scatter_color if r.scatter_color_map != undefined then( r.scatter_color_mapenable = origMtl.texmap_scatter_color_on r.scatter_color_mapamount = origMtl.texmap_scatter_color_multiplier ) -- Radius r.scatter_radius = origMtl.scatter_radius if origMtl.texmap_scatter_radius != undefined do( r.scatter_radius_map = output map1:origMap.texmap_scatter_radius r.scatter_radius_map.output.output_amount = r.scatter_radius -- map needs to be multiplied by maxdistance param r.scatter_radius_mapenable = origMtl.texmap_scatter_radius_on r.scatter_radius_mapamount = origMtl.texmap_scatter_radius_multiplier ) -- Diffuse if origMtl.diffuse_amount > 0.0 or origMtl.diffuse_amount_shortmap != undefined then( r.diffuse_amount = origMtl.diffuse_amount r.diffuse_amount_map = diffuse_amount_shortmap if r.diffuse_amount_map != undefined then( r.diffuse_amount_mapenable = origMtl.texmap_diffuse_amount_on r.diffuse_amount_mapamount = origMtl.texmap_diffuse_amount_multiplier ) local clrMix = mix() clrMix.color2 = origMtl.diffuse_color clrMix.color1 = r.sub_surface_color clrMix.mixAmount = r.diffuse_amount * 100.0 clrMix.mask = origMtl.texmap_diffuse_amount if origMtl.texmap_diffuse_color != undefined then( clrMix.map2 = origMtl.texmap_diffuse_color clrMix.map1 = r.sub_surface_color_map ) r.sub_surface_color_map = clrMix ) -- Reflection r.refl_color = origMtl.specular_color r.refl_color_map = origMtl.texmap_specular_color if r.refl_color_map != undefined then( r.refl_color_mapenable = origMtl.texmap_specular_color_on r.refl_color_mapamount = origMtl.texmap_specular_color_multiplier ) r.reflectivity = origMtl.specular_amount r.reflectivity_map = origMtl.texmap_specular_amount if r.refl_color_map != undefined then( r.reflectivity_mapenable = origMtl.texmap_specular_amount_on r.reflectivity_mapamount = origMtl.texmap_specular_amount_multiplier ) -- glossiness r.refl_gloss = origMtl.specular_glossiness r.refl_gloss_map = origMtl.texmap_specular_glossiness if r.refl_gloss_map != undefined then( r.refl_gloss_mapenable = origMtl.texmap_specular_glossiness_on r.refl_gloss_mapamount = origMtl.texmap_specular_glossiness_multiplier ) --bumpmap r.bump_input_map = origMtl.texmap_bump if r.bump_input_map != undefined then( r.bump_input_mapenable = origMtl.texmap_bump_on r.bump_input_mapamount = origMtl.texmap_bump_multiplier * owner.converterSettings.vrayBumpMultiplier ) --displacement r.displacement_input_map = origMtl.texmap_displacement if r.displacement_input_map != undefined then( r.displacement_input_mapenable = false r.displacement_input_mapamount = origMtl.texmap_displacement_multiplier ) r ), -- ############## VRaySkinMtl Material ################ fn convertFrom_VRaySkinMtl origMtl =( r=RS_Skin() r.name=(if owner.converterSettings.addRedshiftPrefix then owner.converterSettings.userPrefixStr else "") + origMtl.name r.radius_scale = origMtl.scale r.overall_scale = origMtl.max_sss_amount r.overall_scale_map = origMtl.texmap_sss_amount if r.overall_scale_map != undefined then( r.overall_scale_mapenable = origMtl.texmap_sss_amount_on r.overall_scale_mapamount = origMtl.texmap_sss_amount_multiplier ) -- shallow scattering r.shallow_color = origMtl.shallow_color r.shallow_color_map = origMtl.texmap_shallow_color if r.shallow_color_map != undefined then( r.shallow_color_mapenable = origMtl.texmap_shallow_color_on r.shallow_color_mapamount = origMtl.texmap_shallow_color_multiplier ) r.shallow_radius = origMtl.shallow_radius r.shallow_radius_map = origMtl.texmap_shallow_radius if r.shallow_radius_map != undefined then( r.shallow_radius_map = output map1:r.shallow_radius_map r.shallow_radius_map.output.output_amount = r.shallow_radius -- map needs to be multiplied by maxdistance param r.shallow_radius_mapenable = origMtl.texmap_shallow_radius_on r.shallow_radius_mapamount = origMtl.texmap_shallow_radius_multiplier ) r.shallow_weight = if origMtl.shallow_amount > 1.0 then 1.0 else origMtl.shallow_amount r.shallow_weight_map = origMtl.texmap_shallow_amount if r.shallow_weight_map != undefined then( r.shallow_weight_mapenable = origMtl.texmap_shallow_amount_on r.shallow_weight_mapamount = origMtl.texmap_shallow_amount_multiplier ) -- Diffuse if origMtl.diffuse_amount > 0.0 or origMtl.texmap_diffuse_amount != undefined then( r.diffuse_amount = origMtl.diffuse_amount r.diffuse_amount_map = texmap_diffuse_amount if r.diffuse_amount_map != undefined then( r.diffuse_amount_mapenable = origMtl.texmap_diffuse_amount_on r.diffuse_amount_mapamount = origMtl.texmap_diffuse_amount_multiplier ) local clrMix = mix() clrMix.color2 = origMtl.diffuse_color clrMix.color1 = r.shallow_color clrMix.mixAmount = r.diffuse_amount * 100.0 clrMix.mask = origMtl.texmap_diffuse_amount if origMtl.texmap_diffuse_color != undefined then( clrMix.map2 = origMtl.texmap_diffuse_color clrMix.map1 = r.shallow_color_map ) r.shallow_color_map = clrMix ) -- medium scattering r.mid_color = origMtl.medium_color r.mid_color_map = origMtl.texmap_medium_color if r.mid_color_map != undefined then( r.mid_color_mapenable = origMtl.texmap_medium_color_on r.mid_color_mapamount = origMtl.texmap_medium_color_multiplier ) r.mid_radius = origMtl.medium_radius r.mid_radius_map = origMtl.texmap_medium_radius if r.mid_radius_map != undefined then( r.mid_radius_map = output map1:r.mid_radius_map r.mid_radius_map.output.output_amount = r.mid_radius -- map needs to be multiplied by maxdistance param r.mid_radius_mapenable = origMtl.texmap_medium_radius_on r.mid_radius_mapamount = origMtl.texmap_medium_radius_multiplier ) r.mid_weight = if origMtl.medium_amount > 1.0 then 1.0 else origMtl.medium_amount r.mid_weight_map = origMtl.texmap_medium_amount if r.mid_weight_map != undefined then( r.mid_weight_mapenable = origMtl.texmap_medium_amount_on r.mid_weight_mapamount = origMtl.texmap_medium_amount_multiplier ) -- deep scattering r.deep_color = origMtl.deep_color r.deep_color_map = origMtl.texmap_deep_color if r.deep_color_map != undefined then( r.deep_color_mapenable = origMtl.texmap_deep_color_on r.deep_color_mapamount = origMtl.texmap_deep_color_multiplier ) r.deep_radius = origMtl.deep_radius r.deep_radius_map = origMtl.texmap_deep_radius if r.deep_radius_map != undefined then( r.deep_radius_map = output map1:r.deep_radius_map r.deep_radius.output.output_amount = r.deep_radius -- map needs to be multiplied by maxdistance param r.deep_radius_mapenable = origMtl.texmap_deep_radius_on r.deep_radius_mapamount = origMtl.texmap_deep_radius_multiplier ) r.deep_weight = if origMtl.deep_amount > 1.0 then 1.0 else origMtl.deep_amount r.deep_weight_map = origMtl.texmap_deep_amount if r.deep_weight_map != undefined then( r.deep_weight_mapenable = origMtl.texmap_deep_amount_on r.deep_weight_mapamount = origMtl.texmap_deep_amount_multiplier ) -- primary reflection r.refl_color0 = origMtl.primary_reflection_color r.refl_color0_map = origMtl.texmap_primary_reflection_color if r.refl_color0_map != undefined then( r.refl_color0_mapenable = origMtl.texmap_primary_reflection_color_on r.refl_color0_mapamount = origMtl.texmap_primary_reflection_color_multiplier ) r.refl_weight0 = origMtl.primary_reflection_amount r.refl_weight0_map = origMtl.texmap_primary_reflection_amount if r.refl_weight0_map != undefined then( r.refl_weight0_mapenable = origMtl.texmap_primary_reflection_amount_on r.refl_weight0_mapamount = origMtl.texmap_primary_reflection_amount_multiplier ) r.refl_gloss0 = origMtl.primary_reflection_glossiness r.refl_gloss0_map = origMtl.texmap_primary_reflection_glossiness if r.refl_gloss0_map != undefined then( r.refl_gloss0_mapenable = origMtl.texmap_primary_reflection_glossiness_on r.refl_gloss0_mapamount = origMtl.texmap_primary_reflection_glossiness_multiplier ) r.refl_ior0 = origMtl.primary_reflection_fresnel_ior -- secondary reflection r.refl_color1 = origMtl.secondary_reflection_color r.refl_color1_map = origMtl.texmap_secondary_reflection_color if r.refl_color1_map != undefined then( r.refl_color1_mapenable = origMtl.texmap_secondary_reflection_color_on r.refl_color1_mapamount = origMtl.texmap_secondary_reflection_color_multiplier ) r.refl_weight1 = origMtl.secondary_reflection_amount r.refl_weight1_map = origMtl.texmap_secondary_reflection_amount if r.refl_weight1_map != undefined then( r.refl_weight1_mapenable = origMtl.texmap_secondary_reflection_amount_on r.refl_weight1_mapamount = origMtl.texmap_secondary_reflection_amount_multiplier ) r.refl_gloss1 = origMtl.secondary_reflection_glossiness r.refl_gloss1_map = origMtl.texmap_secondary_reflection_glossiness if r.refl_gloss1_map != undefined then( r.refl_gloss1_mapenable = origMtl.texmap_secondary_reflection_glossiness_on r.refl_gloss1_mapamount = origMtl.texmap_secondary_reflection_glossiness_multiplier ) r.refl_ior1 = origMtl.secondary_reflection_fresnel_ior --bump r.bump_input_map = origMtl.texmap_bump if r.bump_input_map != undefined then( r.bump_input_mapenable = origMtl.texmap_bump_on r.bump_input_mapamount = origMtl.texmap_bump_multiplier * owner.converterSettings.vrayBumpMultiplier ) --displacement r.displacement_input_map = origMtl.texmap_displacement if r.displacement_input_map != undefined then( r.displacement_input_mapenable = false r.displacement_input_mapamount = origMtl.texmap_displacement_multiplier ) r ), -------------------------------------------- ------------------ CORONA ------------------ -------------------------------------------- -- ############## CoronaMtl Material ################ fn convertFrom_CoronaMtl origMtl =( r=RS_Material() r.name=(if owner.converterSettings.addRedshiftPrefix then owner.converterSettings.userPrefixStr else "") + origMtl.name fn createReflIorTree iormap =( local mixmap = Mix() mixmap.map1 = RS_Rcp input_map:iormap mixmap.map2 = iormap mixmap.mask = RS_Floor input_map:iormap mixmap ) --Diffuse r.diffuse_weight = origMtl.levelDiffuse r.diffuse_color = origMtl.colorDiffuse r.diffuse_color_map = origMtl.texmapDiffuse if r.diffuse_color_map != undefined then( r.diffuse_color_mapenable = origMtl.texmapOnDiffuse r.diffuse_color_mapamount = origMtl.mapAmountDiffuse ) --Reflection Clr/IOR if origMtl.colorReflect == black and origMtl.texmapReflect == undefined then( -- to preserve Redshift defaults r.refl_weight = 0.0 r.refl_color = white )else( -- for all other cases r.refl_weight = origMtl.levelReflect r.refl_color = origMtl.colorReflect ) r.refl_color_map = origMtl.texmapReflect if r.refl_color_map != undefined then( r.refl_color_mapenable = origMtl.texmapOnReflect r.refl_color_mapamount = origMtl.mapamountReflect ) r.refl_ior = if origMtl.fresnelIor < 1.0 then 1.0 else origMtl.fresnelIor if origMtl.texmapFresnelIor != undefined then( r.refl_ior_map = createReflIorTree origMtl.texmapFresnelIor ) if r.refl_ior_map != undefined then( r.refl_ior_mapenable = origMtl.texmapOnFresnelIor r.refl_ior_mapamount = origMtl.mapamountFresnelIor ) --Reflection Roughness r.refl_brdf = 1 -- set to GGX by default r.refl_isGlossiness = true r.refl_roughness = origMtl.reflectGlossiness if owner.converterSettings.explicitGlossinessConversion then( r.refl_isGlossiness = false r.refl_roughness = 1.0 - r.refl_roughness ) r.refl_roughness_map = origMtl.texmapReflectGlossiness if r.refl_roughness_map != undefined then( r.refl_roughness_mapenable = origMtl.texmapOnReflectGlossiness r.refl_roughness_mapamount = origMtl.mapamountReflectGlossiness if owner.converterSettings.explicitGlossinessConversion then( r.refl_roughness_map = output MAP1:r.refl_roughness_map name:"glossiness_to_roughness" r.refl_roughness_map.output.invert = true ) ) --Refraction r.refr_thin_walled = origMtl.thin if origMtl.colorRefract == black and origMtl.texmapRefract == undefined then( -- to preserve Redshift defaults r.refr_weight = 0.0 r.refr_color = white )else( -- for all other cases r.refr_weight = origMtl.levelRefract r.refr_color = origMtl.colorRefract ) r.refr_color_map = origMtl.texmapRefract if r.refr_color_map != undefined then( r.refr_color_mapenable = origMtl.texmapOnRefract r.refr_color_mapamount = origMtl.mapamountRefract ) r.refr_use_base_IOR = false -- unlock refr and refl iors r.refr_ior = if origMtl.ior < 1.0 then 1.0 else(if origMtl.ior > 10.0 then 10.0 else origMtl.ior) if origMtl.texmapIor != undefined then( r.refr_ior_map = createReflIorTree origMtl.texmapIor ) if r.refr_ior_map != undefined then( r.refr_ior_mapenable = origMtl.texmapOnIor r.refr_ior_mapamount = origMtl.mapamountIor ) -- Refraction Glossiness r.refr_isGlossiness = true r.refr_roughness = origMtl.refractGlossiness if owner.converterSettings.explicitGlossinessConversion then( r.refr_isGlossiness = false r.refr_roughness = 1.0 - r.refr_roughness ) r.refr_roughness_map = origMtl.texmapRefractGlossiness if r.refr_roughness_map != undefined then( r.refr_roughness_mapenable = origMtl.texmapOnOpacity r.refr_roughness_mapamount = origMtl.mapamountOpacity if owner.converterSettings.explicitGlossinessConversion then( r.refr_roughness_map = output MAP1:r.refr_roughness_map name:"glossiness_to_roughness" r.refr_roughness_map.output.invert = true ) ) --Opacity r.opacity_color = origMtl.colorOpacity * origMtl.levelOpacity r.opacity_color_map = origMtl.texmapOpacity if r.opacity_color_map != undefined then( r.opacity_color_mapenable = origMtl.texmapOnOpacity r.opacity_color_mapamount = origMtl.mapamountOpacity if origMtl.levelOpacity != 1.0 then( outM = output map1:r.opacity_color_map outM.output.output_amount = origMtl.levelOpacity r.opacity_color_map = outM ) ) --Bumpmap r.bump_input_map = origMtl.texmapBump if r.bump_input_map != undefined then( local texmapClass = classof r.bump_input_map local isNormalMap = (texmapClass == VrayNormalMap or texmapClass == CoronaNormal or texmapClass == Normal_Bump) r.bump_input_mapenable = origMtl.texmapOnBump r.bump_input_mapamount = origMtl.mapamountBump * (if isNormalMap then 1.0 else owner.converterSettings.vrayBumpMultiplier) * 100.0 ) if origMtl.mediaMode == 1 then( -- volumetric scattering --Absorption if origMtl.absorptionDistance >= 0.01 then( r.ss_phase = origMtl.scatterDirectionality r.refr_transmittance = origMtl.absorptionColor r.refr_absorption_scale = 1.0/origMtl.absorptionDistance r.refr_transmittance_map = origMtl.texmapAbsorption if r.refr_transmittance_map != undefined then( r.refr_transmittance_mapenable = origMtl.texmapOnAbsorption r.refr_transmittance_mapamount = origMtl.mapamountAbsorption ) r.ss_scatter_coeff = origMtl.scatterColor r.ss_amount = 1.0/origMtl.absorptionDistance r.ss_scatter_coeff_map = origMtl.texmapScatterColor if r.ss_scatter_coeff_map != undefined then( r.ss_scatter_coeff_mapenable = origMtl.texmapOnScatterColor r.ss_scatter_coeff_mapamount = origMtl.mapamountScatterColor ) ) )else( -- SSS r.ms_weight0 = origMtl.levelSss r.ms_weight0_map = origMtl.texmapSssAmount if r.ms_weight0_map != undefined then( r.ms_weight0_mapenable = origMtl.texmapOnSssAmount r.ms_weight0_mapamount = origMtl.mapamountSssAmount ) r.ms_color0 = origMtl.sssScatterColor if r.ms_color0_map != undefined then( r.ms_color0_mapenable = origMtl.texmapOnSssScatterColor r.ms_color0_mapamount = origMtl.mapamountSssScatterColor ) r.ms_radius0 = 1.0 r.ms_radius_scale = origMtl.sssRadius r.ms_radius0_map = origMtl.texmapSssRadius if r.ms_radius0_map != undefined then( r.ms_radius0_mapenable = origMtl.texmapOnSssRadius r.ms_radius0_mapamount = origMtl.mapamountSssRadius ) ) --Translucency r.transl_color = origMtl.colorTranslucency r.transl_color_map = origMtl.texmapTranslucency if r.transl_color_map != undefined then( r.transl_color_mapenable = origMtl.texmapOnTranslucency r.transl_color_mapamount = origMtl.mapamountTranslucency ) r.transl_weight = origMtl.levelTranslucency r.transl_weight_map = origMtl.texmapTranslucencyFraction if r.transl_color_map != undefined then( r.transl_weight_mapenable = origMtl.texmapOnTranslucencyFraction r.transl_weight_mapamount = origMtl.mapamountTranslucencyFraction ) --Anisotropy -- as always, rather meh r.refl_aniso = origMtl.anisotropy if origMtl.texmapReflectAnisotropy != undefined then( r.refl_aniso_map = output name:"CoronaAdaption" map1:origMtl.texmapReflectAnisotropy output_amount:2.0 rgb_offset:-0.5 ) if r.refl_aniso_map != undefined then( r.refl_aniso_mapenable = origMtl.texmapOnAnisotropy r.refl_aniso_mapamount = origMtl.mapamountAnisotropy ) --Anisotropy Rotation r.refl_aniso_rotation = -origMtl.anisotropyRotation/360.0 -- add 0.25 to rotate 90 degrees (different axis in redshift) r.refl_aniso_rotation_map = origMtl.texmapReflectAnisotropyRotation if r.refl_aniso_rotation_map != undefined then( cmap = CompositeTexturemap() cmap.add() cmap.mapList[1] = RS_Color_User_Data default:white cmap.mapList[2] = r.refl_aniso_rotation_map cmap.blendMode[2] = 3 r.refl_aniso_rotation_map = cmap r.refl_aniso_rotation_mapenable = origMtl.texmapOnAnisotropyRotation r.refl_aniso_rotation_mapamount = origMtl.mapamountAnisotropyRotation ) r.anisotropy_tangentChannel = origMtl.anisotropyOrientationUvwChannel --Displacement r.displacement_input_map = origMtl.texmapDisplace if r.displacement_input_map != undefined then( --r.displacement_input_mapenable = origMtl.texmap_displacement_on r.displacement_input_mapenable = false ) --SelfIllumination if origMtl.levelSelfIllum == black and origMtl.texmapSelfIllum == undefined then() else( r.emission_weight = origMtl.levelSelfIllum r.emission_color = origMtl.colorSelfIllum r.emission_color_map = origMtl.texmapSelfIllum if r.emission_color_map != undefined then( r.emission_color_mapenable = origMtl.texmapOnSelfIllum r.emission_color_mapamount = origMtl.mapamountSelfIllum ) ) r ), -- ############## CoronaLightMtl Material ################ fn convertFrom_CoronaLightMtl origMtl =( r=RS_Incandescent() r.name=(if owner.converterSettings.addRedshiftPrefix then owner.converterSettings.userPrefixStr else "") + origMtl.name r.color = origMtl.color r.intensity = origMtl.intensity if origMtl.texmap != undefined then( r.color_mapenable = origMtl.texmapOn r.color_Map = origMtl.texmap ) if origMtl.opacityTexmap != undefined then( r.alpha_mapenable = origMtl.opacityTexmapOn r.alpha_map = origMtl.opacityTexmap ) r.reflectScale = if origMtl.visibleRefl then 1.0 else 0.0 r.refractScale = if origMtl.visibleRefract then 1.0 else 0.0 r ), -- ############## CoronaLayeredMtl Material ################ fn convertFrom_CoronaLayeredMtl origMtl =( r=RS_Material_Blender() r.name=(if owner.converterSettings.addRedshiftPrefix then owner.converterSettings.userPrefixStr else "") + origMtl.name fn returnAmoundClr amnt =( local clr = (amnt * 2.5) as integer color clr clr clr ) r.baseColor_map = origMtl.baseMtl r.layerColor1_map = origMtl.Layers[1] if origMtl.Layers[1] != undefined do r.blendColor1 = returnAmoundClr origMtl.amounts[1] r.blendColor1_map = origMtl.mixmaps[1] r.layerColor2_map = origMtl.Layers[2] if origMtl.Layers[2] != undefined do r.blendColor2 = returnAmoundClr origMtl.amounts[2] r.blendColor2_map = origMtl.mixmaps[2] r.layerColor3_map = origMtl.Layers[3] if origMtl.Layers[3] != undefined do r.blendColor3 = returnAmoundClr origMtl.amounts[3] r.blendColor3_map = origMtl.mixmaps[3] r.layerColor4_map = origMtl.Layers[4] if origMtl.Layers[4] != undefined do r.blendColor4 = returnAmoundClr origMtl.amounts[4] r.blendColor4_map = origMtl.mixmaps[4] r.layerColor5_map = origMtl.Layers[5] if origMtl.Layers[5] != undefined do r.blendColor5 = returnAmoundClr origMtl.amounts[5] r.blendColor5_map = origMtl.mixmaps[5] r.layerColor6_map = origMtl.Layers[6] if origMtl.Layers[6] != undefined do r.blendColor6 = returnAmoundClr origMtl.amounts[6] r.blendColor6_map = origMtl.mixmaps[6] layerColor1_mapenable = origMtl.layersOn[1] layerColor2_mapenable = origMtl.layersOn[2] layerColor3_mapenable = origMtl.layersOn[3] layerColor4_mapenable = origMtl.layersOn[4] layerColor5_mapenable = origMtl.layersOn[5] layerColor6_mapenable = origMtl.layersOn[6] r ), -- ############## CoronaRaySwitchMtl Material ################ fn convertFrom_CoronaRaySwitchMtl origMtl =( r=RS_Ray_Switch_Material() r.name=(if owner.converterSettings.addRedshiftPrefix then owner.converterSettings.userPrefixStr else "") + origMtl.name r.cameraColor_map = origMtl.directMtl if r.cameraColor_map == undefined do( r.cameraColor_map = RS_Material name:"Invisible Mtl" r.cameraColor_map.refl_weight = 0 r.cameraColor_map.opacity_color = black ) r.giColor_map = origMtl.giMtl if r.giColor_map != undefinded do r.giSwitch = true r.reflectionColor_map = origMtl.reflectMtl if r.reflectionColor_map != undefinded do r.reflectionSwitch = true r.refractionColor_map = origMtl.refractMtl if r.refractionColor_map != undefinded do r.refractionSwitch = true r ), -------------------------------------------- -------------------- WIP ------------------- -------------------------------------------- -- ############## VRayALSurfaceMtl Material ################ fn convertFrom_VRayALSurfaceMtl origMtl =( -- UNFINISHED r=RS_Skin() r.name=(if owner.converterSettings.addRedshiftPrefix then owner.converterSettings.userPrefixStr else "") + origMtl.name r.radius_scale = 1.0/origMtl.sss_density_scale -- r.overall_scale = origMtl.max_sss_amount -- NOTHING DONE BELOW, is convertFrom_VRaySkinMtl code: r.overall_scale_map = origMtl.texmap_sss_amount if r.overall_scale_map != undefined then( r.overall_scale_mapenable = origMtl.texmap_sss_amount_on r.overall_scale_mapamount = origMtl.texmap_sss_amount_multiplier ) -- shallow scattering r.shallow_color = origMtl.shallow_color r.shallow_color_map = origMtl.texmap_shallow_color if r.shallow_color_map != undefined then( r.shallow_color_mapenable = origMtl.texmap_shallow_color_on r.shallow_color_mapamount = origMtl.texmap_shallow_color_multiplier ) r.shallow_radius = origMtl.shallow_radius r.shallow_radius_map = origMtl.texmap_shallow_radius if r.shallow_radius_map != undefined then( r.shallow_radius_map = output map1:r.shallow_radius_map r.shallow_radius_map.output.output_amount = r.shallow_radius -- map needs to be multiplied by maxdistance param r.shallow_radius_mapenable = origMtl.texmap_shallow_radius_on r.shallow_radius_mapamount = origMtl.texmap_shallow_radius_multiplier ) r.shallow_weight = if origMtl.shallow_amount > 1.0 then 1.0 else origMtl.shallow_amount r.shallow_weight_map = origMtl.texmap_shallow_amount if r.shallow_weight_map != undefined then( r.shallow_weight_mapenable = origMtl.texmap_shallow_amount_on r.shallow_weight_mapamount = origMtl.texmap_shallow_amount_multiplier ) -- Diffuse if origMtl.diffuse_amount > 0.0 or origMtl.texmap_diffuse_amount != undefined then( r.diffuse_amount = origMtl.diffuse_amount r.diffuse_amount_map = texmap_diffuse_amount if r.diffuse_amount_map != undefined then( r.diffuse_amount_mapenable = origMtl.texmap_diffuse_amount_on r.diffuse_amount_mapamount = origMtl.texmap_diffuse_amount_multiplier ) local clrMix = mix() clrMix.color2 = origMtl.diffuse_color clrMix.color1 = r.shallow_color clrMix.mixAmount = r.diffuse_amount * 100.0 clrMix.mask = origMtl.texmap_diffuse_amount if origMtl.texmap_diffuse_color != undefined then( clrMix.map2 = origMtl.texmap_diffuse_color clrMix.map1 = r.shallow_color_map ) r.shallow_color_map = clrMix ) -- medium scattering r.mid_color = origMtl.medium_color r.mid_color_map = origMtl.texmap_medium_color if r.mid_color_map != undefined then( r.mid_color_mapenable = origMtl.texmap_medium_color_on r.mid_color_mapamount = origMtl.texmap_medium_color_multiplier ) r.mid_radius = origMtl.medium_radius r.mid_radius_map = origMtl.texmap_medium_radius if r.mid_radius_map != undefined then( r.mid_radius_map = output map1:r.mid_radius_map r.mid_radius_map.output.output_amount = r.mid_radius -- map needs to be multiplied by maxdistance param r.mid_radius_mapenable = origMtl.texmap_medium_radius_on r.mid_radius_mapamount = origMtl.texmap_medium_radius_multiplier ) r.mid_weight = if origMtl.medium_amount > 1.0 then 1.0 else origMtl.medium_amount r.mid_weight_map = origMtl.texmap_medium_amount if r.mid_weight_map != undefined then( r.mid_weight_mapenable = origMtl.texmap_medium_amount_on r.mid_weight_mapamount = origMtl.texmap_medium_amount_multiplier ) -- deep scattering r.deep_color = origMtl.deep_color r.deep_color_map = origMtl.texmap_deep_color if r.deep_color_map != undefined then( r.deep_color_mapenable = origMtl.texmap_deep_color_on r.deep_color_mapamount = origMtl.texmap_deep_color_multiplier ) r.deep_radius = origMtl.deep_radius r.deep_radius_map = origMtl.texmap_deep_radius if r.deep_radius_map != undefined then( r.deep_radius_map = output map1:r.deep_radius_map r.deep_radius.output.output_amount = r.deep_radius -- map needs to be multiplied by maxdistance param r.deep_radius_mapenable = origMtl.texmap_deep_radius_on r.deep_radius_mapamount = origMtl.texmap_deep_radius_multiplier ) r.deep_weight = if origMtl.deep_amount > 1.0 then 1.0 else origMtl.deep_amount r.deep_weight_map = origMtl.texmap_deep_amount if r.deep_weight_map != undefined then( r.deep_weight_mapenable = origMtl.texmap_deep_amount_on r.deep_weight_mapamount = origMtl.texmap_deep_amount_multiplier ) -- primary reflection r.refl_color0 = origMtl.primary_reflection_color r.refl_color0_map = origMtl.texmap_primary_reflection_color if r.refl_color0_map != undefined then( r.refl_color0_mapenable = origMtl.texmap_primary_reflection_color_on r.refl_color0_mapamount = origMtl.texmap_primary_reflection_color_multiplier ) r.refl_weight0 = origMtl.primary_reflection_amount r.refl_weight0_map = origMtl.texmap_primary_reflection_amount if r.refl_weight0_map != undefined then( r.refl_weight0_mapenable = origMtl.texmap_primary_reflection_amount_on r.refl_weight0_mapamount = origMtl.texmap_primary_reflection_amount_multiplier ) r.refl_gloss0 = origMtl.primary_reflection_glossiness r.refl_gloss0_map = origMtl.texmap_primary_reflection_glossiness if r.refl_gloss0_map != undefined then( r.refl_gloss0_mapenable = origMtl.texmap_primary_reflection_glossiness_on r.refl_gloss0_mapamount = origMtl.texmap_primary_reflection_glossiness_multiplier ) r.refl_ior0 = origMtl.primary_reflection_fresnel_ior -- secondary reflection r.refl_color1 = origMtl.secondary_reflection_color r.refl_color1_map = origMtl.texmap_secondary_reflection_color if r.refl_color1_map != undefined then( r.refl_color1_mapenable = origMtl.texmap_secondary_reflection_color_on r.refl_color1_mapamount = origMtl.texmap_secondary_reflection_color_multiplier ) r.refl_weight1 = origMtl.secondary_reflection_amount r.refl_weight1_map = origMtl.texmap_secondary_reflection_amount if r.refl_weight1_map != undefined then( r.refl_weight1_mapenable = origMtl.texmap_secondary_reflection_amount_on r.refl_weight1_mapamount = origMtl.texmap_secondary_reflection_amount_multiplier ) r.refl_gloss1 = origMtl.secondary_reflection_glossiness r.refl_gloss1_map = origMtl.texmap_secondary_reflection_glossiness if r.refl_gloss1_map != undefined then( r.refl_gloss1_mapenable = origMtl.texmap_secondary_reflection_glossiness_on r.refl_gloss1_mapamount = origMtl.texmap_secondary_reflection_glossiness_multiplier ) r.refl_ior1 = origMtl.secondary_reflection_fresnel_ior --bump r.bump_input_map = origMtl.texmap_bump if r.bump_input_map != undefined then( r.bump_input_mapenable = origMtl.texmap_bump_on r.bump_input_mapamount = origMtl.texmap_bump_multiplier * owner.converterSettings.vrayBumpMultiplier ) --displacement r.displacement_input_map = origMtl.texmap_displacement if r.displacement_input_map != undefined then( r.displacement_input_mapenable = false r.displacement_input_mapamount = origMtl.texmap_displacement_multiplier ) r ) ) matConvMethods owner:this ), mapConvMethods =( struct mapConvMethods ( owner, -------------------------------------------- ------------------- VRAY ------------------- -------------------------------------------- -- ############## VrayHDRI ################ fn convertFrom_VrayHDRI origMap =( r = undefined doNotConvert = false nPath = undefined udimType = 0 fn getLowestUdim searchpattern =( local files = getFiles searchpattern sort files files[1] ) isUDIM = matchpattern origMap.HDRIMapName pattern:"**" ignoreCase:false if isUDIM do nPath = (getLowestUdim (substituteString origMap.HDRIMapName "" "*")); udimType = 1 isUVtile1base = matchpattern origMap.HDRIMapName pattern:"**" ignoreCase:false if isUVtile1base do nPath = (getLowestUdim (substituteString origMap.HDRIMapName "" "*_*")); udimType = 2 isUVtile0base = matchpattern origMap.HDRIMapName pattern:"**" ignoreCase:false if isUVtile0base do nPath = (getLowestUdim (substituteString origMap.HDRIMapName "" "*_*")); udimType = 3 isUVtile1baseCust = matchpattern origMap.HDRIMapName pattern:"*$*U_$*V*" ignoreCase:false if isUVtile1baseCust do ( if matchpattern origMap.HDRIMapName pattern:"*$U_$V*" ignoreCase:false then( nPath = (getLowestUdim (substituteString origMap.HDRIMapName "$U_$V" "*_*")); udimType = 2 )else( spos = findstring origMap.HDRIMapName "$" nPath = (getLowestUdim (replace origMap.HDRIMapName spos 7 "*_*")); udimType = 2 ) ) isUVtile0baseCust = matchpattern origMap.HDRIMapName pattern:"*$*u_$*v*" ignoreCase:false if isUVtile0baseCust do ( if matchpattern origMap.HDRIMapName pattern:"*$u_$v*" ignoreCase:false then( nPath = (getLowestUdim (substituteString origMap.HDRIMapName "$u_$v" "*_*")); udimType = 3 )else( spos = findstring origMap.HDRIMapName "$" nPath = (getLowestUdim (replace origMap.HDRIMapName spos 7 "*_*")); udimType = 3 ) ) if nPath != undefined and udimType != 0 then( -- UDIM handling r = RS_Bitmap() r.name = origMap.name -- filename, output if origMap.HDRIMapName != "" and origMap.HDRIMapName != undefined then( tempBitmap = bitmaptexture() -- workaround tempBitmap.fileName = nPath r.tex0 = tempBitmap.bitmap --openBitmap nPath case udimType of( 1: r.tilingmode = 1 2: r.tilingmode = 3 3: r.tilingmode = 2 ) ) -- r.output = copy origMap.Output r.Coordinates.mapChannel = origMap.coords.mapChannel r.Coordinates.UVW_Type = origMap.coords.UVW_Type r.Coordinates.U_Mirror = origMap.coords.U_Mirror r.Coordinates.V_Mirror = origMap.coords.V_Mirror r.Coordinates.U_Tile = origMap.coords.U_Tile r.Coordinates.V_Tile = origMap.coords.V_Tile r.Coordinates.realWorldScale = origMap.coords.realWorldScale r.Coordinates.realWorldHeight = origMap.coords.realWorldHeight r.Coordinates.realWorldWidth = origMap.coords.realWorldWidth r.Coordinates.U_Offset = origMap.coords.U_Offset r.Coordinates.V_Offset = origMap.coords.V_Offset r.Coordinates.U_Tiling = origMap.coords.U_Tiling r.Coordinates.V_Tiling = origMap.coords.V_Tiling r.Coordinates.U_angle = origMap.coords.U_angle r.Coordinates.V_angle = origMap.coords.V_angle r.Coordinates.W_angle = origMap.coords.W_angle if origMap.mapType == 2 then( -- spherical mode r.Coordinates.mapping = 0 -- spherical r.Coordinates.mappingType = 1 -- Environ r.Coordinates.U_Offset = 0.25 + origMap.horizontalRotation / 360.0 r.Coordinates.V_Offset = origMap.verticalRotation / 180.0 if origMap.horizontalFlip then( r.Coordinates.U_Offset = 0.25 - origMap.horizontalRotation / 360.0 r.Coordinates.U_Tiling = -r.Coordinates.U_Tiling ) if origMap.verticalFlip then r.Coordinates.V_Tiling = -r.Coordinates.V_Tiling ) )else( -- standard max bitmap r = BitmapTexture() r.name = origMap.name -- filename, output if origMap.HDRIMapName != "" and origMap.HDRIMapName != undefined then( --doNotConvert = true r.fileName = origMap.HDRIMapName ) r.output = copy origMap.Output if hasproperty origMap #coords then( r.coords = origMap.coords ) -- Gamma handling if (maxversion())[1] >= 16000 and origMap.gamma != 1 then( try(r.bitmap = openBitmap r.bitmap.filename gamma:(1.0/origMap.gamma))catch() ) if origMap.mapType == 2 then( -- spherical mode r.coords.mapping = 0 -- spherical r.coords.mappingType = 1 -- Environ r.coords.U_Offset = 0.25 + origMap.horizontalRotation / 360.0 r.coords.V_Offset = origMap.verticalRotation / 180.0 if origMap.horizontalFlip then( r.coords.U_Offset = 0.25 - origMap.horizontalRotation / 360.0 r.coords.U_Tiling = -r.coords.U_Tiling ) if origMap.verticalFlip then r.coords.V_Tiling = -r.coords.V_Tiling ) ) -- alpha source, mono channel out, rgb channel out r.alphaSource = origMap.alphaSource r.monoOutput = origMap.monoOutput r.rgbOutput = if origMap.rgbOutput > 1 then 0 else origMap.rgbOutput -- crop/place r.apply = origMap.cropplace_on r.cropPlace = origMap.cropplace_mode r.clipu = origMap.cropplace_u r.clipv = origMap.cropplace_v r.clipw = origMap.cropplace_width r.cliph = origMap.cropplace_height r.output.output_amount *= origMap.multiplier * origMap.renderMultiplier if doNotConvert then r = #NoReplacement r ), -- ############## VrayColor ################ fn convertFrom_VrayColor origMap = ( r = RS_Color_User_Data() r.name = origMap.name r.default = origMap.color if origMap.rgb_multiplier != 1.0 then( outp = output MAP1:r outp.output.output_amount = origMap.rgb_multiplier r = outp ) r ), -- ############## VRayCompTex ################ fn convertFrom_VRayCompTex origMap = ( r = CompositeTexturemap() r.name = origMap.name r.add() r.mapList[1] = origMap.sourceA r.mapList[2] = origMap.sourceB r.blendMode[2] = case origMap.operator of( 0: 2 -- Add 1: 3 -- subtract 2: 19 -- difference 3: 5 -- multiply 4: 5 -- divide not existing! 5: 4 -- minimum 6: 8 -- maximum default:0 ) if origMap.operator == 4 then( r = RS_Vector_Div() r.name = origMap.name r.input1_map = origMap.sourceA r.input2_map = origMap.sourceB ) r ), -- ############## VrayDirt ################ fn convertFrom_VrayDirt origMap =( r = RS_AO() r.name = origMap.name r.dark = origMap.occluded_color r.bright = origMap.unoccluded_color r.maxDistance = origMap.radius r.invert = origMap.invert_normal r.sameObjectOnly = origMap.consider_same_object_only if origMap.texmap_radius != undefined do( r.maxDistance_map = output map1:origMap.texmap_radius r.maxDistance_map.output.output_amount = r.maxDistance -- map needs to be multiplied by maxdistance param r.maxDistance_map.output.rgb_offset = 0.001 -- fix to prevent infinite ray dist ) if length origMap.bias > 0.0 then( r.biasMode = 2 r.bias = -origMap.bias ) r.dark_map = origMap.texmap_occluded_color r.bright_map = origMap.texmap_unoccluded_color r.outputMode = -1 -- shading normals instead of bent normals r.spread = 1.0/(if origMap.Distribution < 0.01 then 0.01 else origMap.Distribution) r.falloff = 1.0/(if origMap.falloff < 0.01 then 0.01 else origMap.falloff) r ), -- ############## VrayNormalMap ################ fn convertFrom_VrayNormalMap origMap = ( r = RS_Bump_Map() r.name = origMap.name r.inputType = 1 r.input_map = origMap.normal_map r.scale = origMap.normal_map_multiplier r.flipY = origMap.flip_green if hasProperty origMap #bump_map then( -- Vray 3.3 if origMap.bump_map != undefined then( bb = RS_Bump_Blender() bb.additive = true bb.baseInput_map = r bb.bumpInput0_map = RS_Bump_Map input_map:origMap.bump_map bb.bumpWeight0 = origMap.bump_map_multiplier * owner.converterSettings.vrayBumpMultiplier r = bb ) ) r ), -- ############## Normal_Bump ################ fn convertFrom_Normal_Bump origMap = ( r = RS_Bump_Map() r.name = origMap.name r.inputType = 1 if origMap.method == 1 then r.inputType = 2 r.input_map = origMap.normal_map r.scale = origMap.mult_spin r.flipY = origMap.flipgreen if origMap.bump_map != undefined and origMap.map2on then( bb = RS_Bump_Blender() bb.additive = true bb.baseInput_map = r bb.bumpInput0_map = RS_Bump_Map input_map:origMap.bump_map bb.bumpWeight0 = origMap.bump_spin * owner.converterSettings.vrayBumpMultiplier r = bb ) r ), -- ############## VRayEdgesTex ################ fn convertFrom_VRayEdgesTex origMap = ( r = RS_Round_Corners() r.name = origMap.name r.radius = origMap.roundedCorners_radius r.sameObjectOnly = origMap.roundedCorners_sameObjectOnly r ), -- ############## VraySky ################ fn convertFrom_VraySky origMap = ( r = RS_Physical_Sky() r.name = origMap.name r ), -- ############## VRayTriplanarTex ################ fn convertFrom_VRayTriplanarTex origMap = ( r = RS_TriPlanar() r.name = origMap.name r.scale = [origMap.scale, origMap.scale, origMap.scale] if origMap.texture_mode == 0 then( -- same texture on all axis r.sameImageOnEachAxis = true r.imageX_map = origMap.texture )else( r.sameImageOnEachAxis = false r.imageX_map = origMap.texture r.imageY_map = origMap.texture_y r.imageZ_map = origMap.texture_z ) r.blendAmount = origMap.blend r.offset = origMap.frame_offset r.rotation = origMap.texture_rotation case origMap.space of( 0: r.projSpaceType = 1 1: ( r.projSpaceType = 0 --r.referenceNode = origMap.reference_node ) ) r ), -- ############## VRayGLSLTex ################ fn convertFrom_VRayGLSLTex origMap = ( r = RS_Color_User_Data() r.name = origMap.name r.default = (color 127 127 127) r ), -- ############## VRaySoftbox ################ fn convertFrom_VRaySoftbox origMap = ( r = RS_Color_User_Data() r.name = origMap.name r.default = (color 255 255 255) r ), -- ############## VRayUserColor ################ fn convertFrom_VRayUserColor origMap = ( r = RS_Color_User_Data() r.name = origMap.name r.default = origMap.default_color r.attribute = if origMap.attribute_name != undefined then origMap.attribute_name else "" r ), -- ############## VRayUserScalar ################ fn convertFrom_VRayUserScalar origMap = ( r = RS_Scalar_User_Data() r.name = origMap.name r.default = origMap.default_value r.attribute = if origMap.attribute_name != undefined then origMap.attribute_name else "" r ), -- ############## VRayColor2Bump ################ fn convertFrom_VRayColor2Bump origMap = ( r = RS_Bump_Map() r.name = origMap.name r.input_map = origMap.map r.scale = origMap.height --r.factorInObjScale = false r ), -- ############## VRayBump2Normal ################ fn convertFrom_VRayBump2Normal origMap = ( r = RS_Bump_Map() r.name = origMap.name r.input_map = origMap.bump_map --r.scale = origMap.height --r.factorInObjScale = false r ), -------------------------------------------- ------------------ CORONA ------------------ -------------------------------------------- -- ############## CoronaAO ################ fn convertFrom_CoronaAO origMap =( r = RS_AO() r.name = origMap.name r.dark = origMap.colorOccluded r.bright = origMap.colorUnoccluded r.maxDistance = origMap.maxDistance r.invert = origMap.normalMode == 1 r.sameObjectOnly = origMap.excludeMode == 3 r.maxDistance_mapenable = origMap.texmapDistanceOn if origMap.texmapDistance != undefined do( r.maxDistance_map = output map1:origMap.texmapDistance r.maxDistance_map.output.output_amount = r.maxDistance -- map needs to be multiplied by maxdistance param r.maxDistance_map.output.rgb_offset = 0.001 -- fix to prevent infinite ray dist ) if length origMap.directionOffsets > 0.0 then( r.biasMode = 2 r.bias = -origMap.directionOffsets ) r.dark_map = origMap.texmapOccluded r.dark_mapenable = origMap.texmapOccludedOn r.bright_map = origMap.texmapUnoccluded r.bright_mapenable = origMap.texmapUnoccludedOn r.outputMode = -1 -- shading normals instead of bent normals r.spread = 1.0 - origMap.rayDirectionality --r.falloff = 1.0/(if origMap.falloff < 0.01 then 0.01 else origMap.falloff) r ), -- ############## CoronaBitmap ################ fn convertFrom_CoronaBitmap origMap =( r = Bitmaptexture() r.name = origMap.name doNotConvert = false -- filename, output if origMap.filename != "" and origMap.filename != undefined then( r.fileName = origMap.filename -- gamma handling, ONLY max 2014+ if (maxVersion())[1] >= 16000 then ( local gammaOrig = origMap.gamma if gammaOrig != -1.0 do( r.bitmap = openBitmap origMap.filename gamma:gammaOrig ) ) )else( doNotConvert = true ) r.output = copy origMap.output -- uv channel, environment mode if origMap.uvwChannel == 0 then ( r.coords.mapping = 1 )else( r.coords.mapChannel = origMap.uvwChannel ) -- blur r.coords.blur = origMap.filteringBlur -- alpha source, mono channel out, rgb channel out r.alphaSource = origMap.alphaSource r.monoOutput = origMap.monoChannelOutput r.rgbOutput = origMap.rgbChannelOutput -- offset, tiling/scale, rotation, rw mapscale r.coords.realWorldScale = origMap.realWorldScale r.coords.U_Offset = origMap.uvwOffset[1] r.coords.V_Offset = origMap.uvwOffset[2] if origMap.realWorldScale then ( r.coords.realWorldWidth = origMap.uvwScale[1] r.coords.realWorldHeight = origMap.uvwScale[2] )else( r.coords.U_Tiling = origMap.uvwScale[1] r.coords.V_Tiling = origMap.uvwScale[2] ) case origMap.tilingU of ( 0: (r.coords.U_Mirror = false; r.coords.U_Tile = false) 2: (r.coords.U_Mirror = true; r.coords.U_Tile = false) 1: (r.coords.U_Mirror = false; r.coords.U_Tile = true) ) case origMap.tilingV of ( 0: (r.coords.V_Mirror = false; r.coords.V_Tile = false) 2: (r.coords.V_Mirror = true; r.coords.V_Tile = false) 1: (r.coords.V_Mirror = false; r.coords.V_Tile = true) ) r.coords.W_angle = origMap.wAngle -- crop/place r.apply = origMap.clippingOn r.cropPlace = origMap.clippingMode r.clipu = origMap.clippingU r.clipv = origMap.clippingV r.clipw = origMap.clippingWidth r.cliph = origMap.clippingHeight if doNotConvert then r = #NoReplacement r ), -- ############## CoronaBumpConverter ################ fn convertFrom_CoronaBumpConverter origMap = ( r = RS_Bump_Map() r.name = origMap.name r.input_map = origMap.input r.scale = origMap.strength --r.factorInObjScale = false r ), -- ############## CoronaColor ################ fn convertFrom_CoronaColor origMap = ( r = RS_Color_User_Data() r.name = origMap.name r.default = case origMap.method of( 0: origMap.color 1: ( scalefac = 255.0 magn = amax #(origMap.colorHdr[1], origMap.colorHdr[2], origMap.colorHdr[3]) if magn >= 1.0 then( scaleFac *= 1.0 / magn origMap.multiplier *= magn ) color (origMap.colorHdr[1]*scaleFac) (origMap.colorHdr[2]*scaleFac) (origMap.colorHdr[3]*scaleFac) 255.0 ) 2: white 3: gray default: gray ) if origMap.multiplier != 1.0 then( outp = output MAP1:r outp.output.output_amount = origMap.multiplier r = outp ) r ), -- ############## CoronaFrontBack ################ fn convertFrom_CoronaFrontBack origMap = ( r = RS_Ray_Switch() r.name = origMap.name r.cameraSwitchFrontBack = true r.cameraColor = origMap.frontColor r.cameraColorBack = origMap.backColor r.cameraColor_map = origMap.frontTexmap r.cameraColor_mapenable = origMap.frontTexmapOn r.cameraColorBack_map = origMap.backTexmap r.cameraColorBack_mapenable = origMap.backTexmapOn r ), -- ############## CoronaMix ################ fn convertFrom_CoronaMix origMap = ( r = CompositeTexturemap() r.name = origMap.name r.add() r.mapList[1] = origMap.texmapBottom if origMap.texmapBottom == undefined then r.mapList[1] = RS_Color_User_Data default:origMap.colorBottom r.mapList[2] = origMap.texmapTop if origMap.texmapTop == undefined then r.mapList[2] = RS_Color_User_Data default:origMap.colorTop r.Mask[2] = origMap.texmapMix r.opacity[2] = origMap.multiplierTop * 100 r.blendMode[2] = case origMap.mixOperation of( 0: 2 -- Add 1: 3 -- subtract 2: 5 -- multiply 3: 5 -- divide not existing 4: 4 -- minimum 5: 8 -- maximum 6: 0 -- mix 7: 0 -- gamma ?? not existing 8: 19 -- difference 9: 9 -- screen 10: 14 -- overlay 11: 10 -- color dodge 12: 6 -- color burn 13: 7 -- linear burn 14: 16 -- linear light (add sub) ?? not existing 15: 15 -- soft light 16: 16 -- hard light 17: 0 -- vivid light ?? not existing 18: 17 -- pin light 19: 18 -- hard mix 20: 20 -- exclusion default:0 ) if origMap.mixOperation == 3 then( r = RS_Vector_Div input1_map:r.mapList[1] input2_map:r.mapList[2] r.name = origMap.name ) r ), -- ############## CoronaNormal ################ fn convertFrom_CoronaNormal origMap = ( r = RS_Bump_Map() r.name = origMap.name r.inputType = 1 r.input_map = origMap.NormalMap r.scale = origMap.multiplier r.flipY = origMap.flipgreen if origMap.additionalBump != undefined then( bb = RS_Bump_Blender() bb.additive = true bb.baseInput_map = r bb.bumpInput0_map = RS_Bump_Map input_map:origMap.additionalBump bb.bumpWeight0 = origMap.additionalBumpStrength * owner.converterSettings.vrayBumpMultiplier r = bb ) r ), -- ############## CoronaSky ################ fn convertFrom_CoronaSky origMap = ( r = RS_Physical_Sky() r.name = origMap.name r ), -- ############## CoronaRaySwitch ################ fn convertFrom_CoronaRaySwitch origMap = ( r = RS_Ray_Switch() r.name = origMap.name r.reflectionSwitch = true r.refractionSwitch = true r.giSwitch = true r.cameraColor = origMap.directColor r.reflectionColor = origMap.reflectColor r.refractionColor = origMap.refractColor r.giColor = origMap.giColor r.cameraColor_map = origMap.directTexmap r.reflectionColor_map = origMap.reflectTexmap r.refractionColor_map = origMap.refractTexmap r.giColor_map = origMap.giTexmap r ), -- ############## CoronaRoundEdges ################ fn convertFrom_CoronaRoundEdges origMap = ( r = RS_Round_Corners() r.name = origMap.name r.radius = origMap.radius r.sameObjectOnly = excludeMode == 1 r.radius_mapenable = origMap.mapOnRadius if origMap.mapRadius != undefined do( r.radius_map = output map1:origMap.mapRadius r.radius_map.output.output_amount = r.radius -- map needs to be multiplied by radius param ) r ), -- ############## CoronaWire ################ fn convertFrom_CoronaWire origMap = ( r = RS_WireFrame() r.name = origMap.name r.polyColor = origMap.baseColor r.wirecolor = origMap.edgeColor r.thickness = origMap.edgeWidthPixels r.showHiddenEdges = false r ), -- ############## CoronaTriplanar ################ fn convertFrom_CoronaTriplanar origMap = ( r = RS_TriPlanar() r.name = origMap.name r.scale = [1.0/origMap.scale, 1.0/origMap.scale, 1.0/origMap.scale] if origMap.onlyTexmapX then( -- same texture on all axis r.sameImageOnEachAxis = true r.imageX_map = origMap.texmapX )else( r.sameImageOnEachAxis = false r.imageX_map = origMap.texmapX r.imageY_map = origMap.texmapY r.imageZ_map = origMap.texmapZ ) r.imageX = origMap.colorX r.imageY = origMap.colorY r.imageZ = origMap.colorZ r.imageX_mapenable = origMap.texmapXOn r.imageY_mapenable = origMap.texmapYOn r.imageZ_mapenable = origMap.texmapZOn r.blendAmount_map = origMap.texmapBlend r.blendAmount_mapenable = origMap.texmapBlendOn r.blendAmount = origMap.Blend r.offset = origMap.offset r.rotation = origMap.rotation case origMap.space of( 0: r.projSpaceType = 1 1: r.projSpaceType = 0 2: r.projSpaceType = 0 ) r ), -------------------------------------------- ------------------ OTHER ------------------- -------------------------------------------- fn convertFrom_BitmapTexture origMap =( r = RS_Bitmap() r.name = origMap.name doNotConvert = false -- filename, output if origMap.fileName != "" and origMap.fileName != undefined then( type = getFilenameType origMap.fileName if (findItem #(".jpg", ".jpeg", ".png", ".gif", ".bmp", ".exr", ".tif", ".tiff", ".tga", ".hdr", ".psd") (toLower type)) != 0 then( r.tex0 = origMap.bitmap -- gamma handling, ONLY max 2014+ local isValidMap = true try(origMap.bitmap)catch(isValidMap = false) if (maxVersion())[1] >= 16000 and isValidMap then ( local gammaOrig = origMap.bitmap.inputGamma if hasProperty renderers.current "SrgbLinearColorSpace" then( -- Redshift 3.0.48 if gammaOrig == #auto then r.tex0_gamma = 2.2 else r.tex0_gamma = gammaOrig if r.tex0_gamma == 1.0 then( r.tex0_colorSpace = renderers.current.RawColorSpace )else( r.tex0_colorSpace = renderers.current.SrgbLinearColorSpace ) )else if hasProperty r "tex0_colorSpace" then( -- Redshift 3.0.46 / 3.0.47 if not gave3046__3047_clrSpaceWarning then( messagebox "Color Space unclear due to old RS version, please check if texture color space is correct after conversion." gave3046__3047_clrSpaceWarning = true ) r.tex0_colorSpace = "scene-linear Rec.709-sRGB" if gammaOrig == #auto then r.tex0_gamma = 2.2 else r.tex0_gamma = gammaOrig )else( -- Redshift 3.0.45 and older r.tex0_gammaoverride = true if gammaOrig == #auto then r.tex0_gamma = 2.2 else r.tex0_gamma = gammaOrig ) ) ) else( doNotConvert = true ) )else( r.fileName = "" ) r.clipu = origMap.clipu r.clipv = origMap.clipv r.clipw = origMap.clipw r.cliph = origMap.cliph r.monoOutput = origMap.monoOutput r.rgbOutput = origMap.rgbOutput r.alphaSource = origMap.alphaSource r.cropPlace = origMap.cropPlace r.startTime = origMap.startTime r.playBackRate = origMap.playBackRate r.endCondition = origMap.endCondition replaceInstances r.output origMap.output replaceInstances r.Coordinates origMap.coords if doNotConvert then r = #NoReplacement r ) ) mapConvMethods owner:this ), lightConvMethods =( struct lightConvMethods ( owner, -- ############## VrayLight ################ fn convertFrom_VrayLight origLight = ( r=rsPhysicalLight() r.name=(if owner.converterSettings.addRedshiftPrefix then owner.converterSettings.userPrefixStr else "") + origLight.name doNotConvert = false -- OnOff, Include/exclude r.on = origLight.on /* NO INCLUDE/EXCLUDE METHODS AVAILABLE!*/ case of ( (origLight.includeList != undefined and origLight.includeList.count != 0): ( r.includeList = origLight.includeList ) (origLight.excludeList != undefined and origLight.excludeList.count != 0): ( r.excludeList = origLight.excludeList ) default: () ) r.inclExclType = origLight.inclExclType /* Corona: 0: Default W/(sr .m^2), 1: Lumen(lm), 2: candela (cd), 3:Lux (lx) Vray: 0: Default (image), 1 : luminous (lm), 2: lumincance (lm/m^2/sr), 3: radiant power (w), 4: radiance (w/m^2/sr) */ -- Bogus multipliers but it works... ¯\_(?)_/¯ case origLight.normalizeColor of ( 0: ( -- vray default (image) r.unitsType = 0 r.intensity = origLight.multiplier ) 1: ( -- vray luminous (lm) r.unitsType = 1 r.intensity = origLight.multiplier * 20.0 ) 2: ( -- vray luminance (lm/m^2/sr) r.unitsType = 2 r.intensity = origLight.multiplier * 20.0 ) 3: ( -- vray radiant power (w) r.unitsType = 3 r.intensity = origLight.multiplier * 150.0 r.lumensperwatt = 100 ) 4: ( -- vray radiance (w/m^2/sr) r.unitsType = 4 r.intensity = origLight.multiplier * 150.0 r.lumensperwatt = 100 ) ) r.colorMode = origLight.color_mode r.color = origLight.color if r.colorMode == 1 do r.temperature = origLight.color_temperature -- kelvin if origLight.texmap_on and origLight.texmap != undefined do( r.color_Map = origLight.texmap ) -- visibility r.areabidirectional = origLight.DoubleSided r.areavisible = not origLight.invisible r.affectsdiffuse = origLight.affect_diffuse r.diffusescale = origLight.diffuse_contribution r.affectsspecular = origLight.affect_reflections r.glossyscale = origLight.specular_contribution --if origLight.noDecay do r.decayType = 2 -- directionality / spread r.areaspread = 1 - (pow origLight.lightDistribution 2) -- shape -- 0: plane, 1: dome, 2: sphere, 3: mesh, 4: disc case origLight.type of ( 0: ( r.areashape = 0 -- Plane r.width = origLight.size0 * 2.0 r.length = origLight.size1 * 2.0 if origLight.skylightPortal then( rsp = rsPortalLight width:r.width height:r.length delete r r = rsp ) ) 1: ( -- Dome delete r r = origLight ) 2: ( r.areashape = 2 -- Sphere r.width = origLight.size0 / 2.0 ) 3:( -- mesh if hasproperty origLight #Shape_mesh do( rV = copy origLight hide rV rV.baseobject = rV.Shape_mesh r.areamesh = rV InstanceMgr.GetInstances origLight &rptInstances trueInstances = for n in rptInstances where (areNodesInstances origLight n) collect n for i in trueInstances do instanceReplace i r trueInstances.material = mtl ) doNotConvert = true ) 4:( r.areashape = 1 -- Disc r.width = origLight.size0 * 2.0 ) ) if doNotConvert then( delete r r = #NoReplacement ) r ), -- ############## VrayIES ################ fn convertFrom_VrayIES origLight = ( r=rsIESLight() r.name=(if owner.converterSettings.addRedshiftPrefix then owner.converterSettings.userPrefixStr else "") + origLight.name -- OnOff, Include/exclude r.on = origLight.enabled -- currently not supported by RS /* case of ( (origLight.includeList != undefined and origLight.includeList.count != 0): ( r.excludeIncludeMod = true r.excludeList = origLight.includeList ) (origLight.excludeList != undefined and origLight.excludeList.count != 0): ( r.excludeIncludeMod = false r.excludeList = origLight.excludeList ) default: () ) */ -- Intensitiy, Color, Texmap r.multiplier = origLight.power * 0.002 -- ¯\_(?)_/¯ r.colorMode = origLight.color_mode -- 0: direct color, 1: kelvin temp r.color = origLight.color if r.colorMode == 1 do r.temperature = origLight.color_temperature -- kelvin -- visibility r.affectsdiffuse = origLight.affect_diffuse r.diffusescale = origLight.diffuse_contribution r.affectsspecular = origLight.affect_specular r.glossyscale = origLight.specular_contribution -- IES if origLight.ies_file != undefined do( r.profile = origLight.ies_file ) r ), -- ############## VraySun ################ fn convertFrom_VraySun origLight = ( r=rsSunLight() -- OnOff, Include/exclude r.on = origLight.enabled -- Intensitiy r.intensity = origLight.intensity_multiplier r ), -- ############## CoronaSun ################ fn convertFrom_CoronaSun origLight = ( r=rsSunLight() -- OnOff, Include/exclude r.on = origLight.on -- Intensitiy r.intensity = origLight.intensity r ), -- ############## CoronaLight ################ fn convertFrom_CoronaLight origLight = ( r=rsPhysicalLight() r.wirecolor = color 255 229 0 r.name=(if owner.converterSettings.addRedshiftPrefix then owner.converterSettings.userPrefixStr else "") + origLight.name doNotConvert = false -- OnOff, Include/exclude r.on = origLight.on /* NO INCLUDE/EXCLUDE METHODS AVAILABLE! */ if (origLight.excludeList != undefined and origLight.excludeList.count != 0) then ( if origLight.excludeIncludeMod then( r.includeList = origLight.excludeList as array )else( r.excludeList = origLight.excludeList as array ) ) -- Bogus multipliers but it works... ¯\_(?)_/¯ .. maybe case origLight.intensityUnits of ( 0: ( -- corona default (w/m^2/sr) r.unitsType = 4 r.lumensperwatt = 100 r.intensity = origLight.intensity * 2.5 ) 1: ( -- corona lumen (lm) r.unitsType = 1 r.intensity = origLight.intensity / 3.14 ) 2: ( -- corona candela (cd) r.unitsType = 1 r.intensity = origLight.intensity ) 3: ( -- corona lux (lx) r.unitsType = 1 r.intensity = origLight.intensity / 78.0 ) ) case origLight.colorMode of ( 0: ( -- direct color r.colorMode = 0 r.color = origLight.color ) 1: ( -- temperature r.colorMode = 1 -- direct color r.temperature = origLight.blackbodyTemp ) 2: ( -- texmap r.colorMode = 0 if origLight.texmap != undefined do( r.color_Map = origLight.texmap ) ) ) -- visibility r.areabidirectional = origLight.twosidedEmission r.areavisible = origLight.visibleDirectly r.affectsspecular = origLight.visibleRefl r.decayType = 0 -- directionality / spread fn getVrayDirectionality CrnVal curve =( local out = 0.0 local crnInt = ((CrnVal * 100) as integer) local run = true for dataPoint in curve while run do( if ((dataPoint.y * 100) as integer) == crnInt then( out = dataPoint.x run = false ) ) out ) --r.directionality = logit origLight.lightDistribution 10 local vrayTmpDirectionality = getVrayDirectionality origLight.directionality owner.converterSettings.vrayDirectionalityToCoronaDirectionality r.areaspread = 1 - (pow vrayTmpDirectionality 2) -- shape -- 0: sphere, 1: rectangle, 2: disk, 3: cylinder case origLight.shape of ( 0: ( -- sphere r.areashape = 2 r.width = origLight.width * 2.0 ) 1: ( -- rectangle r.areashape = 0 r.length = origLight.height r.width = origLight.width ) 2: ( -- disk r.areashape = 1 r.width = origLight.width * 2.0 ) 3:( -- cylinder r.areashape = 3 r.length = origLight.height r.width = origLight.width * 2.0 ) ) if origLight.iesOn and origLight.iesFile != undefined and origLight.iesFile != "" then( rsp = rsIESLight name:origLight.name rsp.wirecolor = color 255 229 0 rsp.profile = origLight.iesFile rsp.on = r.on rsp.colorMode = r.colorMode rsp.color = r.color rsp.temperature = r.temperature rsp.affectsspecular = r.affectsspecular rsp.multiplier = r.intensity delete r r = rsp ) r ) ) lightConvMethods owner:this ), -- conversion core methods fn createRedshiftMap orig_map =( if ((superclassof orig_map)!=textureMap) then return orig_map -- check if this is a material; if not, just return the value local i=findItem converterTempData.orig_maps orig_map -- check if we have already converted this map if i>0 then return converterTempData.new_maps[i] --if yes, just return the already converted one -- recurse into sub-maps, if any local sub_count=getNumSubTexmaps orig_map if sub_count >= 1 then ( for i=1 to sub_count do ( newMap = createRedshiftMap (getSubTexmap orig_map i) if newMap != #NoReplacement then( setSubTexmap orig_map i newMap ) ) ) cls=classof orig_map local new_map=case cls of ( -- VRAY -- VrayColor: errorCatching mapConvMethods.convertFrom_VrayColor orig_map VrayDirt: errorCatching mapConvMethods.convertFrom_VrayDirt orig_map VrayNormalMap: errorCatching mapConvMethods.convertFrom_VrayNormalMap orig_map VraySky: errorCatching mapConvMethods.convertFrom_VraySky orig_map VRayCompTex: errorCatching mapConvMethods.convertFrom_VRayCompTex orig_map VRayEdgesTex: errorCatching mapConvMethods.convertFrom_VRayEdgesTex orig_map VRayGLSLTex: errorCatching mapConvMethods.convertFrom_VRayGLSLTex orig_map VRaySoftbox: errorCatching mapConvMethods.convertFrom_VRaySoftbox orig_map VRayHDRI: errorCatching mapConvMethods.convertFrom_VrayHDRI orig_map VRayTriplanarTex: errorCatching mapConvMethods.convertFrom_VRayTriplanarTex orig_map VRayUserColor: errorCatching mapConvMethods.convertFrom_VRayUserColor orig_map VRayUserScalar: errorCatching mapConvMethods.convertFrom_VRayUserScalar orig_map VRayColor2Bump: errorCatching mapConvMethods.convertFrom_VRayColor2Bump orig_map VRayBump2Normal: errorCatching mapConvMethods.convertFrom_VRayBump2Normal orig_map -- CORONA-- CoronaAO: errorCatching mapConvMethods.convertFrom_CoronaAO orig_map CoronaBitmap: errorCatching mapConvMethods.convertFrom_CoronaBitmap orig_map CoronaBumpConverter: errorCatching mapConvMethods.convertFrom_CoronaBumpConverter orig_map CoronaColor: errorCatching mapConvMethods.convertFrom_CoronaColor orig_map CoronaFrontBack: errorCatching mapConvMethods.convertFrom_CoronaFrontBack orig_map CoronaMix: errorCatching mapConvMethods.convertFrom_CoronaMix orig_map CoronaNormal: errorCatching mapConvMethods.convertFrom_CoronaNormal orig_map CoronaSky: errorCatching mapConvMethods.convertFrom_CoronaSky orig_map CoronaRaySwitch: errorCatching mapConvMethods.convertFrom_CoronaRaySwitch orig_map CoronaRoundEdges: errorCatching mapConvMethods.convertFrom_CoronaRoundEdges orig_map CoronaWire: errorCatching mapConvMethods.convertFrom_CoronaWire orig_map CoronaTriplanar: errorCatching mapConvMethods.convertFrom_CoronaTriplanar orig_map -- OTHER -- -- Bitmaptexture: (if converterSettings.bitmapTextureToCoronaBitmap then errorCatching mapConvMethods.convertFrom_BitmapTexture orig_map else orig_map) Normal_Bump: errorCatching mapConvMethods.convertFrom_Normal_Bump orig_map -- Autodesk_Map: errorCatching mapConvMethods.convertFrom_Autodesk_Map orig_map -- Ambient_Reflective_Occlusion__3dsmax: errorCatching mapConvMethods.convertFrom_Ambient_Reflective_Occlusion__3dsmax orig_map -- Multi_Sub_Map: errorCatching mapConvMethods.convertFrom_Multi_Sub_Map orig_map default: orig_map ) if new_map!=orig_map then ( -- if converted, add to the list of converted materials append converterTempData.orig_maps orig_map append converterTempData.new_maps new_map ) new_map ), fn createRedshiftMtl orig_mtl processMaps:true =( if ((superclassof orig_mtl)!=material) then return orig_mtl -- check if this is a material; if not, just return the value local i=findItem converterTempData.orig_mtls orig_mtl -- check if we have already converted this material if i>0 then return converterTempData.new_mtls[i] --if yes, just return the already converted one -- recurse into sub-materials, if any local sub_count=getNumSubMtls orig_mtl if sub_count >= 1 then ( for i=1 to sub_count do ( setSubMtl orig_mtl i (createRedshiftMtl (getSubMtl orig_mtl i) processMaps:processMaps ) ) ) if processMaps do( -- check if there are maps in this material and recurse into all subtexmaps local sub_count=getNumSubTexmaps orig_mtl if sub_count >= 1 then ( for i=1 to sub_count do ( newMap = createRedshiftMap (getSubTexmap orig_mtl i) if newMap != #NoReplacement then( setSubTexmap orig_mtl i newMap ) ) ) ) cls=classof orig_mtl -- format orig_mtl.name -- format (" " + cls as string + "\n") local new_mtl=case cls of ( StandardMaterial: errorCatching matConvMethods.convertFrom_Standard orig_mtl -- vray VRayMtl: errorCatching matConvMethods.convertFrom_VrayMtl orig_mtl VRayBlendMtl: errorCatching matConvMethods.convertFrom_VrayBlendMtl orig_mtl VRayLightMtl: errorCatching matConvMethods.convertFrom_VrayLightMtl orig_mtl VRay2SidedMtl: errorCatching matConvMethods.convertFrom_Vray2sidedMtl orig_mtl VRayCarPaintMtl: errorCatching matConvMethods.convertFrom_VRayCarPaintMtl orig_mtl VrayOverrideMtl: errorCatching matConvMethods.convertFrom_VrayOverrideMtl orig_mtl --VrayMtlWrapper: errorCatching matConvMethods.convertFrom_VrayMtlWrapper orig_mtl VRayFastSSS: errorCatching matConvMethods.convertFrom_VRayFastSSS orig_mtl VRayFastSSS2: errorCatching matConvMethods.convertFrom_VRayFastSSS2 orig_mtl --VRayALSurfaceMtl: errorCatching matConvMethods.convertFrom_VRayALSurfaceMtl orig_mtl VRayHairMtl: errorCatching matConvMethods.convertFrom_VRayHairMtl orig_mtl VRaySkinMtl: errorCatching matConvMethods.convertFrom_VRaySkinMtl orig_mtl VRayBumpMtl: errorCatching matConvMethods.convertFrom_VrayBumpMtl orig_mtl -- corona CoronaMtl: errorCatching matConvMethods.convertFrom_CoronaMtl orig_mtl CoronaLightMtl: errorCatching matConvMethods.convertFrom_CoronaLightMtl orig_mtl CoronaLayeredMtl: errorCatching matConvMethods.convertFrom_CoronaLayeredMtl orig_mtl CoronaRaySwitchMtl: errorCatching matConvMethods.convertFrom_CoronaRaySwitchMtl orig_mtl -- wip RaytraceMaterial: errorCatching matConvMethods.CreateDefaultRedshiftMtl orig_mtl default: orig_mtl ) if new_mtl!=orig_mtl then ( -- if converted, add to the list of converted materials append converterTempData.orig_mtls orig_mtl append converterTempData.new_mtls new_mtl ) new_mtl ), fn createRedshiftLights orig_light =( if ((superclassof orig_light)!=light) then return orig_light -- check if this is a light; if not, just return the value local i=findItem converterTempData.orig_lights orig_light -- check if we have already converted this light if i>0 then return converterTempData.new_lights[i] --if yes, just return the already converted one cls=classof orig_light local new_light=case cls of ( VrayLight: errorCatching lightConvMethods.convertFrom_VrayLight orig_light VRayIES: errorCatching lightConvMethods.convertFrom_VrayIES orig_light VraySun: errorCatching lightConvMethods.convertFrom_VraySun orig_light CoronaSun: errorCatching lightConvMethods.convertFrom_CoronaSun orig_light CoronaLight: errorCatching lightConvMethods.convertFrom_CoronaLight orig_light default: orig_light ) if new_light != orig_light then ( -- if converted, add to the list of converted lights append converterTempData.orig_lights orig_light append converterTempData.new_lights new_light ) new_light ), fn cleanUpConversionData =( converterTempData.orig_mtls=#() converterTempData.new_mtls=#() converterTempData.orig_maps=#() converterTempData.new_maps=#() converterTempData.orig_lights=#() converterTempData.new_lights=#() if converterTempData.AD_mats_found then( selectionSets["converted_AD_mtls"] = converterTempData.foundAdskMtls converterTempData.foundAdskMtls = #() scenematerialsUpdateHack() converterTempData.AD_mats_found = false warningMessage = "Autodesk Materials were used in this scene and have been converted, it is STRONGLY recommended to check all those materials before rendering! \nObjects using these Materials have been added to a \"converted_AD_mtls\" selection set" if not converterSettings.silent do messageBox warningMessage title:"Warning" ) clearUndoBuffer() true ), fn additionalSceneSetup =( if converterSettings.switchRenderEngine do ( if classof renderers.current != Redshift_Renderer then( local primarayEngine = secondaryEngine = giEnabled = undefined if substring ((classof renderers.current) as string) 1 10 == "V_Ray_Adv_" then( primarayEngine = renderers.current.gi_primary_type -- 0:IR 1:PM 2:BF 3:LC secondaryEngine = renderers.current.gi_secondary_type -- 0:none 1:PM 2:BF 3:LC giEnabled = renderers.current.gi_on ) local reopen = renderSceneDialog.isOpen() renderSceneDialog.close() renderers.current = Redshift_Renderer() if not renderers.medit_locked do renderers.medit = Redshift_Renderer() if giEnabled == true then( if primarayEngine == 0 or primarayEngine == 2 then( renderers.current.PrimaryGIEngine = case primarayEngine of( 0: #RS_GIENGINE_IRRADIANCE_CACHE 2: #RS_GIENGINE_BRUTE_FORCE ) renderers.current.SecondaryGIEngine = case secondaryEngine of( 0: #RS_GIENGINE_NONE 1: #RS_GIENGINE_NONE 2: #RS_GIENGINE_BRUTE_FORCE 3: #RS_GIENGINE_IRRADIANCE_POINT_CLOUD ) ) ) if reopen do renderSceneDialog.open() ) ) ), -- High-level Converter functionality fn convertSceneLights ErrorReport:true =( -- TODO rs sun start = timeStamp() if converterSettings.printInfo do format "INFO: Converting scene lights...\n" cntr = 0 allLights = for o in objects where superclassof o == light collect o for i in allLights do( if isValidNode i do( if i.parent != undefined and classof i.parent == DaylightAssemblyHead then() else( newLight = createRedshiftLights i if newLight != #NoReplacement do( replaceInstances i newLight ) cntr += 1 ) ) ) for o in (getclassinstances DaylightAssemblyHead) do ( cntr += 1 orig_light = o.sun cls=classof orig_light local new_light=case cls of ( VraySun: errorCatching lightConvMethods.convertFrom_VraySun orig_light --mr_Sun: lightConvMethods.convertFrom_mrSun orig_light CoronaSun: errorCatching lightConvMethods.convertFrom_CoronaSun orig_light IES_Sun: (Redshift_Sun()) Directionallight: (Redshift_Sun()) default: orig_light ) o.sun = new_light if new_light != orig_light do(delete new_light) o.sky=undefined ) delete (for elem in converterTempData.new_lights where (superclassof elem == light) and isvalidnode elem collect elem) end = timeStamp() cTime = ("Light conversion took " + ((end - start) / 1000.0) as string + " seconds ") append converterTempData.conversionTimeInfo cTime if converterSettings.printInfo do format "INFO: %\n" cTime itLts = ("Iterations: " + cntr as string) append converterTempData.conversionTimeInfo itLts if converterSettings.printInfo do format "INFO: %\n" itLts additionalSceneSetup() cleanUpConversionData() if ErrorReport do createErrorReports() ), fn convertSceneMtlsMaps ErrorReport:true =( local isMeditOpen = MatEditor.isOpen() if isMeditOpen then MatEditor.Close() -- material conversion start = timeStamp() if converterSettings.printInfo do format "INFO: Converting scene materials...\n" cntr = 0 for c in converterTempData.supportedMtlClasses do( --where c.creatable cls = execute c if classof cls == material do( clssInst = getclassinstances cls processAllAnimatables:false processChildren:false asTrackViewPick:false -- HUGE SLOW DOWN!!!!!!!!!!!!! for i in clssInst do( replaceInstances i (createRedshiftMtl i processMaps:false) cntr += 1 ) ) ) end = timeStamp() cMtlTime = ("Material conversion took " + ((end - start) / 1000.0) as string + " seconds ") append converterTempData.conversionTimeInfo cMtlTime if converterSettings.printInfo do format "INFO: %\n" cMtlTime itMtl = ("Iterations: " + cntr as string + ", converted: " + converterTempData.new_mtls.count as string) append converterTempData.conversionTimeInfo itMtl if converterSettings.printInfo do format "INFO: %\n" itMtl -- map conversion start = timeStamp() if converterSettings.printInfo do format "INFO: Converting scene maps...\n" cntr = 0 for c in converterTempData.supportedMapClasses do( cls = execute c if classof cls == textureMap do( classInst = getclassinstances cls processAllAnimatables:false processChildren:converterSettings.processChildNodes asTrackViewPick:false -- HUGE SLOW DOWN!!!!!!!!!!!!! for i in classInst do( newMap = createRedshiftMap i if newMap != #NoReplacement then( replaceInstances i newMap ) cntr += 1 ) ) ) end = timeStamp() cMapTime = ("Map conversion took " + ((end - start) / 1000.0) as string + " seconds ") append converterTempData.conversionTimeInfo cMapTime if converterSettings.printInfo do format "INFO: %\n" cMapTime itMap = ("Iterations: " + cntr as string + ", converted: " + converterTempData.new_maps.count as string) append converterTempData.conversionTimeInfo itMap if converterSettings.printInfo do format "INFO: %\n" itMap additionalSceneSetup() cleanUpConversionData() if isMeditOpen then MatEditor.Open() if ErrorReport do createErrorReports() ), fn convertScene =( convertSceneMtlsMaps ErrorReport:false convertSceneLights ErrorReport:false createErrorReports() ), fn convertNodeArray nodeArray ErrorReport:true =( start = timeStamp() if converterSettings.printInfo do format "INFO: Converting scene materials...\n" cntr = 0 for obj in nodeArray do( mat = obj.material if mat != undefined do( replaceInstances mat (createRedshiftMtl mat processMaps:true) cntr += 1 ) ) end = timeStamp() cMtlTime = ("Material conversion took " + ((end - start) / 1000.0) as string + " seconds ") append converterTempData.conversionTimeInfo cMtlTime if converterSettings.printInfo do format "INFO: %\n" cMtlTime itMtl = ("Iterations: " + cntr as string + ", converted: " + converterTempData.new_mtls.count as string) append converterTempData.conversionTimeInfo itMtl if converterSettings.printInfo do format "INFO: %\n" itMtl additionalSceneSetup() cleanUpConversionData() if ErrorReport do createErrorReports() ), fn convertMaterialArray matArray ErrorReport:true =( start = timeStamp() if converterSettings.printInfo do format "INFO: Converting scene materials...\n" cntr = 0 for mat in matArray do( replaceInstances mat (createRedshiftMtl mat processMaps:true) cntr += 1 ) end = timeStamp() cMtlTime = ("Material conversion took " + ((end - start) / 1000.0) as string + " seconds ") append converterTempData.conversionTimeInfo cMtlTime if converterSettings.printInfo do format "INFO: %\n" cMtlTime itMtl = ("Iterations: " + cntr as string + ", converted: " + converterTempData.new_mtls.count as string) append converterTempData.conversionTimeInfo itMtl if converterSettings.printInfo do format "INFO: %\n" itMtl additionalSceneSetup() cleanUpConversionData() if ErrorReport do createErrorReports() ), -- Converter Dialog RedshiftConverterRoll = rollout RedshiftConverterRoll ("Redshift Converter v" + converterTools.getVersion() ) width:466 height:370 ( local owner = if owner != undefined do owner -- Conversion settings Group local lastPos = [8,8] groupBox grpStd "Material features" pos:(lastPos += [0,0]) width:186 height:78 checkbox chkReflstandardMat "Standard: specular to reflection" pos:(lastPos += [8,18]) width:170 height:16 checked:owner.converterSettings.standardMatSpecToRefl tooltip:"Convert Standard_Material specular intensitiy and glossiness to reflection values in a Redshift Mtl" checkbox chkUseAdvVrayBlinnToGgx "VRay: adv. VRayBlinn to GGX" pos:(lastPos += [0,18]) width:168 height:16 checked:owner.converterSettings.vrayUseAdvBlinnToRedshiftGgxConversion tooltip:"If checked uses a conversion table and an output map for converting VrayBlinn glossiness to Redshift GGX, will convert 1:1 otherwise" checkbox chkExplicitGlossinessConv "Explicit Glossiness conversion" pos:(lastPos += [0,18]) width:170 height:16 checked:owner.converterSettings.explicitGlossinessConversion tooltip:"When checked, glossiness values will be converted to roughness by explicitly inverting values and maps instead of using the inbuilt conversion of the Redshift Material (meaning: roughness spinners will still work with roughness instead of glossiness)" groupBox grpOptions "General Options" pos:(lastPos += [-8,26]) width:186 height:126 checkbox chkCorPrefix "add prefix to converted mtls" pos:(lastPos += [8,18]) width:174 height:16 checked:owner.converterSettings.addRedshiftPrefix tooltip:"converted materials will have the prefix added to their name" --pos:(lastPos += [0,52]) edittext edtPrefix "" pos:(lastPos += [14,18]) width:144 height:17 tooltip:"converted materials will have the prefix added to their name" checkbox chkClampIOR "100 fresnel IOR to" pos:(lastPos += [-14,22]) width:106 height:16 checked:owner.converterSettings.clampIor tooltip:"Materials that would be converted to a 100.0 fresnel IOR (e.g. VrayMtls without fresnel reflections activated) can be clamped to a lower IOR with this setting." spinner spnClampedIOR "" pos:(lastPos + [112,0]) width:46 height:32 range:[1.0,100.0,owner.converterSettings.clampIorAmount] enabled:false type:#float tooltip:"Materials that would be converted to a 100.0 fresnel IOR (e.g. VrayMtls without fresnel reflections activated) can be clamped to a lower IOR with this setting." checkbox chkSwitchRen "switch renderer to Redshift" pos:(lastPos += [0,22]) width:168 height:16 checked:owner.converterSettings.switchRenderEngine tooltip:"Assigns Redshift as the current active renderer" checkbox chkDeepSrch "thorough map search" pos:(lastPos += [0,22]) width:168 height:16 checked:owner.converterSettings.processChildNodes tooltip:"Do a more thorough serarch for map classes. Helps to convert maps in lights but will make the conversions slower (sometimes a lot)." groupBox grpConv "Conversion" pos:([8, grpOptions.pos.y + grpOptions.height + 4]) width:186 height:142 radiobuttons rdoMode "" pos:(grpConv.pos + [8, 19]) width:82 height:48 labels:#("All (materials, maps, lights)", "only scene materials and maps", "only scene lights", "materials of selected objects", "selected material editor slot") columns:1 tooltip:"selection modes will convert materials and maps without breaking instancing, so be aware that other materials can be affected!" button btnStartConverting "START CONVERSION" pos:(grpConv.pos + [8,102]) width:170 height:32 -- pos:(lastPos += [0,24]) -- Tools Group local lastPos = [202,8] groupBox grpTools "Tools" pos:(lastPos += [0,0]) width:256 height:352 -- +16 button btnResetMtlEdit "Reset Material Editor Slots to Redshift Materials" pos:(lastPos += [8,20]) width:240 height:20 tooltip:"Resets all Material editor materials to Standard Redshift Mats" label lblShowMaps "Show maps in VP (selected obj):" pos:(lastPos += [5,26]) enabled:false button btnShowMapsInVP "On" pos:(lastPos += [155,-2]) width:40 height:20 enabled:false tooltip:"Workaround for displaying diffuse maps in the viewport - can be VERY SLOW!" button btnUnShowMapsInVP "Off" pos:(lastPos += [40,0]) width:40 height:20 enabled:false tooltip:"Workaround for turning display of diffuse maps in the viewport off" button btnOpacityToSprite "Convert RS_Mtl opacity maps to SpriteMtl" pos:(lastPos += [-200,24]) width:240 height:20 tooltip:"This button will clear out all opacity maps in RS_Materials and create a Sprite material instead. This only happens if the opacity is directly mapped via a bitmaptexture, otherwise the Material will be skipped. This is primarily useful for scenes with foliage where leafs are mapped with opacity textures. \nWARNING: the Sprite material has very limited options, opacity maps will not line up correctly if, for example, crop was used - save your scene before trying it out!" button btnConvertBitmapToRSbitmap "Convert Bitmap to RedshiftBitmap" pos:(lastPos += [0,24]) width:240 height:20 tooltip:"Converts BitmapTexture maps to RedshiftBitmap if possible" button btnAddRSBumpMap "Add RS_Bump_Map to bump slots" pos:(lastPos += [0,24]) width:240 height:20 tooltip:"Adds an RS_Bump_Map in the bump slots of RS_Material, RS_Skin and RS_SSS materials if there are none" button btnFixNormalMapLoaders "Fix normal map gamma" pos:(lastPos += [0,24]) width:240 height:20 tooltip:"overrides gamma for normal maps in RS_Bump_Map with 1.0" button btnOnlineCheck "Check online for new converter versions" pos:(lastPos += [0,24]) width:240 height:20 tooltip:"Opens a window with info about available converter versions" hyperlink hprDwnld " Visit the converter download page" pos:(lastPos += [0,24]) address:"http://www.racoon-artworks.de/RedshiftConverter/RedshiftConverter.html" visitedColor:owner.converterSettings.uiLinkColor color:owner.converterSettings.uiLinkColor pos:(lastPos += [0,24]) hyperlink hprForum " Visit the Redshift Forum dicsussion thread" pos:(lastPos += [0,18]) address:"https://www.redshift3d.com/forums/viewthread/15634/" visitedColor:owner.converterSettings.uiLinkColor color:owner.converterSettings.uiLinkColor pos:(lastPos += [0,24]) label lblWarn "" pos:(grpTools.pos + [10,224]) width:240 height:70 -- hyperlink hlmxsDoc "Maxscript Documentation" address:"https://corona-renderer.com/link/4004" visitedColor:owner.converterSettings.uiLinkColor color:owner.converterSettings.uiLinkColor pos:[grpReaddMe.pos.x + 95 ,(lblDesc.pos.y + 52)] -- DEBUG checkBox chkErrorCatching "use try/catch bug reporting" pos:(grpConv.pos + grpConv.height + [-120,20]) checked:owner.converterSettings.useTryCatchBugReporting on chkErrorCatching changed state do( owner.converterSettings.useTryCatchBugReporting = state ) -- Gui handler on chkReflstandardMat changed state do( owner.converterSettings.standardMatSpecToRefl = state ) on chkUseAdvVrayBlinnToGgx changed state do( owner.converterSettings.vrayUseAdvBlinnToRedshiftGgxConversion = state ) on chkExplicitGlossinessConv changed state do( owner.converterSettings.explicitGlossinessConversion = state ) on chkConvVrayHDRI changed state do( owner.converterSettings.VrayHDRIToBitmaptexture = state ) on chkCorPrefix changed state do( owner.converterSettings.addRedshiftPrefix = state ) on edtPrefix changed txt do( owner.converterSettings.userPrefixStr = txt ) on chkClampIOR changed state do( spnClampedIOR.enabled = state owner.converterSettings.clampIor = state ) on spnClampedIOR changed val do( owner.converterSettings.clampIorAmount = val ) on chkSwitchRen changed state do( owner.converterSettings.switchRenderEngine = state ) on chkDeepSrch changed state do( owner.converterSettings.processChildNodes = state ) -- Tools on btnResetMtlEdit pressed do( owner.converterTools.resetMtlEdit() ) on btnShowMapsInVP pressed do( owner.converterTools.showMapsInVP true selected:true ) on btnUnShowMapsInVP pressed do( owner.converterTools.showMapsInVP false selected:true ) on btnOpacityToSprite pressed do( owner.converterTools.convertOpacityToSpriteMtl() ) on btnConvertBitmapToRSbitmap pressed do( owner.converterTools.convertBitmapToRSbitmap() ) on btnAddRSBumpMap pressed do( owner.converterTools.addRsBumpMapToSlots() ) on btnFixNormalMapLoaders pressed do( for map in (getclassinstances RS_Bump_Map) do( owner.converterTools.fixNormalMapGamma map ) ) on btnOnlineCheck pressed do( owner.converterTools.checkForNewVersion() ) -- start conversion button on btnStartConverting pressed do( max create mode with animate off ( case rdoMode.state of( 1: owner.convertScene() 2: owner.convertSceneMtlsMaps() 3: owner.convertSceneLights() 4: owner.convertNodeArray (selection as array) 5: owner.convertMaterialArray #(meditmaterials[activeMeditSlot]) ) ) -- if chkConvertProxies.checked then( -- if (getClassInstances VrayProxy).count != 0 then( -- CoronaProxyConverter.openGui() -- ) -- ) format "Conversion done.\n" ) on RedshiftConverterRoll open do( fn getIniSet sectionStr keyStr default =( out = (getinisetting owner.converterSettings.iniPath sectionStr keyStr) as string if out == "" then out = default as string out ) cc = owner.converterSettings chkReflstandardMat.checked = cc.standardMatSpecToRefl = if (getIniSet "Standard" "SpecToRefl_Checked" cc.standardMatSpecToRefl) == "true" then true else false chkUseAdvVrayBlinnToGgx.checked = cc.vrayUseAdvBlinnToRedshiftGgxConversion = if (getIniSet "Vray" "AdvBlinnToCoronaGGX" cc.vrayUseAdvBlinnToRedshiftGgxConversion) == "true" then true else false chkExplicitGlossinessConv.checked = cc.explicitGlossinessConversion = if (getIniSet "Common" "ExplicitGlossiConversion" cc.explicitGlossinessConversion) == "true" then true else false edtPrefix.text = cc.userPrefixStr = (getIniSet "Options" "userString_String" cc.userPrefixStr) as string chkCorPrefix.checked = cc.addRedshiftPrefix = if (getIniSet "Options" "userString_Checked" cc.addRedshiftPrefix) == "true" then true else false chkClampIOR.checked = cc.clampIor = if (getIniSet "Options" "ClampIor_Checked" cc.clampIor) == "true" then true else false spnClampedIOR.value = cc.clampIorAmount = (getIniSet "Options" "ClampIor_Value" cc.clampIorAmount) as float spnClampedIOR.enabled = chkClampIOR.checked chkSwitchRen.checked = cc.switchRenderEngine = if (getIniSet "Options" "SwitchEngine_Checked" cc.switchRenderEngine) == "true" then true else false chkDeepSrch.checked = cc.processChildNodes = if (getIniSet "Options" "DeepSearch_Checked" cc.processChildNodes) == "true" then true else false cc.dialogPosX = (getIniSet "DialogPos" "pos_x" cc.dialogPosX) as float cc.dialogPosY = (getIniSet "DialogPos" "pos_y" cc.dialogPosY) as float if cc.dialogPosX != 0.0 and cc.dialogPosY != 0.0 then ( if (cc.dialogPosX > 0 and cc.dialogPosX < sysInfo.desktopSize.x - 200) do( if (cc.dialogPosY > 0 and cc.dialogPosY < sysInfo.desktopSize.y - 100) do( SetDialogPos RedshiftConverterRoll [cc.dialogPosX, cc.dialogPosY] ) ) ) if cc.exposeDebugSettings then RedshiftConverterRoll.height += 60 lblWarn.text += "WARNING: Bump Map heights are currently mismatching due to VRay/Corona using UV-space and Redshift using World-space for calculating heights. You will need to adjust those by hand for now until a workaround is found.\n" ) on RedshiftConverterRoll close do( ini = owner.converterSettings.iniPath setINISetting ini "Standard" "SpecToRefl_Checked" (chkReflstandardMat.checked as string) setINISetting ini "Vray" "AdvBlinnToCoronaGGX" (chkUseAdvVrayBlinnToGgx.checked as string) setINISetting ini "Common" "ExplicitGlossiConversion" (chkExplicitGlossinessConv.checked as string) setINISetting ini "Options" "userString_String" edtPrefix.text setINISetting ini "Options" "userString_Checked" (chkCorPrefix.checked as string) setINISetting ini "Options" "ClampIor_Checked" (chkClampIOR.checked as string) setINISetting ini "Options" "ClampIor_Value" (spnClampedIOR.value as string) setINISetting ini "Options" "SwitchEngine_Checked" (chkSwitchRen.checked as string) setINISetting ini "Options" "DeepSearch_Checked" (chkDeepSrch.checked as string) try(setINISetting ini "DialogPos" "pos_x" ((GetDialogPos owner.RedshiftConverterRoll).x as string) )catch() try(setINISetting ini "DialogPos" "pos_y" ((GetDialogPos owner.RedshiftConverterRoll).y as string) )catch() ) ), fn openGui =( createDialog RedshiftConverterRoll style:#(#style_titlebar, #style_sysmenu, #style_minimizebox) ), fn destroyGui =( try(destroydialog RedshiftConverterRoll)catch() ), on create do( RedshiftConverterRoll.owner = this try(deleteItem selectionsets (selectionSets["converted_AD_mtls"]))catch() ) ) RSConverter = RSConverterStr() if RSConverterSuppressGui == false or RSConverterSuppressGui == undefined do( try(windows.sendMessage (windows.getChildHWND 0 ("Redshift Converter v" + RSConverter.converterVersion) parent:#max)[1] 0x0010 0 0)catch() convVers = RSConverter.converterTools.getVersion() -- this script's version reqBuild = RSConverter.converterSettings.requiredBuildNumber -- lowest Redshift build version accepted instBuild = RSConverter.converterTempData.redshiftBuildNumber if not RSConverter.isRedshiftVersionOfDateOrHigher() then( msg = "" as stringstream format "RedshiftConverter v.% requires Redshift %.%.% or later to work properly.\nYour currently installed Redshift version is %.%.%" \ convVers reqBuild[1] reqBuild[2] reqBuild[3] instBuild[1] instBuild[2] instBuild[3] to:msg messagebox msg title:"Version mismatch!" ) RSConverter.openGui() ) )