feat(ShaderBake): 全局参数注入(光照/环境/自定义全局量)

- 渲染前把勾选的全局量写进 Shader 全局,命令缓冲执行完按相反顺序还原,不污染编辑器状态
- 常用预设:光照方向/颜色、环境光三段、反射探针、_Time
- 从 shader 源文件扫描非材质属性的 uniform 声明,按类型生成可编辑条目
- 侧边栏新增可折叠的"全局参数"区,贴图引用不进 JSON(资产引用无法可靠序列化)
This commit is contained in:
2026-11-05 17:56:17 +08:00
parent a0512ad450
commit f8f4a3cfd0
10 changed files with 612 additions and 0 deletions
+8
View File
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;
@@ -356,6 +357,7 @@ namespace XericUI.ShaderBake
// 不动网格(外部模型的绕序不该被我们改),只在这一刻把剔除方向反过来。
bool previousInvert = GL.invertCulling;
GL.invertCulling = previousInvert != settings.output.flipY;
List<Action> restoreGlobals = settings.globals != null ? settings.globals.Apply() : null;
try
{
Graphics.ExecuteCommandBuffer(m_Buffer);
@@ -363,6 +365,12 @@ namespace XericUI.ShaderBake
finally
{
GL.invertCulling = previousInvert;
// 画完立刻还原:这些是编辑器全局状态,留一次烘焙的值下来会污染别处的渲染
if (restoreGlobals != null)
{
for (int i = restoreGlobals.Count - 1; i >= 0; i--)
restoreGlobals[i]();
}
}
m_Buffer.Clear();
}