实现一种在小尺度下快速增量像素孤岛连通分量标记算法,该算法可以高效实现在多个属性混合的情况下在目标区域内得到一个不会与其他所有属性交叉的中性点。

This commit is contained in:
2026-06-08 19:35:00 +08:00
parent 0289b1855f
commit 95677e9536
3 changed files with 135 additions and 7 deletions
+36 -1
View File
@@ -1,3 +1,38 @@
# Unity 屏幕空间后处理阶段检查器-模型数据提取器
依赖 [MaterialFunctionLibrary](https://gitea.xeric.cc/LiRuochen_WorkFlow/MaterialFunctionLibrary) 插件。
依赖 [MaterialFunctionLibrary](https://gitea.xeric.cc/LiRuochen_WorkFlow/MaterialFunctionLibrary) 插件。
插件能力:
1. 快速抓取到一个物体上多个不同材质分类区域在屏幕特定区域内的占比,中心位置坐标等信息
2. 支持webgl平台
## 使用示例
``` csharp
public class GeoLayerPicker : MonoBehaviour
{
public List<MeshFilter> MeshFilters;
public void Start()
{
GeoLayerPickerRenderPassFeature.Instance?.AddGeoMeshes(MeshFilters); // 将模型设置到处理器中
}
public void LateUpdate()
{
var islands = GeoLayerPickerRenderPassFeature.Instance.GetMaterialIslands();
foreach (var island in islands)
{
Debug.Log($"材质: {island.GetMaterialName()} (ID:{island.matID})");
Debug.Log($" 像素数: {island.totalPixelCount}");
Debug.Log($" 中心世界坐标: {island.centerWorldPos}");
Debug.Log($" 中心像素坐标: {island.centerPixelPos}");
}
}
}
```
处理器中已经包含了必要的转换功能,比如 `island.GetCenterRectAnchoredPosition(rectTransform)` 就可以得到ui坐标。