Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. #pragma strict
  2. #pragma implicit
  3. #pragma downcast
  4.  
  5. // When attached to a camera, will clear alpha channel
  6. // of camera's render texture to pure white.
  7. // Useful if you have camera rendering into a texture and later
  8. // want to display it in GUI.
  9. private var mat : Material;
  10.  
  11. // customised map image variables to use within the GUI
  12. var mapRT : RenderTexture;
  13. var alpha : Texture2D;
  14.  
  15. function Awake() {
  16.  
  17. if (!mat) {
  18. mat = new Material (
  19. "Shader \"\" {" +
  20. " Properties {" +
  21. " _MainTex (\"Base (RGB) Trans (A)\", 2D) = \"white\" {}" +
  22. " _RadarMask (\"Mix Mask (A)\", 2D) = \"gray\" {}" +
  23. " }" +
  24. " SubShader {" +
  25. " Lighting On " +
  26. " Cull Off " +
  27. " ZTest Always " +
  28. " ZWrite Off " +
  29. " Fog { Mode Off } " +
  30. " Pass {" +
  31. " SetTexture [_MainTex] { combine texture }" +
  32. " SetTexture [_RadarMask] { combine previous - texture }" +
  33. " }" +
  34. " }" +
  35. "}"
  36. );
  37. }
  38. // make sure this material isn't saved or displayed in the editor
  39. mat.shader.hideFlags = HideFlags.HideAndDontSave;
  40. mat.hideFlags = HideFlags.HideAndDontSave;
  41. }
  42.  
  43. function OnPostRender () {
  44.  
  45. GL.PushMatrix ();
  46. GL.LoadOrtho ();
  47. for (var i = 0; i < mat.passCount; ++i) {
  48. mat.SetTexture ("_MainTex", mapRT);
  49. mat.SetTexture ("_RadarMask", alpha);
  50. mat.SetPass (i);
  51. GL.Begin (GL.QUADS);
  52. GL.Vertex3 (0, 0, 0.1);
  53. GL.Vertex3 (1, 0, 0.1);
  54. GL.Vertex3 (1, 1, 0.1);
  55. GL.Vertex3 (0, 1, 0.1);
  56. GL.End ();
  57. }
  58. GL.PopMatrix ();
  59.  
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement