Ejemplo n.º 1
0
		public static void DecodeTextureDataToWriter(byte[] data, int width, int height, TextureFormat format,
													PipelineWriter writer)
		{
			if (!format.IsSupported())
				throw new FormatException("Unsupported format: " + format.ToString());
			PipelineReader reader = null;
			switch (format)
			{
				case TextureFormat.DXT1:
					reader = new DXT1Reader(data, format, width, height);
					break;
				case TextureFormat.DXT2:
				case TextureFormat.DXT3:
					reader = new DXT3Reader(data, format, width, height);
					break;
				case TextureFormat.DXT4:
				case TextureFormat.DXT5:
					reader = new DXT5Reader(data, format, width, height);
					break;
				case TextureFormat.BC4:
					reader = new BC4Reader(data, format, width, height);
					break;
				case TextureFormat.BC5:
					reader = new BC5Reader(data, format, width, height);
					break;
				default:
					reader = new DefaultReader(data, format, width, height);
					break;
			}
			reader.Read(writer);
		}
Ejemplo n.º 2
0
 public static Texture2D GetLutStrip(int size)
 {
     if (!m_LutStrips.TryGetValue(size, out Texture2D value))
     {
         int     num   = size * size;
         Color[] array = new Color[num * size];
         float   num2  = 1f / ((float)size - 1f);
         for (int i = 0; i < size; i++)
         {
             int   num3 = i * size;
             float b    = (float)i * num2;
             for (int j = 0; j < size; j++)
             {
                 float g = (float)j * num2;
                 for (int k = 0; k < size; k++)
                 {
                     float r = (float)k * num2;
                     array[j * num + num3 + k] = new Color(r, g, b);
                 }
             }
         }
         TextureFormat format = TextureFormat.RGBAHalf;
         if (!format.IsSupported())
         {
             format = TextureFormat.ARGB32;
         }
         Texture2D texture2D = new Texture2D(size * size, size, format, mipmap: false, linear: true);
         texture2D.name       = "Strip Lut" + size;
         texture2D.hideFlags  = HideFlags.DontSave;
         texture2D.filterMode = FilterMode.Bilinear;
         texture2D.wrapMode   = TextureWrapMode.Clamp;
         texture2D.anisoLevel = 0;
         value = texture2D;
         value.SetPixels(array);
         value.Apply();
         m_LutStrips.Add(size, value);
     }
     return(value);
 }