3dmax中VRay的3d导出glb的模型是黑白的,没有带贴图

错误案例:导出的3dmax.jlb文件在vue中运行,是黑色的

解决办法:直接用下面的代码运行

复制代码
import pymxs
from pymxs import runtime as rt

def convert_vray_to_physical_material(convert_to_physical=True):
    """
    将场景中所有 VRayMtl 转换为 Physical Material 或 Standard Material
    :param convert_to_physical: True=转Physical Material, False=转Standard Material
    """
    rt.redrawViews()  # 刷新视图

    # 获取场景中所有VRay材质
    vray_materials = [mat for mat in rt.sceneMaterials if rt.isKindOf(mat, rt.VRayMtl)]
    
    if not vray_materials:
        rt.messageBox("场景中没有找到 VRayMtl 材质!", title="提示")
        return

    for vray_mat in vray_materials:
        try:
            new_mat = None
            mat_name = vray_mat.name
            
            if convert_to_physical:
                # 创建 Physical Material
                new_mat = rt.PhysicalMaterial()
                new_mat.name = f"{mat_name}_Physical"
                
                # 复制基础属性
                if hasattr(vray_mat, "diffuse"):
                    new_mat.base_color = vray_mat.diffuse
                
                if hasattr(vray_mat, "reflection"):
                    new_mat.metalness = 0.0  # 非金属
                    new_mat.roughness = 1.0 - vray_mat.reflection_glossiness
                    new_mat.ior = 1.5  # 默认值
            else:
                # 创建 Standard Material
                new_mat = rt.StandardMaterial()
                new_mat.name = f"{mat_name}_Standard"
                
                # 复制基础属性
                if hasattr(vray_mat, "diffuse"):
                    new_mat.diffuse = vray_mat.diffuse
                
                if hasattr(vray_mat, "reflection"):
                    new_mat.specular_level = vray_mat.reflection_amount * 100
                    new_mat.glossiness = vray_mat.reflection_glossiness * 100

            # 替换材质
            rt.replaceInstances(vray_mat, new_mat)
            print(f"已转换材质: {mat_name} -> {new_mat.name}")
        except Exception as e:
            print(f"转换失败: {vray_mat.name} | 错误: {str(e)}")

    rt.messageBox(f"转换完成!共处理 {len(vray_materials)} 个VRay材质。", title="完成")

# 调用示例(默认转Physical Material)
convert_vray_to_physical_material(convert_to_physical=True)

插件安装步骤

  1. 保存脚本

    • 将上述代码复制到记事本,保存为 VRayToPhysicalMaterialConverter.py(确保扩展名是 .py)。
  2. 安装到3ds Max

    • 方法1(临时运行)

      打开3ds Max → 菜单栏 ScriptingRun Script → 选择该脚本文件。

    • 方法2(永久安装)

      将脚本文件放入3ds Max的脚本目录(如 C:\Users\<用户名>\AppData\Local\Autodesk\3dsMax\<版本>\ENU\scripts\),然后通过 MAXScript监听器 输入以下命令加载:

      python.executeFile("VRayToPhysicalMaterialConverter.py")

  3. 自定义按钮(可选)

    • 打开 Customize User InterfaceToolbars → 新建一个工具栏。

    • Category 中选择 Python,找到脚本名称拖到工具栏即可生成按钮。

运行后的结果:

相关推荐
心疼你的一切4 小时前
三维创世:CANN加速的实时3D内容生成
数据仓库·深度学习·3d·aigc·cann
3DVisionary13 小时前
掌控发动机“心脏”精度:蓝光3D扫描在凸轮轴全尺寸检测中的应用
3d·图形渲染·汽车发动机·精密测量·蓝光3d扫描·凸轮轴检测·形位公差
coder攻城狮19 小时前
VTK系列1:在屏幕绘制多边形
c++·3d
PHOSKEY21 小时前
3D工业相机如何“读透”每一个字符?快速识别、高精度3D测量
数码相机·3d
XX風1 天前
7.2 harris 3d
3d
多恩Stone1 天前
【3D-AICG 系列-3】Trellis 2 的O-voxel (下) Material: Volumetric Surface Attributes
人工智能·3d·aigc
多恩Stone1 天前
【3D-AICG 系列-1】Trellis v1 和 Trellis v2 的区别和改进
人工智能·pytorch·python·算法·3d·aigc
三年模拟五年烧烤1 天前
easy-threesdk快速一键搭建threejs3d可视化场景
3d·threejs
top_designer1 天前
Materialize:手绘地表太假?“PBR 纹理炼金术” 5分钟生成次世代材质
游戏·3d·aigc·材质·设计师·游戏美术·pbr
esmap1 天前
OpenClaw与ESMAP AOA定位系统融合技术分析
前端·人工智能·计算机视觉·3d·ai·js