![[重点]UE的GROOM毛发贴图显示不出的方法-优化老外插件](http://pic.xiahunao.cn/yaotu/[重点]UE的GROOM毛发贴图显示不出的方法-优化老外插件)
【b站】老外GroomExporter不管新版还是老版导不出纹理踩的坑--因为阉割了surface_uv_coordinate的数据当前UE GROOM毛发需要一个很关键的数据就是毛发的ROOT UV数据信息但是UE官方只提供了针对MAYA的XGEN毛发的ROOT UV导出代码。也就是说现在GROOM毛发官方给出的标准工作流只针对了MAYAmaya的显示很卡。这个数据的重要性使得我们的毛发无法读取正确的贴图信息在制作带有复杂颜色动物的毛皮时成为一个巨大的BUG级问题。Blender毛发是带有原覆着面的UV信息的但是导出ABC的时候并不适配GROOM的 ROOT UV。这个Blender开发官方也明确表明了没有开发这一块的计划(或许人家故意挖的坑免费的不是那么好拿的)。幸亏有了强大的AI帮我们解决了surface_uv_coordinate属性的UV值的写入问题现在blender to UE毛发工作流的唯一完美解决即支持blender几何节点毛发也支持blender的粒子毛发一定要取消勾选“显示发射体”导出时勾选“导出毛发 (Export Hair)”不勾选“导出粒子”至此Blener也可以像Maya一样愉快完美的干好各种毛发并导出到UE里了。下面是关于maya的rootuv的官方处理过程maya的毛发缺点是不支持太多的毛发显示会很卡UE_MayaXgen导入UE的Groom毛发流程_哔哩哔哩_bilibilihttps://dev.epicgames.com/documentation/zh-cn/unreal-engine/xgen-guidelines-for-hair-creation-in-unreal-engine【epic官方】maya的xgen毛发导出UE的groom毛发插件的脚本simple_hair_uv.py导出 rootuvfrom maya import cmds from maya import OpenMaya import os def create_root_uv_attribute(curves_group, mesh_node, uv_setmap1): Create groom_root_uv attribute on group of curves. # check curves group if not cmds.objExists(curves_group): raise RuntimeError(Group not found: {}.format(curves_group)) # get curves in group curve_shapes cmds.listRelatives(curves_group, shapesTrue, noIntermediateTrue) curve_shapes cmds.ls(curve_shapes, typenurbsCurve) if not curve_shapes: raise RuntimeError(Invalid curves group. No nurbs-curves found in group.) else: print found curves print curve_shapes # get curve roots points list() for curve_shape in curve_shapes: point cmds.pointPosition({}.cv[0].format(curve_shape), worldTrue) points.append(point) # get uvs values list() uvs find_closest_uv_point(points, mesh_node, uv_setuv_set) for u, v in uvs: values.append([u, v, 0]) #print (str(u) , str(v) ) # create attribute name groom_root_uv cmds.addAttr(curves_group, lnname, dtvectorArray) cmds.addAttr(curves_group, ln{}_AbcGeomScope.format(name), dtstring) cmds.addAttr(curves_group, ln{}_AbcType.format(name), dtstring) cmds.setAttr({}.{}.format(curves_group, name), len(values), *values, typevectorArray) cmds.setAttr({}.{}_AbcGeomScope.format(curves_group, name), uni, typestring) cmds.setAttr({}.{}_AbcType.format(curves_group, name), vector2, typestring) return uvs def find_closest_uv_point(points, mesh_node, uv_setmap1): Find mesh UV-coordinates at given points. # check mesh if not cmds.objExists(mesh_node): raise RuntimeError(Node not found: {}.format(mesh_node)) # check uv_set uv_sets cmds.polyUVSet(mesh_node, qTrue, allUVSetsTrue) if uv_set not in uv_sets: raise RuntimeError(Invalid uv_set provided: {}.format(uv_set)) # get mesh as dag-path selection_list OpenMaya.MSelectionList() selection_list.add(mesh_node) mesh_dagpath OpenMaya.MDagPath() selection_list.getDagPath(0, mesh_dagpath) mesh_dagpath.extendToShape() # get mesh function set fn_mesh OpenMaya.MFnMesh(mesh_dagpath) uvs list() for i in range(len(points)): script_util OpenMaya.MScriptUtil() script_util.createFromDouble(0.0, 0.0) uv_point script_util.asFloat2Ptr() point OpenMaya.MPoint(*points[i]) fn_mesh.getUVAtPoint(point, uv_point, OpenMaya.MSpace.kWorld, uv_set) u OpenMaya.MScriptUtil.getFloat2ArrayItem(uv_point, 0, 0) v OpenMaya.MScriptUtil.getFloat2ArrayItem(uv_point, 0, 1) uvs.append((u, v)) return uvs def abc_export(filepath, nodeNone, start_frame1, end_frame1, data_formatotawa, uv_writeTrue): job_command -frameRange {} {} .format(start_frame, end_frame) job_command -dataFormat {} .format(data_format) job_command -attr groom_root_uv if uv_write: job_command -uvWrite job_command -root {} .format(node) job_command -file {} .format(filepath) cmds.AbcExport(verboseTrue, jjob_command) def main(): export_directory D:/Dev/Ref hair_file os.path.join(export_directory, hair_export.abc) curve_top_group description1|SplineGrp0 uv_meshpPlane1 create_root_uv_attribute( curve_top_group , uv_mesh) abc_export(hair_file, curve_top_group) main()材质设置1shading model 设置为hair材质设置2used with hair strands下面是关于max 的rootuv的处理过程1、先把y轴缩放改为-1max的毛发导入到maya里用groom脚步导入UE5blender导出的选项【照着这个用claude做了个blender版本的】也参考加菲猫教程先把几何节点和粒子毛发导出abc再导入abc一次先把粒子毛发或者几何节点毛发导出abc再导入abc获得曲线组1、选择曲线组上的毛发图标增加surface_uv_coordinate自定义属性spline2dvector选择依附面和uv集。2、选择2导的毛发的曲线组的毛发图标新开窗口打开spreadsheet选择spline查看新写入的surface_uv_coordinate属性的值开始没有以下数据的在脚本窗口头贴入以下代码修改准确后点执行surface_uv_coordinate便有了数据。【此处不提供关键脚本】或者使用GroomExporter_v013(zsz优化过的版本)插件导出forUE groom毛发的abc【此处也不提供优化过的插件】