【问题标题】:Add texture with output modifier to material with MaxScript使用 MaxScript 将带有输出修改器的纹理添加到材质
【发布时间】:2018-09-22 00:29:20
【问题描述】:

我有一个场景,其纹理连接到输出修改器,然后连接到材质的漫反射槽 (CoronaMtl)。

我需要遍历文件夹内的多个纹理,将它们分配给材质(分配给一个对象),渲染它,然后保存图像。

一切正常,但我无法理解如何应用的输出修饰符。我当前的脚本已经搜索文件、创建数组、将纹理应用到正确的材质、渲染和保存,但是,如果没有输出调整,这一切都毫无意义。

任何人都可以照亮它吗?

这是我的材料: https://i.stack.imgur.com/AZe1r.png

这是目前为止的脚本:

carMake = "Chevy" -- Case Sensitive

liveriesFiles = "C:\\Path\\PaintSchemes\\" + carMake as string + "\\PAINT_*_PRIMARY.png"
glossFiles = "C:\\Path\\PaintSchemes\\" + carMake as string + "\\PAINT_*_PRIMARY_MAT_ID.png"

liveries = getFiles liveriesFiles
gloss = getFiles glossFiles

for livery in liveries do ( 
    sceneMaterials["CHEVY"].texmapDiffuse = Bitmaptexture fileName: livery      
    index = findItem liveries livery

    sceneMaterials["CHEVY"].texmapReflectGlossiness = Bitmaptexture fileName: gloss[index]

    CoronaRenderer.CoronaFp.showvfb true
    actionMan.executeAction 0 "50031" -- Render

    splitString = filterString livery "\ ."
    elementName = replace splitString[12] 1 6 ""

    savePath = "C:\\Path\\PaintSchemes\\" + carMake as string + "\\renders\\" + elementName as string + ".png"  
    CoronaRenderer.CoronaFp.saveAllElements savePath
)

【问题讨论】:

    标签: 3dsmax maxscript


    【解决方案1】:

    要创建输出纹理,请使用outputTex = Output map1:bitmapTex,其中 bitmapTex 是一个变量,用于保存您希望分配的 BitmapTexture。输出纹理贴图的输出属性(此处术语的双重使用可能会造成混淆)将在 outputTex.output 中。

    您可以使用showproperties outputTexshowproperties outputTex.output 检查可用的属性。例如,通过outputTex.output.clamp = trueoutputTex.output.invert = true 设置反转和钳位复选框。另外一点,您可以在字符串常量前面加上 @ 来表示忽略转义字符的文字路径字符串,或者在 MaxScript 路径字符串中使用 / 作为 \ 的替换。

    注意 - 如果输出纹理贴图尚不存在,则无法为输出纹理贴图创建颜色曲线。该曲线只能通过用户界面通过单击“启用颜色映射”来创建。这是 MaxScript 的限制。然而,这个限制可以通过 C++ 来解决(更多细节请咨询)。

    使用标准材质而不是 CoronaMtl 和 Corona 渲染器,这是一个示例脚本:

    -- See available properties the Output map, assuming on the Diffuse slot of Standard material
    showproperties (sceneMaterials["CHEVY"].diffusemap)
    showproperties (sceneMaterials["CHEVY"].diffusemap.output)
    
    -- Run the test
    carMake = "Chevy" -- Case Sensitive
    rootPath = @"D:\Temp\PaintSchemes" + carMake as string + @"\"
    liveriesFiles = rootPath + @"Test_Map*A.png"
    glossFiles = rootPath + @"Test_Map*B.png"
    
    liveries = getFiles liveriesFiles
    gloss = getFiles glossFiles
    
    for livery in liveries do ( 
        bitmap1 = Bitmaptexture fileName: livery      
        output1 = Output map1:bitmap1
        output1.output.clamp = true
        sceneMaterials["CHEVY"].diffuseMap = output1
    
        index = findItem liveries livery
        bitmap2 = Bitmaptexture fileName: gloss[index]      
        output2 = Output map1:bitmap2
        output2.output.invert = true
        sceneMaterials["CHEVY"].glossinessMap = output2
    
        max quick render
    
        splitString = filterString livery "\ ."
        elementName = splitString[4]
    
        r = getLastRenderedImage()
        r.filename = rootPath + @"\renders\" + elementName as string + ".png"  
        save r
    )
    

    【讨论】:

      猜你喜欢
      • 2012-09-06
      • 1970-01-01
      • 2012-11-15
      • 2015-05-17
      • 1970-01-01
      • 2016-03-25
      • 2013-07-30
      • 2022-06-14
      • 1970-01-01
      相关资源
      最近更新 更多