diff --git a/Runtime/ShaderBake/ShaderBakeCameraSettings.cs b/Runtime/ShaderBake/ShaderBakeCameraSettings.cs
index dd7faf0..188ca44 100644
--- a/Runtime/ShaderBake/ShaderBakeCameraSettings.cs
+++ b/Runtime/ShaderBake/ShaderBakeCameraSettings.cs
@@ -101,6 +101,19 @@ namespace XericUI.ShaderBake
farClipPlane = distanceFromCamera + radius * 3f;
}
+ ///
+ /// 收拢数值。负数在这组参数里没有任何含义,但数字框拦不住一个负号,而它造成的后果是
+ /// "渲染成功、画面全空":半高为负时投影矩阵被钳成一条线,什么都框不住,还不报任何错。
+ /// 取绝对值而不是就地归零,是因为负号多半是手滑,量级本身是用户想要的。
+ ///
+ public void Clamp()
+ {
+ orthographicSize = Mathf.Max(Mathf.Abs(orthographicSize), 0.0001f);
+ fieldOfView = Mathf.Clamp(Mathf.Abs(fieldOfView), 1f, 179f);
+ nearClipPlane = Mathf.Max(Mathf.Abs(nearClipPlane), 0.0001f);
+ farClipPlane = Mathf.Max(Mathf.Abs(farClipPlane), nearClipPlane + 0.0001f);
+ }
+
/// 摄像机指纹:变了不需要重建网格,只需要重画
public string GetCameraSignature()
{
diff --git a/Runtime/ShaderBake/ShaderBakeSettings.cs b/Runtime/ShaderBake/ShaderBakeSettings.cs
index 738c1bb..4209214 100644
--- a/Runtime/ShaderBake/ShaderBakeSettings.cs
+++ b/Runtime/ShaderBake/ShaderBakeSettings.cs
@@ -37,6 +37,7 @@ namespace XericUI.ShaderBake
{
output.Clamp();
surface.Clamp();
+ camera.Clamp();
}
/// 复制一份(编辑器窗口拿它当工作副本,改坏了不至于污染存下来的那份)