Files
UltimateFishing/Assets/Scripts/Assembly-CSharp/UnityEngine/PostProcessing/GraphicsUtils.cs
2026-02-21 16:45:37 +08:00

112 lines
2.3 KiB
C#

namespace UnityEngine.PostProcessing
{
public static class GraphicsUtils
{
private static Mesh s_Quad;
public static bool isLinearColorSpace
{
get
{
return QualitySettings.activeColorSpace == ColorSpace.Linear;
}
}
public static bool supportsDX11
{
get
{
return SystemInfo.graphicsShaderLevel >= 50 && SystemInfo.supportsComputeShaders;
}
}
public static Mesh quad
{
get
{
if (s_Quad != null)
{
return s_Quad;
}
Vector3[] vertices = new Vector3[4]
{
new Vector3(-1f, -1f, 0f),
new Vector3(1f, 1f, 0f),
new Vector3(1f, -1f, 0f),
new Vector3(-1f, 1f, 0f)
};
Vector2[] uv = new Vector2[4]
{
new Vector2(0f, 0f),
new Vector2(1f, 1f),
new Vector2(1f, 0f),
new Vector2(0f, 1f)
};
int[] triangles = new int[6] { 0, 1, 2, 1, 0, 3 };
Mesh mesh = new Mesh();
mesh.vertices = vertices;
mesh.uv = uv;
mesh.triangles = triangles;
s_Quad = mesh;
s_Quad.RecalculateNormals();
s_Quad.RecalculateBounds();
return s_Quad;
}
}
public static void Blit(Material material, int pass)
{
GL.PushMatrix();
GL.LoadOrtho();
material.SetPass(pass);
GL.Begin(5);
GL.TexCoord2(0f, 0f);
GL.Vertex3(0f, 0f, 0.1f);
GL.TexCoord2(1f, 0f);
GL.Vertex3(1f, 0f, 0.1f);
GL.TexCoord2(0f, 1f);
GL.Vertex3(0f, 1f, 0.1f);
GL.TexCoord2(1f, 1f);
GL.Vertex3(1f, 1f, 0.1f);
GL.End();
GL.PopMatrix();
}
public static void ClearAndBlit(Texture source, RenderTexture destination, Material material, int pass, bool clearColor = true, bool clearDepth = false)
{
RenderTexture active = RenderTexture.active;
RenderTexture.active = destination;
GL.Clear(false, clearColor, Color.clear);
GL.PushMatrix();
GL.LoadOrtho();
material.SetTexture("_MainTex", source);
material.SetPass(pass);
GL.Begin(5);
GL.TexCoord2(0f, 0f);
GL.Vertex3(0f, 0f, 0.1f);
GL.TexCoord2(1f, 0f);
GL.Vertex3(1f, 0f, 0.1f);
GL.TexCoord2(0f, 1f);
GL.Vertex3(0f, 1f, 0.1f);
GL.TexCoord2(1f, 1f);
GL.Vertex3(1f, 1f, 0.1f);
GL.End();
GL.PopMatrix();
RenderTexture.active = active;
}
public static void Destroy(Object obj)
{
if (obj != null)
{
Object.Destroy(obj);
}
}
public static void Dispose()
{
Destroy(s_Quad);
}
}
}