很多设计师在 MD 里做出漂亮的衣服,导出到 Blender/Maya 就发现面数爆炸、UV 全乱;再进 UE5 又发现布料不能动、穿上角色就穿模。问题不在某一步,而在整条链路缺乏交付标准:每个环节各自为政,上一环不关心下一环需要什么。
专业定位是:MD 服装资产 = 仿真 → 重拓扑 → UV → 烘焙 → 绑定 → 引擎接入的完整链路,每一环都有明确的交付契约。设计得再好看,过不了重拓扑和引擎这关,就是废资产。
仿真阶段:在MD里用足够高的精度跑出褶皱,导出高模(保留细节,不管面数)。
重拓扑阶段:把高模减到引擎可接受的面数(单件服装 5k-20k 三角面),保留主要褶皱的形体。
UV与烘焙:为低模展UV,把高模的法线、褶皱细节烘到法线贴图。
绑定阶段:根据服装类型(紧身/宽松/刚性)选择蒙皮方式。
引擎接入:UE5 中用 Chaos Cloth 或骨骼驱动,配置碰撞体与物理参数。
(1)重拓扑面数目标:按服装类型分级
def target_polycount(garment_type: str, lod: int = 0) -> int:
"""按服装类型与LOD定面数预算:紧身低、宽松高"""
base = {"shirt": 8000, "pants": 10000, "coat": 15000,
"dress": 12000, "accessory": 3000}
lod_ratio = {0: 1.0, 1: 0.5, 2: 0.25, 3: 0.1}
return int(base.get(garment_type, 8000) * lod_ratio[lod])
# 验收:重拓扑后面数落在目标±15%内(2)UV检查:拉伸率与岛屿利用率
import numpy as np
def uv_quality(vertices_3d, uvs, faces) -> dict:
"""UV拉伸率与利用率:拉伸大→贴图糊,利用率低→浪费分辨率"""
tri3 = vertices_3d[faces]; tri2 = uvs[faces]
a3 = 0.5 * np.linalg.norm(np.cross(tri3[:,1]-tri3[:,0], tri3[:,2]-tri3[:,0]), axis=1)
a2 = 0.5 * np.abs(np.cross(tri2[:,1]-tri2[:,0], tri2[:,2]-tri2[:,0]))
ratio = np.sqrt(a2 / np.maximum(a3, 1e-9))
ratio /= np.median(ratio)
stretch = np.maximum(ratio, 1 / np.maximum(ratio, 1e-9))
# 利用率:UV包围盒面积 / 总面积,理想>60%
u0, v0 = uvs.min(0); u1, v1 = uvs.max(0)
util = np.sum(a2) / ((u1-u0)*(v1-v0) + 1e-9)
return {"stretch_p95": round(float(np.percentile(stretch, 95)), 3),
"utilization": round(float(util), 3)}
# 验收:stretch_p95<1.5,utilization>0.6(3)法线烘焙:高模细节转低模贴图
def bake_normal(low_mesh, high_mesh, cage_offset=0.015):
"""高模法线烘到低模切线空间,cage 防止边缘漏烘"""
import trimesh
origins = low_mesh.vertices + low_mesh.vertex_normals * cage_offset
locs, idx_ray, idx_tri = high_mesh.ray.intersects_location(
ray_origins=origins, ray_directions=-low_mesh.vertex_normals)
n_world = np.zeros_like(low_mesh.vertices)
for v, tri in zip(idx_ray, idx_tri):
n_world[v] = high_mesh.face_normals[tri]
# 切线空间编码:与引擎切线基必须一致
T = low_mesh.vertex_normals
B = np.cross(low_mesh.vertex_normals, T)
n_tan = np.einsum("vij,vj->vi", np.stack([T, B, low_mesh.vertex_normals], 1), n_world)
n_tan[:, :2] = n_tan[:, :2] * 0.5 + 0.5
return n_tan
# 验收:引擎内法线光照方向与MD一致,偏差<3°(4)绑定策略:按服装类型选择方式
def binding_strategy(garment_type: str, tightness: float) -> dict:
"""紧身→骨骼蒙皮;宽松→Chaos Cloth;刚性配件→单骨骼"""
if garment_type == "accessory" or tightness > 0.9:
return {"method": "rigid_skin", "bones": "nearest",
"note": "配件或极紧身,绑到最近骨骼"}
if tightness > 0.6:
return {"method": "skinned", "max_influence": 4,
"note": "半紧身,常规蒙皮即可"}
return {"method": "chaos_cloth", "iterations": 3,
"collision_thickness": 1.5,
"note": "宽松服装,需要布料模拟才能自然"}
# 验收:宽松外套在角色走动时有自然摆动,紧身衣无异常抖动(5)UE5接入:Chaos Cloth参数配置
def chaos_cloth_config(fabric: FabricProfile) -> dict:
"""把MD物理参数翻译成UE5 Chaos Cloth参数"""
return {
"damping_coefficient": fabric.damping / 10.0,
"friction_coefficient": fabric.friction,
"bending_stiffness": fabric.bending * 0.01, # 量纲转换
"anim_drive_stiffness": 0.5 if fabric.stretch > 150 else 0.2,
"collision_thickness": 1.0,
"solver_frequency": 120 if fabric.bending > 100 else 60,
}
# 验收:引擎内布料运动与MD预览形态相似度>75%(6)交付验收:整条链路逐项检查
def delivery_check(mesh, uv, normal_map, engine_cfg) -> dict:
checks = {
"polycount_ok": len(mesh.faces) <= 20000,
"non_manifold": 0,
"uv_ok": uv_quality(mesh.vertices, uv, mesh.faces)["stretch_p95"] < 1.5,
"normal_baked": normal_map is not None,
"engine_cfg_complete": all(k in engine_cfg for k in
("bending_stiffness", "damping_coefficient", "collision_thickness")),
}
return {"passed": all(checks.values()), "checks": checks}
# 验收:五项全过才允许入库;任一项失败标注具体原因六项硬指标:面数达标率(落在目标±15%内=100%)、UV拉伸(p95<1.5)、法线烘焙一致性(引擎内光照偏差<3°)、绑定方式正确率(按服装类型匹配=100%)、引擎内形态相似度(与MD预览>75%)、交付检查通过率(五项全过=100%)。前两项决定“资产能不能用”,中间两项决定“细节保不保真”,后两项决定“引擎里动不动得对”。
Marvelous Designer 的工程核心,是把它当成流程中间站,按下游需求定义交付标准:仿真出细节、重拓扑控面数、UV控拉伸、烘焙保细节、绑定按类型选方式、引擎参数做量纲转换。每一环都为下一环负责,服装资产才不是"MD里好看、引擎里不能用"的半成品。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。