Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma strict
- #pragma implicit
- #pragma downcast
- // When attached to a camera, will clear alpha channel
- // of camera's render texture to pure white.
- // Useful if you have camera rendering into a texture and later
- // want to display it in GUI.
- private var mat : Material;
- // customised map image variables to use within the GUI
- var mapRT : RenderTexture;
- var alpha : Texture2D;
- function Awake() {
- if (!mat) {
- mat = new Material (
- "Shader \"\" {" +
- " Properties {" +
- " _MainTex (\"Base (RGB) Trans (A)\", 2D) = \"white\" {}" +
- " _RadarMask (\"Mix Mask (A)\", 2D) = \"gray\" {}" +
- " }" +
- " SubShader {" +
- " Lighting On " +
- " Cull Off " +
- " ZTest Always " +
- " ZWrite Off " +
- " Fog { Mode Off } " +
- " Pass {" +
- " SetTexture [_MainTex] { combine texture }" +
- " SetTexture [_RadarMask] { combine previous - texture }" +
- " }" +
- " }" +
- "}"
- );
- }
- // make sure this material isn't saved or displayed in the editor
- mat.shader.hideFlags = HideFlags.HideAndDontSave;
- mat.hideFlags = HideFlags.HideAndDontSave;
- }
- function OnPostRender () {
- GL.PushMatrix ();
- GL.LoadOrtho ();
- for (var i = 0; i < mat.passCount; ++i) {
- mat.SetTexture ("_MainTex", mapRT);
- mat.SetTexture ("_RadarMask", alpha);
- mat.SetPass (i);
- GL.Begin (GL.QUADS);
- GL.Vertex3 (0, 0, 0.1);
- GL.Vertex3 (1, 0, 0.1);
- GL.Vertex3 (1, 1, 0.1);
- GL.Vertex3 (0, 1, 0.1);
- GL.End ();
- }
- GL.PopMatrix ();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement