1. Can be used for texture processing, also can be used for model display processing (such as a piece of preparation or clothing not acquired when the gray display)
On-line comparison chart:
Using system.collections;using system.collections.generic;using Unityengine;public class texturegrey:monobehaviour{ [Serializefield] Uitexture tex = null; Texture2d tex2d = null; Vector3 grey = new Vector3 (0.299f, 0.587f, 0.114f); Gray shader in the gray value, the specific meaning is not too clear now void Start () {tex2d = tex.maintexture as texture2d; } void Update () {if (Input.getkeyup (KEYCODE.A)) {//ashing Vector3 tempV3 = Vector3 . Zero; if (null! = tex2d) {color[] cols = Tex2d.getpixels (); for (int i = 0, IMax = cols. Length; i < IMax; ++i) {Tempv3.set (COLS[I].R, COLS[I].G, cols[i].b); float dot = Vector3.dot (tempV3, grey); Cols[i] = new Color (dot, dot, dot, cols[i].a); } tex2d = new Texture2d (Tex2d.width, Tex2d.height, Textureformat.argb32, false); Tex2d.setpixels (cols); Tex2d.apply (FALSE); Actually transmit the changed pixel data to the video card tex.maintexture = tex2d as Texture; } } }}
Unity uses code to make the gray display of the arts and Sciences simple