var rndrTexture : Texture;
var r : RenderToTexture;
var mat : Material;
function Start()
{
r = GameObject.Find("Main Camera").GetComponent(RenderToTexture); //коннект к скрипту на основной камере
rndrTexture = r.tex; //текстура на которую идет рендер
}
function OnPostRender()
{
if (!mat)
{
mat = new Material("Shader \"Texture Simple\" {" +
" Properties { " +
" _MainTex (\"Base (RGB)\", 2D) = \"white\" " +
" } " +
" SubShader { " +
" Pass { " +
" SetTexture [_MainTex] " +
"}" +
"}" +
"}"
);
}
mat.SetTexture("_MainTex", rndrTexture);
//прямоугольник с текстурными координами
GL.PushMatrix();
mat.SetPass(0);
GL.Color(Color(1,1,1,1));
GL.LoadOrtho();
GL.Begin(GL.QUADS);
GL.TexCoord(Vector3(0,0,0));
GL.Vertex3(0,0,0);
GL.TexCoord(Vector3(0,1,0));
GL.Vertex3(0,1,0);
GL.TexCoord(Vector3(1,1,0));
GL.Vertex3(1,1,0);
GL.TexCoord(Vector3(1,0,0));
GL.Vertex3(1,0,0);
GL.End();
GL.PopMatrix();
}