Mass Battle Frameworkv1.20.0

GPU Shaders (.ush)

HLSL INCLUDE LIBRARY

Source/MassBattle/HLSL/*.ush

着色器总览 Overview

Mass Battle 的 GPU 侧由一组 .ush 包含文件构成。它们被插件自带的 Niagara 系统(预测/插值)、材质(Custom 节点)与 GPU 计算着色器按需引用,负责渲染侧的插值、外推、参数解码与骨骼计算——GPU 不产生任何模拟状态。日常使用不需要改动这些文件:随插件发行的 Niagara 系统已经接好,材质侧则由 MF_MassBattleMaterialFunction 接进你的源材质,没有一份固定的 VAT 主材质需要你替换。只有当你在自建材质、Niagara 系统或计算着色器上复用 MassBattle 的渲染数据时,才会用到它们。

The GPU side of Mass Battle consists of a set of .ush include files. They are referenced as needed by the plugin's bundled Niagara systems (prediction / interpolation), materials (Custom nodes) and GPU compute shaders, handling render-side interpolation, extrapolation, parameter decoding and bone computation — the GPU never produces simulation state. Day-to-day use never requires editing these files: the shipped Niagara systems are already wired, and on the material side MF_MassBattleMaterialFunction is grafted into your source material — there is no fixed VAT master to swap in. You only touch them when reusing MassBattle render data in your own materials, Niagara systems or compute shaders.

如何在自定义材质/系统中引用:插件启动时把 Source/MassBattle/HLSL 注册为虚拟着色器路径 /MassBattle;Niagara Custom HLSL 节点与材质 Custom 节点通过 VirtualIncludeFilePaths="/MassBattle/<文件名>.ush" 包含。自建材质时,并没有一份官方 VAT 主材质可以改:烘焙复制源材质,把 MF_MassBattleMaterialFunction 嫁接进那份副本(适配器契约:恰好一个 InAttributes 输入引脚,类型为 material attributes;至少一个 Out 输出),材质实例再以副本为父——直接读它解码后的输出,不要自行解包参数通道。sprite 走另一条路:图集资产(UMassBattleATADataAsset)的 MasterMaterial 指向薄 sprite 母材质,由 Material.BuildSpriteMaster 建(Unlit + Masked + attributes 驱动,声明 MB_AtlasTexture / MB_AtlasCols / MB_AtlasRows / MB_SpriteMode 四个参数);该字段为空时烘焙只记一行日志并跳过材质实例创建,不会回退到任何 M_VATMaster*。M_VATMaster 仅作为 37 份历史演示材质(/MassBattle/Demo/Agent/*/Gen_*)的父材质保留,M_VATMaster_CS 已于 2026-11-14 删除(删除时已无引用);两者都不是新材质的出发点。

How to reference them in custom materials / systems: at startup the plugin registers Source/MassBattle/HLSL as the virtual shader path /MassBattle; Niagara Custom HLSL nodes and material Custom nodes include via VirtualIncludeFilePaths="/MassBattle/<file>.ush". When building your own material, there is no official VAT master to edit: the bake duplicates the source material and grafts MF_MassBattleMaterialFunction into that copy (adapter contract: exactly one InAttributes input pin of material-attributes type, and at least one Out output), and the material instance parents the copy — read its decoded outputs instead of unpacking the parameter channels yourself. Sprites take another route: the atlas asset (UMassBattleATADataAsset) points its MasterMaterial at a thin sprite master built by Material.BuildSpriteMaster (Unlit + Masked, attributes-driven, declaring MB_AtlasTexture / MB_AtlasCols / MB_AtlasRows / MB_SpriteMode); when that field is null the bake logs and skips material-instance creation — there is no fallback to any M_VATMaster*. M_VATMaster survives only as the parent of the 37 legacy demo materials under /MassBattle/Demo/Agent/*/Gen_*, and M_VATMaster_CS was deleted on 2026-11-14 (nothing referenced it at that point); neither is a starting point for new materials.

常见入口文件与消费点 Common Entry Files & Consumers

下表列出最常见的入口文件及其消费资产,并非全部包含文件;其余文件不在此逐一展开。

The table below lists the most common entry files and their consumer assets — not every include; the rest are not expanded here.

File运行位置Runs in消费资产Consumer assets负责什么What it covers
MassBattle_AgentMeshPrediction.ush Niagara Custom HLSLNiagara Custom HLSL NS_AgentRenderer_Template(NM_UpdateAgentMeshDataFromArray_GPU) agent 网格的位置/旋转/缩放预测与动画帧推进,让逻辑帧之间的画面保持平滑。Position / rotation / scale prediction and animation-frame advance for agent meshes, keeping the picture smooth between logic ticks.
MassBattle_FxPrediction.ush Niagara Custom HLSLNiagara Custom HLSL NS_FxRendererTemplate(NM_UpdateAttachedFxParams_GPU) 附着特效跟随其父单位:父级平滑移动时,特效钉在插槽上不漂移。Attached FX follow their parent unit — FX stay glued to their sockets while the parent moves smoothly.
MassBattle_HealthBarPrediction.ush Niagara Custom HLSLNiagara Custom HLSL NM_UpdateHealthBarFromArray · NM_UpdateAgentHealthBarFromArray 血条位置与血量比例的插值,掉血时比例平滑过渡。Health-bar position and ratio interpolation, so the bar eases when health drops.
MassBattle_MaterialDecode.ush 材质 Custom 节点Material Custom node MF_MassBattleMaterialFunction(烘焙嫁接进源材质副本的适配器)(the adapter grafted into the source-material copy)· M_VATMaster(旧演示材质)(legacy demo materials)· ML_VATMatLayer 把渲染参数通道解码为材质可读的浮点输出(受击发光/冰冻/燃烧/中毒、队伍色、溶解、LOD、选中态)。Decodes the render parameter channels into material-readable float outputs (hit glow / freeze / burn / poison, team color, dissolve, LOD, selection).
MassBattle_TextPopDecode.ush 材质 Custom 节点Material Custom node M_TextPopUp 伤害跳字的数字图集渲染:K/M/B/T 后缀、正负号、暴击标记与最多 3 位小数。Damage text-pop atlas rendering: K/M/B/T suffixes, signs, crit marks and up to 3 decimals.