更新0.6.0

This commit is contained in:
2026-06-26 12:30:54 +08:00
parent f8edda498e
commit d56d4731a4
19 changed files with 1208 additions and 39 deletions
+34
View File
@@ -4,6 +4,37 @@
## [0.6.0] 2026-06-26
添加:
* 添加了一个从屏幕上摄取模型材质的功能。
* xericLogger添加了常规的日志方法,不用每次都写cc。
* 添加了判断当前帧是否第一次调用的方法。
* 添加了摄像机视锥方相关方法。
* 多维布尔添加了更多的运算符。
* 添加趋势预测器。
* 添加卡尔曼滤波。
* 全局生命周期调度器 XericLifeCycleCore,支持 Update/LateUpdate/FixedUpdate/Coroutine 四阶段调度,按发布者管理任务。
* XericLifeCycleCore 协程阶段:基于卡尔曼滤波的帧预算控制,自动 Yield 跨帧续接。
* XLifeCycleProfile Editor 窗口:发布者分组折叠区 + 任务甘特图 + Profiler API 监视。
* PID 动画控制器 GetPIDAnimaterV3/V2/Float/Color,基于调度器实现平滑过渡。
* PIDController 对象池,减少 GC。
* IPIDEqualityComparer 接口及四种默认实现,支持自定义到达目标判断。
* 数学库添加了最大最小公约数公倍数的计算。
* 添加了语义化版本号和语义化定时器
* 整合了协程库
* 添加了样式表用法
* 添加了unity上预处理命令管理器
修复:
* SingleMonoBase.EditorInstance 重写:移除 Obsolete,父节点+子节点统一 HideAndDontSave,编辑器内不再因 GlobalInstance 报错。
* XericLifeCycleCore.GlobalInstance:编辑器模式自动走 EditorInstance(场景世界),不再走 DontDestroyOnLoad。
* 修复 PID 控制器导数公式(除以 Δt² 改为 Δt),解决无穷大溢出问题。
* 删除 PID 中无效的 NaN 安全检查(只能拦截 NaN,无法拦截 Infinity)。
优化:
* 优化按键宏逻辑,添加了按键趋势统计。
## [0.5.7] 2026-05-27 ## [0.5.7] 2026-05-27
添加: 添加:
@@ -17,12 +48,15 @@
* 添加使用windows文件窗口的窗口调用函数(包含文件和目录访问)。 * 添加使用windows文件窗口的窗口调用函数(包含文件和目录访问)。
* 配置宏添加了获取方法。 * 配置宏添加了获取方法。
* json序列化器添加了部分基础类型的null处理方案。 * json序列化器添加了部分基础类型的null处理方案。
* 添加了一种通过整数获取excel列文本函数
优化: 优化:
* TextBlockBuilder文本拼接逻辑,减少GC。 * TextBlockBuilder文本拼接逻辑,减少GC。
* 优化枚举库中的对比方法,改为了泛型模型,避免枚举装箱操作 * 优化枚举库中的对比方法,改为了泛型模型,避免枚举装箱操作
修复: 修复:
* 对象池宏中联合对象池间接释放对象有可能报错导致无法释放的问题。 * 对象池宏中联合对象池间接释放对象有可能报错导致无法释放的问题。
装配岛部分的插件功能已经同步更新。
## [0.5.6] 2025-12-30 ## [0.5.6] 2025-12-30
增加数据集合可复用对象池组件,优化列表池中部分方法的性能。 增加数据集合可复用对象池组件,优化列表池中部分方法的性能。
Binary file not shown.
+97 -38
View File
@@ -1,62 +1,121 @@
<h1 align="center">Xeric Library</h1> <h1 align="center">Xeric Library</h1>
<a href="https://xeric.zicp.fun/LiRuochen_WorkFlow/XericLibrary-Publish">个人发布页面(最新)</a> <a href="https://xeric.zicp.fun/LiRuochen_WorkFlow/XericLibrary-Publish">个人发布页面(最新)</a> 
<a href="https://gitee.com/none_9_0/xeric-library2">Gitee发布页面</a> <a href="https://gitee.com/none_9_0/xeric-library2">Gitee发布页面</a> 
<a href="https://github.com/2128cz/XericLibrary">Github库</a> <a href="https://github.com/2128cz/XericLibrary">Github库</a>
更多内容请翻阅[百科](https://xeric.zicp.fun/LiRuochen_WorkFlow/XericLibrary-Publish/wiki) 更多内容请翻阅[百科](https://xeric.zicp.fun/LiRuochen_WorkFlow/XericLibrary-Publish/wiki)
---
| 版本 | SRP | URP | HDRP | ## 兼容性
| 版本 | SRP | URP | HDRP |
| --- | --- | --- | --- | | --- | --- | --- | --- |
| 2021.3.2f1 | ✔️ | ✔️ | ✔️ | | 2021.3.2f1 | ✔️ | ✔️ | ✔️ |
| 2022.1.24f1 | ✔️ | ✔️ | ✔️ | | 2022.1.24f1 | ✔️ | ✔️ | ✔️ |
| 6000.0.24f1 | ✔️ | ✔️ | ✔️ | | 6000.0.24f1 | ✔️ | ✔️ | ✔️ |
* 插件更名历史 > 插件更名历史:Xeric Library → Aetherial Deconstructionism Paradigm (XericLibrary)
> Xeric Library
> Aetherial Deconstructionism Paradigm (XericLibrary)
>
---- ---
欢迎使用Xeric Library, 这是一个专注代码的扩展库 ## 概述
* 专注Unity成员语法, 扩展多种基本类型的数据结构的Linq语法/语法糖, 提供: 函数平滑、 多项式计算、 权重拟合、 过程分级、 工业控制、 曲线绘制、 路径设置、 对象控制、 迭代扩展、 空间变换、 独特结构、 文本格式、 类型转换、 机器编码、 开发调试、 动态生成、 几何创建、 快速池化、 导航寻路、 隔离控制、 隔离输入、 语义化委托、 反射超驰、 数学常数、 单位换算、 排序算法、 程序调用、 网络连接、 windows窗口控制等快捷用法。 Xeric Library 是一个专注代码的 Unity 扩展库。
* 扩展特殊类型, 包括且不限于: 多维布尔、 样条曲线、 超级单例、 多例系统、 邻居网络、 四叉树、 字典树、 软引用封装器等。 **基础扩展**:针对 Unity 成员语法,扩展多种基本类型的 Linq 语法及语法糖,提供函数平滑、多项式计算、权重拟合、过程分级、工业控制、曲线绘制、路径设置、对象控制、迭代扩展、空间变换、独特结构、文本格式、类型转换、机器编码、开发调试、动态生成、几何创建、快速池化、导航寻路、隔离控制、隔离输入、语义化委托、反射超驰、数学常数、单位换算、排序算法、程序调用、网络连接、Windows 窗口控制等快捷用法。
* 扩展各种常用脚本: 游戏交互、 界面适配、 弱扩展、 绘制工厂、 SQL扩展。 **特殊类型**:多维布尔、样条曲线、超级单例、多例系统、邻居网络、四叉树、八叉树、字典树、大顶堆、双生哈希表、比特图、软引用封装器、卡尔曼滤波器等。
* 兼容不规范程序: 针对不规范或毫无设计规则可言的代码, 提供了更多基于反射, CIL特性等底层语法的程序扩展, 以便快速实现目的: **常用脚本**:游戏交互、界面适配、弱扩展、绘制工厂、SQL 扩展。
1. 脚本没有继承单例? "超级单例"不需要声名, 也不需要修改任何原来的脚本内容, 径直调用就是单例。
2. 数据结构字段冗余重复? "软接口" (SoftInterface) 支持快速执行反射获取和设置,方法委托,字段属性一行调用。
3. untiy对象要遵循生命周期池化太麻烦? "联合对象池" (MacroPool.UnionSet) 直接将设定项目开放到inspector上配置,代码中只需要get和release就可以!
4. 程序UI框架和逻辑框架高度耦合无从下手? 有点麻烦, 不过菜单特性, 查找特性, 命名标记特性可以帮助你无视内容查找字段属性方法类型等内容, 直接将类传入就能程序化生成菜单界面。
5. 驱动ui的数据量太大? 提供多种基于UI框架的数据结构虚拟化技术, 使用虚拟化拆分数据可以每次刷新的压力。 使用此功能需要安装XericUIActionVessel插件, 代码以脚本呈现,直接浏览,编写时遵循精细的工厂权能划分!
6. 喜欢函数式变成和便捷的语法糖? 插件提供多种工具类: 枚举可以使用`MacroEnum`分类和`MacroEnum<T>`扩展; 数学, 向量, 几何, 数据结构扩展, 常见算法, 常用字符计算已经全部内嵌`MacroMath`分类;
7. 需要使用高级数据结构? 大顶堆, 四叉树, 八叉树, 字典树, 时间戳, 多段线, 贝塞尔, 多维布尔(比特矢量), 比特图, 双生哈希表, 相邻网格等内容可以直接使用。
8. 想要立刻能够在场景中移动角色? 第一人称, 第三人称, 上帝视角已经准备就绪!
9. 厌烦复杂的按键检查逻辑? 按键宏 (MacroKey) 提供状态表处理更多按键, 可以识别短按, 长按, 双击, 连击, 拖拽, 以及它们的按下和释放状态! 且可以选择以时间, 坐标等共计4种模式触发, 支持新输入系统, 满足绝大部分场景的细分需求。
10. 需要隐藏日志调用栈信息? XericLogger 可以减少日志输出内容。
11. 需要更多调试信息? 提供可以和虚幻原生媲美的Gizmos调试显示功能。
11. 担心兼容性吗? 程序主要基于2022版本开发, 向下兼容2021, 向上支持6000, 不涉及渲染管线API, 有针对webgl版本的单独构建版本, 且经过项目实战验证。
更多编辑器功能参考: **兼容不规范程序**:针对无设计规则的代码,提供基于反射、CIL 特性等底层语法的程序扩展:
* 安装Xeric Blueprint Graph以获取Unity上蓝图节点功能, 并支持Xeric函数库功能。 - **超级单例**:无需声明继承,径直调用即为单例。
* 安装Xeric UI Graph以获取蓝图化UI生成功能, 使用蓝图逻辑控制UI交互, 生成逻辑, 并支持Xeric函数库功能。 - **软接口 (SoftInterface)**:快速反射获取/设置,方法委托与字段属性一行调用。
* 安装Digital Twin Tool以获取常用调试工具集。 - **联合对象池 (MacroPool.UnionSet)**:Inspector 面板直接配置,代码中只需 Get 和 Release。
* 安装Nexus Frame Flow以获取工作架构流处理功能。 - **菜单/查找/命名标记特性**:无视内容查找字段属性方法,类传入即可程序化生成菜单界面。
* 安装Xeric Editor辅助引擎大纲美化组件、 资源垃圾处理组件、 资源缓存组件、 快速截图功能, 以及更多快捷键功能 - **按键宏 (MacroKey)**:状态表处理多按键,识别短按、长按、双击、连击、拖拽及其按下释放状态,支持新输入系统。
- **XericLogger**:精简日志调用栈信息。
- **Gizmos 调试**:媲美原生调试显示功能。
需要使用编译标记启用的功能: 建议添加 Odin 插件,便于呈现更多界面功能。
* XericLibrary: 通用的启用特殊功能。
当前插件提供编辑器功能: Deepseek AI对话。 ---
需要注意: 插件内如果涉及多平台切换, 可能会提供多种自动或手动的切换方案, 或默认使用windows平台, 请注意辨别。 ## 样式表 (XSSS)
建议添加ODin插件, 便于呈现更多界面功能。 自研 Xeric Super Style Sheet (XSSS) 系统,使用 `.xsss` 自定义文本格式,类 CSS/USS 语法,专为 Unity 组件样式设计。基于字典树进行样式路径查找与匹配,支持命名空间隔离、动态监听热重载。提供完整的编辑器导入、Inspector 编辑及 PropertyDrawer 支持。
更多详细内容说明请翻阅README文档。 ---
如果发现任何问题, 包括版本兼容性, 计算错误, 调用错误, 使用问题, 都可以通过发布页Issues或其他联系方式找我获得帮助。
## 扩展库结构
核心运行时位于 `Developer/XericLibrary/`,主要模块:
| 模块 | 说明 |
| --- | --- |
| `MacroLibrary/` | 核心工具集,含 ~60 个分类宏文件,覆盖数学、几何、天文、排序、编码等 |
| `Type/` | 特殊数据类型:四叉树/八叉树、字典树、多维布尔、软引用、卡尔曼滤波器等 |
| `AI/Chat/` | DeepSeek AI 聊天接口封装 |
| `PlayerController/` | 第一/三人称及上帝视角控制器 |
| `SuperStyleSheet/` | XSSS 样式表运行时 |
| `Debugger/` | Gizmos 调试绘制 |
| `Nav/` | A* 寻路 |
| `Net/` | LAN 局域网通信 |
| `Generation/` | 程序化生成(楼梯、平面开孔等) |
| `Security/` | 程序流安全控制 |
| `CollisionLOD/` | 碰撞体 LOD 系统 |
| `XericComponent/` | 组件系统(样条曲线、网格布局、生命周期核心) |
| `RegistrationActivation/` | 注册激活码校验 |
| `MachineID/` | 机器码验证授权 |
---
## 编辑器界面
- **太阳系模拟界面**:注册激活窗口内嵌的日心说太阳系动画,在编辑器上也能看到漂亮的天体(地球、月球、大气等)。
- **预编译宏管理**:`XericLibrary/Define Symbols/预设宏管理` 菜单入口,勾选框式增删编译标记。
- **DeepSeek AI 对话**:编辑器内 AI 聊天窗口。
- **生命周期性能分析**:`XLifeCycleProfile` 窗口,分析组件生命周期耗时。
- **Hierarchy 面板定制**:增强的 Hierarchy 显示。
- **颜色渐变编辑器**:线性颜色渐变编辑窗口。
- **2D 纹理数组工具**:批量管理纹理数组。
---
## 示例文件
- **Roslyn 检查器**:位于 `Release/Samples~/XericUnityAnalyzer/`,包含编译后的分析器 DLL 及安装说明。提供组件搜索、命名规范、对象关系、富文本检测等代码分析规则,源码见 `Developer/XericUnityAnalyzer/`。
- **配置界面 UI**:`Release/Samples~/ConfigUIElement/`,自动化配置界面的预制体与脚本示例。
- **轨迹线路**:`Release/Samples~/HorizonLineOrbit/`,平面线路绘制与导航示例。
---
## 依赖此插件的扩展
| 插件 | 说明 |
| --- | --- |
| XericUIActionVessel | UI 动作容器插件,提供 UI 界面、UIToolkit 扩展及高性能表格实现 |
| XericCICD | Unity CI/CD 工作流配置界面及 Git 界面 |
| XericWebRequest | Unity WebRequest 封装,提供请求时间轴检查器及 AI 对话示例 |
| DigitalTwinTool | Unity 数字孪生常用功能集合 |
| Xeric_Editor | Unity 编辑器美化和功能集合扩展 |
| ScreenDetectionLayerPicker | 高性能屏幕空间模型数据组提取,支持 WebGL |
| XericMeshTool | 可视化蓝图连线处理模型及模型生成 |
| MaterialLibrary | Shader 库及后处理库,包含 BIRP、URP、HDRP |
---
## 编译标记
使用编译标记启用的特殊功能:
- `XericLibrary`:通用启用特殊功能。
---
## 注意事项
- 插件涉及多平台切换时,可能提供多种自动或手动切换方案,或默认使用 Windows 平台,请注意辨别。
- 如发现版本兼容性、计算错误、调用错误、使用问题,可通过发布页 Issues 或其他联系方式获得帮助。
@@ -0,0 +1,162 @@
// Made with Amplify Shader Editor v1.9.9.1
// Available at the Unity Asset Store - http://u3d.as/y3X
Shader "XUIDotBasic"
{
Properties
{
[PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
_Color ("Tint", Color) = (1,1,1,1)
_StencilComp ("Stencil Comparison", Float) = 8
_Stencil ("Stencil ID", Float) = 0
_StencilOp ("Stencil Operation", Float) = 0
_StencilWriteMask ("Stencil Write Mask", Float) = 255
_StencilReadMask ("Stencil Read Mask", Float) = 255
_ColorMask ("Color Mask", Float) = 15
[Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip ("Use Alpha Clip", Float) = 0
}
SubShader
{
LOD 0
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "PreviewType"="Plane" "CanUseSpriteAtlas"="True" }
Stencil
{
Ref [_Stencil]
ReadMask [_StencilReadMask]
WriteMask [_StencilWriteMask]
Comp [_StencilComp]
Pass [_StencilOp]
}
Cull Off
Lighting Off
ZWrite Off
ZTest [unity_GUIZTestMode]
Blend One OneMinusSrcAlpha
ColorMask [_ColorMask]
Pass
{
Name "Default"
CGPROGRAM
#define ASE_VERSION 19901
#pragma vertex vert
#pragma fragment frag
#pragma target 3.5
#include "UnityCG.cginc"
#include "UnityUI.cginc"
#pragma multi_compile_local _ UNITY_UI_CLIP_RECT
#pragma multi_compile_local _ UNITY_UI_ALPHACLIP
struct appdata_t
{
float4 vertex : POSITION;
float4 color : COLOR;
float2 texcoord : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 vertex : SV_POSITION;
fixed4 color : COLOR;
float2 texcoord : TEXCOORD0;
float4 worldPosition : TEXCOORD1;
float4 mask : TEXCOORD2;
UNITY_VERTEX_OUTPUT_STEREO
};
sampler2D _MainTex;
fixed4 _Color;
fixed4 _TextureSampleAdd;
float4 _ClipRect;
float4 _MainTex_ST;
float _UIMaskSoftnessX;
float _UIMaskSoftnessY;
v2f vert(appdata_t v )
{
v2f OUT;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(OUT);
v.vertex.xyz += float3( 0, 0, 0 ) ;
float4 vPosition = UnityObjectToClipPos(v.vertex);
OUT.worldPosition = v.vertex;
OUT.vertex = vPosition;
float2 pixelSize = vPosition.w;
pixelSize /= float2(1, 1) * abs(mul((float2x2)UNITY_MATRIX_P, _ScreenParams.xy));
float4 clampedRect = clamp(_ClipRect, -2e10, 2e10);
float2 maskUV = (v.vertex.xy - clampedRect.xy) / (clampedRect.zw - clampedRect.xy);
OUT.texcoord = v.texcoord;
OUT.mask = float4(v.vertex.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * half2(_UIMaskSoftnessX, _UIMaskSoftnessY) + abs(pixelSize.xy)));
OUT.color = v.color * _Color;
return OUT;
}
fixed4 frag(v2f IN ) : SV_Target
{
//Round up the alpha color coming from the interpolator (to 1.0/256.0 steps)
//The incoming alpha could have numerical instability, which makes it very sensible to
//HDR color transparency blend, when it blends with the world's texture.
const half alphaPrecision = half(0xff);
const half invAlphaPrecision = half(1.0/alphaPrecision);
IN.color.a = round(IN.color.a * alphaPrecision)*invAlphaPrecision;
float4 appendResult2 = (float4(0.0 , 0.0 , 0.0 , 1.0));
half4 color = appendResult2;
#ifdef UNITY_UI_CLIP_RECT
half2 m = saturate((_ClipRect.zw - _ClipRect.xy - abs(IN.mask.xy)) * IN.mask.zw);
color.a *= m.x * m.y;
#endif
#ifdef UNITY_UI_ALPHACLIP
clip (color.a - 0.001);
#endif
color.rgb *= color.a;
return color;
}
ENDCG
}
}
CustomEditor "AmplifyShaderEditor.MaterialInspector"
Fallback Off
}
/*ASEBEGIN
Version=19901
Node;AmplifyShaderEditor.DynamicAppendNode, AmplifyShaderEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null;2;-256,0;Inherit;False;FLOAT4;4;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;0;False;3;FLOAT;1;False;1;FLOAT4;0
Node;AmplifyShaderEditor.TextureCoordinatesNode, AmplifyShaderEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null;3;-1024,-128;Inherit;False;0;-1;2;3;2;SAMPLER2D;;False;0;FLOAT2;1,1;False;1;FLOAT2;0,0;False;5;FLOAT2;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
Node;AmplifyShaderEditor.TemplateMultiPassMasterNode, AmplifyShaderEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null;0;0,0;Float;False;True;-1;3;AmplifyShaderEditor.MaterialInspector;0;3;XUIDotBasic;5056123faa0c79b47ab6ad7e8bf059a4;True;Default;0;0;Default;2;False;True;3;1;False;;10;False;;0;1;False;;0;False;;False;False;False;False;False;False;False;False;False;False;False;False;True;2;False;;False;True;True;True;True;True;0;True;_ColorMask;False;False;False;False;False;False;False;True;True;0;True;_Stencil;255;True;_StencilReadMask;255;True;_StencilWriteMask;0;True;_StencilComp;0;True;_StencilOp;0;False;;0;False;;0;False;;0;False;;0;False;;0;False;;False;True;2;False;;True;0;True;unity_GUIZTestMode;False;True;5;Queue=Transparent=Queue=0;IgnoreProjector=True;RenderType=Transparent=RenderType;PreviewType=Plane;CanUseSpriteAtlas=True;False;False;0;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;3;False;0;;0;0;Standard;0;0;1;True;False;;False;0
WireConnection;0;0;2;0
ASEEND*/
//CHKSM=2D7C452CAA9F9AC9B28539E122A9F5072E3B0DC3
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 858173d3f3725a1468cac9f50da734a4
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
preprocessorOverride: 0
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,292 @@
// Made with Amplify Shader Editor v1.9.9.1
// Available at the Unity Asset Store - http://u3d.as/y3X
Shader "XUIBasic"
{
Properties
{
[PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
_Color ("Tint", Color) = (1,1,1,1)
_StencilComp ("Stencil Comparison", Float) = 8
_Stencil ("Stencil ID", Float) = 0
_StencilOp ("Stencil Operation", Float) = 0
_StencilWriteMask ("Stencil Write Mask", Float) = 255
_StencilReadMask ("Stencil Read Mask", Float) = 255
_ColorMask ("Color Mask", Float) = 15
[Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip ("Use Alpha Clip", Float) = 0
_CoordTransform( "CoordTransform", Vector ) = ( 1, 1, 0, 0 )
_CoordCenterv2( "CoordCenter(v2)", Vector ) = ( 0.5, 0.5, 0, 0 )
_CoordRotateAngle( "CoordRotateAngle", Float ) = 0
[KeywordEnum( Gradient,Polygon )] _ElementType( "Element Type", Float ) = 0
[KeywordEnum( Linear,Sin,Cos,Exponential )] _GradientType( "GradientType", Float ) = 0
_ExpNumber( "ExpNumber", Float ) = 1
_ColorA( "Color A", Color ) = ( 0, 1, 0.07612991, 1 )
_ColorB( "Color B", Color ) = ( 1, 0, 0, 1 )
_PolygonSides( "PolygonSides", Float ) = 5
_PolygonSizev2( "PolygonSize(v2)", Vector ) = ( 0.5, 0.5, 0, 0 )
[KeywordEnum( Normal,Mode,ABS )] _CoordRange( "CoordRange", Float ) = 0
}
SubShader
{
LOD 0
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "PreviewType"="Plane" "CanUseSpriteAtlas"="True" }
Stencil
{
Ref [_Stencil]
ReadMask [_StencilReadMask]
WriteMask [_StencilWriteMask]
Comp [_StencilComp]
Pass [_StencilOp]
}
Cull Off
Lighting Off
ZWrite Off
ZTest [unity_GUIZTestMode]
Blend One OneMinusSrcAlpha
ColorMask [_ColorMask]
Pass
{
Name "Default"
CGPROGRAM
#define ASE_VERSION 19901
#pragma vertex vert
#pragma fragment frag
#pragma target 3.5
#include "UnityCG.cginc"
#include "UnityUI.cginc"
#pragma multi_compile_local _ UNITY_UI_CLIP_RECT
#pragma multi_compile_local _ UNITY_UI_ALPHACLIP
#define ASE_NEEDS_TEXTURE_COORDINATES0
#define ASE_NEEDS_FRAG_TEXTURE_COORDINATES0
#pragma shader_feature_local _ELEMENTTYPE_GRADIENT _ELEMENTTYPE_POLYGON
#pragma shader_feature_local _GRADIENTTYPE_LINEAR _GRADIENTTYPE_SIN _GRADIENTTYPE_COS _GRADIENTTYPE_EXPONENTIAL
#pragma shader_feature_local _COORDRANGE_NORMAL _COORDRANGE_MODE _COORDRANGE_ABS
struct appdata_t
{
float4 vertex : POSITION;
float4 color : COLOR;
float2 texcoord : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 vertex : SV_POSITION;
fixed4 color : COLOR;
float2 texcoord : TEXCOORD0;
float4 worldPosition : TEXCOORD1;
float4 mask : TEXCOORD2;
UNITY_VERTEX_OUTPUT_STEREO
};
sampler2D _MainTex;
fixed4 _Color;
fixed4 _TextureSampleAdd;
float4 _ClipRect;
float4 _MainTex_ST;
float _UIMaskSoftnessX;
float _UIMaskSoftnessY;
uniform float4 _ColorA;
uniform float4 _ColorB;
uniform float4 _CoordTransform;
uniform float2 _CoordCenterv2;
uniform float _CoordRotateAngle;
uniform float _ExpNumber;
uniform float2 _PolygonSizev2;
uniform float _PolygonSides;
v2f vert(appdata_t v )
{
v2f OUT;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(OUT);
v.vertex.xyz += float3( 0, 0, 0 ) ;
float4 vPosition = UnityObjectToClipPos(v.vertex);
OUT.worldPosition = v.vertex;
OUT.vertex = vPosition;
float2 pixelSize = vPosition.w;
pixelSize /= float2(1, 1) * abs(mul((float2x2)UNITY_MATRIX_P, _ScreenParams.xy));
float4 clampedRect = clamp(_ClipRect, -2e10, 2e10);
float2 maskUV = (v.vertex.xy - clampedRect.xy) / (clampedRect.zw - clampedRect.xy);
OUT.texcoord = v.texcoord;
OUT.mask = float4(v.vertex.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * half2(_UIMaskSoftnessX, _UIMaskSoftnessY) + abs(pixelSize.xy)));
OUT.color = v.color * _Color;
return OUT;
}
fixed4 frag(v2f IN ) : SV_Target
{
//Round up the alpha color coming from the interpolator (to 1.0/256.0 steps)
//The incoming alpha could have numerical instability, which makes it very sensible to
//HDR color transparency blend, when it blends with the world's texture.
const half alphaPrecision = half(0xff);
const half invAlphaPrecision = half(1.0/alphaPrecision);
IN.color.a = round(IN.color.a * alphaPrecision)*invAlphaPrecision;
float2 texCoord1 = IN.texcoord.xy * (_CoordTransform).xy + (_CoordTransform).zw;
float cos2 = cos( ( ( _CoordRotateAngle * 2.0 ) * UNITY_PI ) );
float sin2 = sin( ( ( _CoordRotateAngle * 2.0 ) * UNITY_PI ) );
float2 rotator2 = mul( texCoord1 - _CoordCenterv2 , float2x2( cos2 , -sin2 , sin2 , cos2 )) + _CoordCenterv2;
float2 temp_output_2_0_g3 = rotator2;
float2 temp_output_3_0_g3 = float2( 1,1 );
float2 temp_output_1_0_g3 = ( temp_output_2_0_g3 % temp_output_3_0_g3 );
float2 temp_output_6_0_g3 = saturate( sign( temp_output_2_0_g3 ) );
float2 lerpResult4_g3 = lerp( ( ( temp_output_1_0_g3 + temp_output_3_0_g3 ) % temp_output_3_0_g3 ) , temp_output_1_0_g3 , temp_output_6_0_g3);
#if defined( _COORDRANGE_NORMAL )
float2 staticSwitch26 = rotator2;
#elif defined( _COORDRANGE_MODE )
float2 staticSwitch26 = lerpResult4_g3;
#elif defined( _COORDRANGE_ABS )
float2 staticSwitch26 = abs( rotator2 );
#else
float2 staticSwitch26 = rotator2;
#endif
float temp_output_18_0 = (staticSwitch26).x;
#if defined( _GRADIENTTYPE_LINEAR )
float staticSwitch13 = temp_output_18_0;
#elif defined( _GRADIENTTYPE_SIN )
float staticSwitch13 = sin( temp_output_18_0 );
#elif defined( _GRADIENTTYPE_COS )
float staticSwitch13 = cos( temp_output_18_0 );
#elif defined( _GRADIENTTYPE_EXPONENTIAL )
float staticSwitch13 = pow( temp_output_18_0 , _ExpNumber );
#else
float staticSwitch13 = temp_output_18_0;
#endif
float temp_output_2_0_g4 = _PolygonSides;
float cosSides12_g4 = cos( ( UNITY_PI / temp_output_2_0_g4 ) );
float2 appendResult18_g4 = (float2(( _PolygonSizev2.x * cosSides12_g4 ) , ( _PolygonSizev2.y * cosSides12_g4 )));
float2 break23_g4 = ( (staticSwitch26*2.0 + -1.0) / appendResult18_g4 );
float polarCoords30_g4 = atan2( break23_g4.x , -break23_g4.y );
float temp_output_52_0_g4 = ( 6.28318548202515 / temp_output_2_0_g4 );
float2 appendResult25_g4 = (float2(break23_g4.x , -break23_g4.y));
float2 finalUVs29_g4 = appendResult25_g4;
float temp_output_44_0_g4 = ( cos( ( ( floor( ( 0.5 + ( polarCoords30_g4 / temp_output_52_0_g4 ) ) ) * temp_output_52_0_g4 ) - polarCoords30_g4 ) ) * length( finalUVs29_g4 ) );
#if defined( _ELEMENTTYPE_GRADIENT )
float staticSwitch11 = staticSwitch13;
#elif defined( _ELEMENTTYPE_POLYGON )
float staticSwitch11 = saturate( ( ( 1.0 - temp_output_44_0_g4 ) / fwidth( temp_output_44_0_g4 ) ) );
#else
float staticSwitch11 = staticSwitch13;
#endif
float4 lerpResult14 = lerp( _ColorA , _ColorB , staticSwitch11);
float4 appendResult7 = (float4(lerpResult14));
half4 color = appendResult7;
#ifdef UNITY_UI_CLIP_RECT
half2 m = saturate((_ClipRect.zw - _ClipRect.xy - abs(IN.mask.xy)) * IN.mask.zw);
color.a *= m.x * m.y;
#endif
#ifdef UNITY_UI_ALPHACLIP
clip (color.a - 0.001);
#endif
color.rgb *= color.a;
return color;
}
ENDCG
}
}
CustomEditor "AmplifyShaderEditor.MaterialInspector"
Fallback Off
}
/*ASEBEGIN
Version=19901
Node;AmplifyShaderEditor.RangedFloatNode, AmplifyShaderEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null;5;-1408,256;Inherit;False;Property;_CoordRotateAngle;CoordRotateAngle;2;0;Create;True;0;0;0;False;0;False;0;0;0;0;0;1;FLOAT;0
Node;AmplifyShaderEditor.Vector4Node, AmplifyShaderEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null;28;-1920,0;Inherit;False;Property;_CoordTransform;CoordTransform;0;0;Create;True;0;0;0;False;0;False;1,1,0,0;1,1,0,0;0;5;FLOAT4;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
Node;AmplifyShaderEditor.SimpleMultiplyOpNode, AmplifyShaderEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null;9;-1184,256;Inherit;False;2;2;0;FLOAT;0;False;1;FLOAT;2;False;1;FLOAT;0
Node;AmplifyShaderEditor.ComponentMaskNode, AmplifyShaderEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null;30;-1664,96;Inherit;False;False;False;True;True;1;0;FLOAT4;0,0,0,0;False;1;FLOAT2;0
Node;AmplifyShaderEditor.ComponentMaskNode, AmplifyShaderEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null;29;-1664,16;Inherit;False;True;True;False;False;1;0;FLOAT4;0,0,0,0;False;1;FLOAT2;0
Node;AmplifyShaderEditor.TextureCoordinatesNode, AmplifyShaderEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null;1;-1408,0;Inherit;False;0;-1;2;3;2;SAMPLER2D;;False;0;FLOAT2;1,1;False;1;FLOAT2;0,0;False;5;FLOAT2;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
Node;AmplifyShaderEditor.PiNode, AmplifyShaderEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null;8;-1024,256;Inherit;False;1;0;FLOAT;1;False;1;FLOAT;0
Node;AmplifyShaderEditor.Vector2Node, AmplifyShaderEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null;4;-1408,128;Inherit;False;Property;_CoordCenterv2;CoordCenter(v2);1;0;Create;True;0;0;0;False;0;False;0.5,0.5;0.5,0.5;0;3;FLOAT2;0;FLOAT;1;FLOAT;2
Node;AmplifyShaderEditor.Vector2Node, AmplifyShaderEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null;34;-768,-128;Inherit;False;Constant;_Vector0;Vector 0;11;0;Create;True;0;0;0;False;0;False;1,1;0,0;0;3;FLOAT2;0;FLOAT;1;FLOAT;2
Node;AmplifyShaderEditor.RotatorNode, AmplifyShaderEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null;2;-896,0;Inherit;False;3;0;FLOAT2;0,0;False;1;FLOAT2;0,0;False;2;FLOAT;1;False;1;FLOAT2;0
Node;AmplifyShaderEditor.FunctionNode, AmplifyShaderEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null;32;-512,0;Inherit;False;PMod;-1;;3;f21979a9080cb044ca372458f5a37d88;1,33,0;2;2;FLOAT2;0,0;False;3;FLOAT2;1,1;False;1;FLOAT2;0
Node;AmplifyShaderEditor.AbsOpNode, AmplifyShaderEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null;36;-480,128;Inherit;False;1;0;FLOAT2;0,0;False;1;FLOAT2;0
Node;AmplifyShaderEditor.StaticSwitch, AmplifyShaderEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null;26;-256,-128;Inherit;False;Property;_CoordRange;CoordRange;10;0;Create;True;0;0;0;False;0;False;0;0;0;True;;KeywordEnum;3;Normal;Mode;ABS;Create;True;True;All;9;1;FLOAT2;0,0;False;0;FLOAT2;0,0;False;2;FLOAT2;0,0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT2;0,0;False;6;FLOAT2;0,0;False;7;FLOAT2;0,0;False;8;FLOAT2;0,0;False;1;FLOAT2;0
Node;AmplifyShaderEditor.ComponentMaskNode, AmplifyShaderEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null;18;0,-128;Inherit;False;True;False;True;True;1;0;FLOAT2;0,0;False;1;FLOAT;0
Node;AmplifyShaderEditor.RangedFloatNode, AmplifyShaderEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null;23;0,96;Inherit;False;Property;_ExpNumber;ExpNumber;5;0;Create;True;0;0;0;False;0;False;1;0;0;0;0;1;FLOAT;0
Node;AmplifyShaderEditor.SinOpNode, AmplifyShaderEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null;19;256,-64;Inherit;False;1;0;FLOAT;0;False;1;FLOAT;0
Node;AmplifyShaderEditor.CosOpNode, AmplifyShaderEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null;20;256,0;Inherit;False;1;0;FLOAT;0;False;1;FLOAT;0
Node;AmplifyShaderEditor.PowerNode, AmplifyShaderEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null;22;256,64;Inherit;False;False;2;0;FLOAT;0;False;1;FLOAT;1;False;1;FLOAT;0
Node;AmplifyShaderEditor.Vector2Node, AmplifyShaderEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null;25;0,384;Inherit;False;Property;_PolygonSizev2;PolygonSize(v2);9;0;Create;True;0;0;0;False;0;False;0.5,0.5;0,0;0;3;FLOAT2;0;FLOAT;1;FLOAT;2
Node;AmplifyShaderEditor.RangedFloatNode, AmplifyShaderEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null;24;0,288;Inherit;False;Property;_PolygonSides;PolygonSides;8;0;Create;True;0;0;0;False;0;False;5;0;0;0;0;1;FLOAT;0
Node;AmplifyShaderEditor.FunctionNode, AmplifyShaderEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null;10;256,256;Inherit;False;Polygon;-1;;4;6906ef7087298c94c853d6753e182169;0;4;1;FLOAT2;0,0;False;2;FLOAT;5;False;3;FLOAT;0.5;False;4;FLOAT;0.5;False;1;FLOAT;0
Node;AmplifyShaderEditor.StaticSwitch, AmplifyShaderEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null;13;512,-128;Inherit;False;Property;_GradientType;GradientType;4;0;Create;True;0;0;0;False;0;False;0;0;0;True;;KeywordEnum;4;Linear;Sin;Cos;Exponential;Create;True;True;All;9;1;FLOAT;0;False;0;FLOAT;0;False;2;FLOAT;0;False;3;FLOAT;0;False;4;FLOAT;0;False;5;FLOAT;0;False;6;FLOAT;0;False;7;FLOAT;0;False;8;FLOAT;0;False;1;FLOAT;0
Node;AmplifyShaderEditor.StaticSwitch, AmplifyShaderEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null;11;896,-128;Inherit;False;Property;_ElementType;Element Type;3;0;Create;True;0;0;0;False;0;False;0;0;0;True;;KeywordEnum;2;Gradient;Polygon;Create;True;True;All;9;1;FLOAT;0;False;0;FLOAT;0;False;2;FLOAT;0;False;3;FLOAT;0;False;4;FLOAT;0;False;5;FLOAT;0;False;6;FLOAT;0;False;7;FLOAT;0;False;8;FLOAT;0;False;1;FLOAT;0
Node;AmplifyShaderEditor.ColorNode, AmplifyShaderEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null;15;896,-512;Inherit;False;Property;_ColorA;Color A;6;0;Create;True;0;0;0;False;0;False;0,1,0.07612991,1;0,1,0.07612991,1;True;True;0;6;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4;FLOAT3;5
Node;AmplifyShaderEditor.ColorNode, AmplifyShaderEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null;16;896,-320;Inherit;False;Property;_ColorB;Color B;7;0;Create;True;0;0;0;False;0;False;1,0,0,1;1,0,0,1;True;True;0;6;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4;FLOAT3;5
Node;AmplifyShaderEditor.LerpOp, AmplifyShaderEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null;14;1152,-384;Inherit;False;3;0;COLOR;0,0,0,0;False;1;COLOR;0,0,0,0;False;2;FLOAT;0;False;1;COLOR;0
Node;AmplifyShaderEditor.DynamicAppendNode, AmplifyShaderEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null;7;1312,-384;Inherit;False;FLOAT4;4;0;FLOAT4;0,0,0,0;False;1;FLOAT;0;False;2;FLOAT;0;False;3;FLOAT;1;False;1;FLOAT4;0
Node;AmplifyShaderEditor.TemplateMultiPassMasterNode, AmplifyShaderEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null;0;1472,-384;Float;False;True;-1;3;AmplifyShaderEditor.MaterialInspector;0;3;XUIBasic;5056123faa0c79b47ab6ad7e8bf059a4;True;Default;0;0;Default;2;False;True;3;1;False;;10;False;;0;1;False;;0;False;;False;False;False;False;False;False;False;False;False;False;False;False;True;2;False;;False;True;True;True;True;True;0;True;_ColorMask;False;False;False;False;False;False;False;True;True;0;True;_Stencil;255;True;_StencilReadMask;255;True;_StencilWriteMask;0;True;_StencilComp;0;True;_StencilOp;0;False;;0;False;;0;False;;0;False;;0;False;;0;False;;False;True;2;False;;True;0;True;unity_GUIZTestMode;False;True;5;Queue=Transparent=Queue=0;IgnoreProjector=True;RenderType=Transparent=RenderType;PreviewType=Plane;CanUseSpriteAtlas=True;False;False;0;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;3;False;0;;0;0;Standard;0;0;1;True;False;;False;0
WireConnection;9;0;5;0
WireConnection;30;0;28;0
WireConnection;29;0;28;0
WireConnection;1;0;29;0
WireConnection;1;1;30;0
WireConnection;8;0;9;0
WireConnection;2;0;1;0
WireConnection;2;1;4;0
WireConnection;2;2;8;0
WireConnection;32;2;2;0
WireConnection;32;3;34;0
WireConnection;36;0;2;0
WireConnection;26;1;2;0
WireConnection;26;0;32;0
WireConnection;26;2;36;0
WireConnection;18;0;26;0
WireConnection;19;0;18;0
WireConnection;20;0;18;0
WireConnection;22;0;18;0
WireConnection;22;1;23;0
WireConnection;10;1;26;0
WireConnection;10;2;24;0
WireConnection;10;3;25;1
WireConnection;10;4;25;2
WireConnection;13;1;18;0
WireConnection;13;0;19;0
WireConnection;13;2;20;0
WireConnection;13;3;22;0
WireConnection;11;1;13;0
WireConnection;11;0;10;0
WireConnection;14;0;15;0
WireConnection;14;1;16;0
WireConnection;14;2;11;0
WireConnection;7;0;14;0
WireConnection;0;0;7;0
ASEEND*/
//CHKSM=EF1BCF878CBE9DBF87503B5564BA985D4602AE12
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 1b840b32ff140044cbe24edf0fea80a5
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,38 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 8
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Xuib_BitLineBottom
m_Shader: {fileID: 4800000, guid: 858173d3f3725a1468cac9f50da734a4, type: 3}
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- _ColorMask: 15
- _Stencil: 0
- _StencilComp: 8
- _StencilOp: 0
- _StencilReadMask: 255
- _StencilWriteMask: 255
- _UseUIAlphaClip: 0
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
m_BuildTextureStacks: []
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 7bb9dc87ba416eb40949ddd7fda23ffc
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 5a1e2547bd9a1a747a58aa500f689d02
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+328
View File
@@ -0,0 +1,328 @@
#if ENABLE_BURST
using Unity.Burst;
#endif
using System.Runtime.CompilerServices;
namespace XericLibrary.Runtime.MacroLibrary
{
/// <summary>
/// 空间填充曲线映射——提供 Z 字曲线(Morton Code) 与 Hilbert 曲线的 2D/3D 坐标与 1D 索引的映射工具
/// 所有方法支持 Burst 编译,可用于 Unity 多线程环境
/// </summary>
#if ENABLE_BURST
[BurstCompile]
#endif
public static class MacroCurveMapping
{
#region Z 字曲线 (Morton Code)
/// <summary>
/// 将 2D 块坐标交织为 1D Z 索引 (Morton Code)
/// </summary>
/// <param name="blockX">X 坐标 (非负)</param>
/// <param name="blockY">Y 坐标 (非负)</param>
/// <returns>64 位 Z 索引</returns>
#if ENABLE_BURST
[BurstCompile]
#endif
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ulong ZOrderEncode(int blockX, int blockY)
{
ulong x = (uint)blockX;
ulong y = (uint)blockY;
x = (x | (x << 16)) & 0x0000FFFF0000FFFF;
x = (x | (x << 8)) & 0x00FF00FF00FF00FF;
x = (x | (x << 4)) & 0x0F0F0F0F0F0F0F0F;
x = (x | (x << 2)) & 0x3333333333333333;
x = (x | (x << 1)) & 0x5555555555555555;
y = (y | (y << 16)) & 0x0000FFFF0000FFFF;
y = (y | (y << 8)) & 0x00FF00FF00FF00FF;
y = (y | (y << 4)) & 0x0F0F0F0F0F0F0F0F;
y = (y | (y << 2)) & 0x3333333333333333;
y = (y | (y << 1)) & 0x5555555555555555;
return x | (y << 1);
}
/// <summary>
/// 将 1D Z 索引解码还原为 2D 块坐标
/// </summary>
/// <param name="z">Z 索引</param>
/// <param name="blockX">解码后的 X 坐标</param>
/// <param name="blockY">解码后的 Y 坐标</param>
#if ENABLE_BURST
[BurstCompile]
#endif
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void ZOrderDecode(ulong z, out int blockX, out int blockY)
{
ulong x = z & 0x5555555555555555;
ulong y = (z >> 1) & 0x5555555555555555;
x = (x ^ (x >> 1)) & 0x3333333333333333;
x = (x ^ (x >> 2)) & 0x0F0F0F0F0F0F0F0F;
x = (x ^ (x >> 4)) & 0x00FF00FF00FF00FF;
x = (x ^ (x >> 8)) & 0x0000FFFF0000FFFF;
x = (x ^ (x >> 16)) & 0x00000000FFFFFFFF;
y = (y ^ (y >> 1)) & 0x3333333333333333;
y = (y ^ (y >> 2)) & 0x0F0F0F0F0F0F0F0F;
y = (y ^ (y >> 4)) & 0x00FF00FF00FF00FF;
y = (y ^ (y >> 8)) & 0x0000FFFF0000FFFF;
y = (y ^ (y >> 16)) & 0x00000000FFFFFFFF;
blockX = (int)x;
blockY = (int)y;
}
/// <summary>
/// 将 3D 块坐标编码为 1D Z 索引 (Morton Code)
/// </summary>
/// <param name="x">X 坐标 (非负, 最多 21 bit)</param>
/// <param name="y">Y 坐标 (非负, 最多 21 bit)</param>
/// <param name="z">Z 坐标 (非负, 最多 21 bit)</param>
/// <returns>64 位 Z 索引</returns>
#if ENABLE_BURST
[BurstCompile]
#endif
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ulong ZOrderEncode3D(int x, int y, int z)
{
return SplitBy3((uint)x) | (SplitBy3((uint)y) << 1) | (SplitBy3((uint)z) << 2);
}
/// <summary>
/// 将 1D Z 索引解码还原为 3D 坐标
/// </summary>
#if ENABLE_BURST
[BurstCompile]
#endif
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void ZOrderDecode3D(ulong code, out int x, out int y, out int z)
{
x = (int)CompactBy3((uint)(code));
y = (int)CompactBy3((uint)(code >> 1));
z = (int)CompactBy3((uint)(code >> 2));
}
/// <summary>
/// 将 21-bit 整数按位分散到 63-bit 空间 (每 3 位留 1 位)
/// </summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static ulong SplitBy3(uint a)
{
ulong x = (ulong)a & 0x1fffffUL; // 仅保留低 21 位
x = (x | (x << 32)) & 0x1f00000000ffffUL;
x = (x | (x << 16)) & 0x1f0000ff0000ffUL;
x = (x | (x << 8)) & 0x100f00f00f00f00fUL;
x = (x | (x << 4)) & 0x10c30c30c30c30c3UL;
x = (x | (x << 2)) & 0x1249249249249249UL;
return x;
}
/// <summary>
/// CompactBy3: 反向提取分散的位,还原为原始 21-bit 整数
/// </summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static uint CompactBy3(uint a)
{
ulong x = (ulong)a & 0x1249249249249249UL;
x = (x ^ (x >> 2)) & 0x10c30c30c30c30c3UL;
x = (x ^ (x >> 4)) & 0x100f00f00f00f00fUL;
x = (x ^ (x >> 8)) & 0x1f0000ff0000ffUL;
x = (x ^ (x >> 16)) & 0x1f00000000ffffUL;
x = (x ^ (x >> 32)) & 0x1fffffUL;
return (uint)x;
}
#endregion
#region Hilbert 曲线 (2D)
// 2D Hilbert 状态转移表: encodeTable[state][rx*2+ry] = (quadrant << 2) | nextState
private static readonly byte[] Hilbert2DEncodeTable = new byte[16]
{
0x00, 0x01, 0x0E, 0x0B, // state 0: (0,0)→0/0, (0,1)→1/0, (1,0)→3/3, (1,1)→2/3
0x08, 0x05, 0x06, 0x03, // state 1: (0,0)→2/1, (0,1)→1/1, (1,0)→1/2, (1,1)→0/3
0x08, 0x0D, 0x04, 0x01, // state 2: (0,0)→2/2, (0,1)→3/2, (1,0)→1/1, (1,1)→0/0
0x00, 0x0D, 0x07, 0x0A, // state 3: (0,0)→0/3, (0,1)→3/0, (1,0)→3/3, (1,1)→2/2
};
// 2D Hilbert 解码用: decodeTable[state][quadrant] = (rx << 1 | ry << 0) | (nextState << 2)
private static readonly byte[] Hilbert2DDecodeTable = new byte[16]
{
0x00, 0x01, 0x0B, 0x06, // state 0: 0→(0,0)/0, 1→(0,1)/0, 2→(1,1)/2, 3→(1,0)/3
0x08, 0x05, 0x03, 0x06, // state 1: 0→(1,1)/2, 1→(0,1)/1, 2→(0,0)/0, 3→(1,0)/3
0x0A, 0x07, 0x01, 0x04, // state 2: 0→(1,1)/2, 1→(1,0)/3, 2→(0,0)/0, 3→(0,1)/1
0x00, 0x0D, 0x0B, 0x06, // state 3: 0→(0,0)/0, 1→(1,0)/3, 2→(1,1)/2, 3→(0,1)/1
};
/// <summary>
/// 将 2D 坐标编码为 Hilbert 曲线索引
/// </summary>
/// <param name="x">X 坐标 (非负)</param>
/// <param name="y">Y 坐标 (非负)</param>
/// <param name="order">曲线阶数 (1~16), 决定网格大小为 2^order</param>
/// <returns>Hilbert 索引</returns>
#if ENABLE_BURST
[BurstCompile]
#endif
public static ulong Hilbert2DEncode(int x, int y, int order)
{
ulong index = 0;
int state = 0;
for (int s = order - 1; s >= 0; s--)
{
int rx = (x >> s) & 1;
int ry = (y >> s) & 1;
int key = (state << 2) | (rx << 1) | ry;
byte entry = Hilbert2DEncodeTable[key];
int quadrant = entry & 3;
state = entry >> 2;
index = (index << 2) | (uint)quadrant;
}
return index;
}
/// <summary>
/// 将 Hilbert 索引解码为 2D 坐标
/// </summary>
/// <param name="index">Hilbert 索引</param>
/// <param name="order">曲线阶数</param>
/// <param name="x">解码后的 X 坐标</param>
/// <param name="y">解码后的 Y 坐标</param>
#if ENABLE_BURST
[BurstCompile]
#endif
public static void Hilbert2DDecode(ulong index, int order, out int x, out int y)
{
x = 0;
y = 0;
int state = 0;
for (int s = 0; s < order; s++)
{
int quadrant = (int)((index >> ((order - 1 - s) * 2)) & 3);
int key = (state << 2) | quadrant;
byte entry = Hilbert2DDecodeTable[key];
int rx = (entry >> 1) & 1;
int ry = entry & 1;
state = entry >> 2;
x = (x << 1) | rx;
y = (y << 1) | ry;
}
}
#endregion
#region Hilbert 曲线 (3D)
// 3D Hilbert 编码状态转移表: encode3DTable[state][rx*4+ry*2+rz] = (octant << 3) | nextState
// state 索引原始坐标位(rx,ry,rz), 返回:高4位为octant,低3位为nextState
private static readonly byte[] Hilbert3DEncodeTable = new byte[64]
{
// state 0
0x00, 0x01, 0x13, 0x12, 0x3F, 0x36, 0x24, 0x2D,
// state 1
0x09, 0x08, 0x1B, 0x1A, 0x37, 0x3E, 0x2C, 0x25,
// state 2
0x1B, 0x1A, 0x08, 0x09, 0x2C, 0x25, 0x37, 0x3E,
// state 3
0x12, 0x13, 0x01, 0x00, 0x24, 0x2D, 0x3F, 0x36,
// state 4
0x2B, 0x32, 0x38, 0x31, 0x04, 0x05, 0x17, 0x16,
// state 5
0x3A, 0x33, 0x21, 0x28, 0x0C, 0x0D, 0x1F, 0x1E,
// state 6
0x20, 0x29, 0x3A, 0x33, 0x15, 0x1C, 0x0C, 0x05,
// state 7
0x29, 0x20, 0x33, 0x3A, 0x1D, 0x14, 0x04, 0x0D,
};
// 3D Hilbert 解码状态转移表: decode3DTable[state][octant] = (rx<<2|ry<<1|rz) | (nextState << 3)
private static readonly byte[] Hilbert3DDecodeTable = new byte[64]
{
// state 0
0x00, 0x01, 0x1B, 0x13, 0x36, 0x37, 0x25, 0x2C,
// state 1
0x09, 0x10, 0x1A, 0x03, 0x3E, 0x2F, 0x24, 0x35,
// state 2
0x1B, 0x02, 0x08, 0x11, 0x25, 0x3C, 0x3F, 0x26,
// state 3
0x12, 0x0B, 0x01, 0x18, 0x2D, 0x2C, 0x36, 0x27,
// state 4
0x2B, 0x2A, 0x39, 0x30, 0x04, 0x0D, 0x1F, 0x16,
// state 5
0x32, 0x23, 0x38, 0x21, 0x0C, 0x15, 0x1E, 0x07,
// state 6
0x38, 0x29, 0x2A, 0x23, 0x1D, 0x04, 0x0D, 0x16,
// state 7
0x21, 0x30, 0x23, 0x2A, 0x15, 0x0C, 0x0D, 0x0E,
};
/// <summary>
/// 将 3D 坐标编码为 Hilbert 曲线索引
/// </summary>
/// <param name="x">X 坐标 (非负)</param>
/// <param name="y">Y 坐标 (非负)</param>
/// <param name="z">Z 坐标 (非负)</param>
/// <param name="order">曲线阶数 (1~10), 决定网格大小为 2^order</param>
/// <returns>Hilbert 索引</returns>
#if ENABLE_BURST
[BurstCompile]
#endif
public static ulong Hilbert3DEncode(int x, int y, int z, int order)
{
ulong index = 0;
int state = 0;
for (int s = order - 1; s >= 0; s--)
{
int rx = (x >> s) & 1;
int ry = (y >> s) & 1;
int rz = (z >> s) & 1;
int key = (state << 3) | (rx << 2) | (ry << 1) | rz;
byte entry = Hilbert3DEncodeTable[key];
int octant = entry >> 3;
state = entry & 7;
index = (index << 3) | (uint)octant;
}
return index;
}
/// <summary>
/// 将 Hilbert 索引解码为 3D 坐标
/// </summary>
/// <param name="index">Hilbert 索引</param>
/// <param name="order">曲线阶数</param>
/// <param name="x">解码后的 X 坐标</param>
/// <param name="y">解码后的 Y 坐标</param>
/// <param name="z">解码后的 Z 坐标</param>
#if ENABLE_BURST
[BurstCompile]
#endif
public static void Hilbert3DDecode(ulong index, int order, out int x, out int y, out int z)
{
x = 0;
y = 0;
z = 0;
int state = 0;
for (int s = 0; s < order; s++)
{
int octant = (int)((index >> ((order - 1 - s) * 3)) & 7);
int key = (state << 3) | octant;
byte entry = Hilbert3DDecodeTable[key];
int rx = (entry >> 2) & 1;
int ry = (entry >> 1) & 1;
int rz = entry & 1;
state = entry >> 3;
x = (x << 1) | rx;
y = (y << 1) | ry;
z = (z << 1) | rz;
}
}
#endregion
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a486924113c5f02419766eb21331cdb0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Binary file not shown.
@@ -0,0 +1,70 @@
fileFormatVersion: 2
guid: 7395568d54979b54fa983a6c08051d48
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 0
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Editor: 0
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude WebGL: 1
Exclude Win: 1
Exclude Win64: 1
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 1
settings:
CPU: AnyCPU
DefaultValueInitialized: true
OS: AnyOS
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: None
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,70 @@
fileFormatVersion: 2
guid: 2e4d66a8654c88e4c8feb3fb149e861a
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 0
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Editor: 0
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude WebGL: 1
Exclude Win: 1
Exclude Win64: 1
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 1
settings:
CPU: AnyCPU
DefaultValueInitialized: true
OS: AnyOS
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: None
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,70 @@
fileFormatVersion: 2
guid: 1e8ac916e7f928d4f8f2ac8e286cfc31
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 0
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Editor: 0
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude WebGL: 1
Exclude Win: 1
Exclude Win64: 1
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 1
settings:
CPU: AnyCPU
DefaultValueInitialized: true
OS: AnyOS
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: None
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
+1 -1
View File
File diff suppressed because one or more lines are too long