40 lines
882 B
C#
40 lines
882 B
C#
using System;
|
|
using UnityEngine;
|
|
|
|
[Serializable]
|
|
public class RenderTextureAlpha : MonoBehaviour
|
|
{
|
|
public float alpha;
|
|
|
|
private Material mat;
|
|
|
|
public RenderTextureAlpha()
|
|
{
|
|
alpha = 1f;
|
|
}
|
|
|
|
public virtual void Start()
|
|
{
|
|
mat = new Material("Shader \"Hidden/Clear Alpha\" {" + "Properties { _Alpha(\"Alpha\", Float)=1.0 } " + "SubShader {" + " Pass {" + " ZTest Always Cull Off ZWrite Off" + " ColorMask A" + " SetTexture [_Dummy] {" + " constantColor(0,0,0,[_Alpha]) combine constant }" + " }" + "}" + "}");
|
|
}
|
|
|
|
public virtual void OnPostRender()
|
|
{
|
|
GL.PushMatrix();
|
|
GL.LoadOrtho();
|
|
mat.SetFloat("_Alpha", alpha);
|
|
mat.SetPass(0);
|
|
GL.Begin(7);
|
|
GL.Vertex3(0f, 0f, 0.1f);
|
|
GL.Vertex3(1f, 0f, 0.1f);
|
|
GL.Vertex3(1f, 1f, 0.1f);
|
|
GL.Vertex3(0f, 1f, 0.1f);
|
|
GL.End();
|
|
GL.PopMatrix();
|
|
}
|
|
|
|
public virtual void Main()
|
|
{
|
|
}
|
|
}
|