AgentSkillsCN

Materials

创建材质、材质实例,或在Unreal Engine中对材质进行分类与管理。

SKILL.md
--- frontmatter
description: Creating materials, material instances, or organizing materials in Unreal Engine

UE5 Materials

Best practices for material creation and organization in Unreal Engine 5.

Naming Convention

PrefixAsset Type
M_Material
MI_Material Instance
MF_Material Function
MPC_Material Parameter Collection

Examples: M_Rock_Master, MI_Rock_Mossy, MF_WorldAlignedTexture

Folder Organization

code
Content/
└── ProjectName/
    └── MaterialLibrary/        # Shared/global materials
        ├── Master/             # Master materials
        ├── Functions/          # Material functions
        ├── Instances/          # Common instances
        └── ParameterCollections/

Master Material Design

Create versatile master materials with static switches:

code
M_Environment_Master
├── [Switch] Use Normal Map
├── [Switch] Use Roughness Map
├── [Switch] Use Metallic Map
├── [Switch] Enable Parallax
├── [Switch] Enable Detail Textures
└── Parameters...

Static switches compile out unused features - no runtime cost.

Parameter Organization

Use numbered prefixes for consistent parameter ordering:

PrefixCategory
00Base Color
01Normal
02Roughness
03Metallic
04Emissive
05Tiling/UV
06Detail
07Special

Example parameter names:

  • 00_BaseColor
  • 01_NormalIntensity
  • 02_RoughnessMin
  • 02_RoughnessMax

Material Parameter Collections (MPCs)

Global parameters accessible by any material:

cpp
// In C++ or Blueprint
UMaterialParameterCollection* MPC = LoadObject<UMaterialParameterCollection>(...);
UKismetMaterialLibrary::SetScalarParameterValue(World, MPC, "GlobalWetness", 0.5f);
RuleDetails
Max 2 MPCs per materialPerformance limit
Use for global effectsWeather, time of day, etc.
Avoid per-object dataUse Material Instances instead

Material Instances

Always use Material Instances, not material copies

code
M_Character_Master          # Master material
├── MI_Character_Player     # Player instance
├── MI_Character_Enemy_01   # Enemy variant
└── MI_Character_Enemy_02   # Enemy variant

Benefits:

  • Shared shader compilation
  • Easy parameter tweaking
  • Reduced memory usage

Material Functions

Reusable node groups:

code
MF_WorldAlignedTexture     # Common triplanar projection
MF_HeightBlend             # Landscape layer blending
MF_Fresnel_Custom          # Custom fresnel calculation

Best Practices

PracticeReason
Use Material InstancesNot duplicate materials
Static switches over dynamicCompiles out unused code
Material Functions for reuseMaintainable node graphs
Limit MPCs to 2 per materialGPU performance
Numbered parameter groupsConsistent UI ordering

Anti-Patterns

AvoidWhy
Over-featured master materialsShader permutation bloat
Copying materials for variantsMemory waste
Too many dynamic switchesRuntime cost
Excessive texture samplesPerformance

Performance Tips

  • Use texture packing (ORM)
  • Limit instruction count
  • Use LOD for material complexity
  • Profile with Shader Complexity view

Documentation: https://dev.epicgames.com/documentation/en-us/unreal-engine/instanced-materials-in-unreal-engine