/// <summary> /// Generate a normal map. /// </summary> /// <param name="width">Width.</param> /// <param name="height">Height.</param> /// <param name="pixels">Pixel buffer.</param> /// <param name="normalFormat">Normal format.</param> public void GenerateNormalMap(int width, int height, Color[] pixels, DiagramNormalFormat normalFormat) { if (normalFiltering == DiagramTextureNormalFiltering.Sharp) { GenerateSimpleNormalMap(width, height, strength, pixels); } else { GenerateSobelNormalMap(width, height, strength, pixels); } if (normalFormat == DiagramNormalFormat.Automatic) { #if UNITY_EDITOR || !(UNITY_IPHONE || UNITY_ANDROID || UNITY_BLACKBERRY || UNITY_WP8) ConvertNormalToDXT5(pixels); #else ConvertNormalToRGB(pixels); #endif } else if (normalFormat == DiagramNormalFormat.DXT5nm) { ConvertNormalToDXT5(pixels); } else { ConvertNormalToRGB(pixels); } }
/// <summary> /// Posts process filled pixel buffers. Call after Fill or FillRows with the same pixel data. /// </summary> /// <param name="buffers">The buffers.</param> /// <param name="width">Width.</param> /// <param name="height">Height.</param> /// <param name="normalFormat">Normal format.</param> public void PostProcess(Color[][] buffers, int width, int height, DiagramNormalFormat normalFormat) { for (int i = 0; i < outputs.Length; i++) { DiagramOutput o = outputs[i]; if (o.type == DiagramTextureType.NormalMap) { o.GenerateNormalMap(width, height, buffers[i], normalFormat); } } }
/// <summary> /// Posts process filled pixel buffer for the first output. Use the default width and height. /// Call after Fill or FillRows with the same pixel data. /// </summary> /// <param name="buffer">The buffer.</param> /// <param name="normalFormat">Normal format.</param> public void PostProcess(Color[] buffer, DiagramNormalFormat normalFormat) { PostProcess(buffer, 0, width, height, normalFormat); }
/// <summary> /// Posts process filled pixel buffer. Use the default width and height. Call after Fill or FillRows with the same pixel data. /// </summary> /// <param name="buffer">The buffer.</param> /// <param name='outputIndex'>Index of the output to use.</param> /// <param name="normalFormat">Normal format.</param> public void PostProcess(Color[] buffer, int outputIndex, DiagramNormalFormat normalFormat) { PostProcess(buffer, outputIndex, width, height, normalFormat); }
/// <summary> /// Posts process filled pixel buffer. Call after Fill or FillRows with the same pixel data. /// </summary> /// <param name="buffer">The buffer.</param> /// <param name='outputIndex'>Index of the output to use.</param> /// <param name="width">Width.</param> /// <param name="height">Height.</param> /// <param name="normalFormat">Normal format.</param> public void PostProcess(Color[] buffer, int outputIndex, int width, int height, DiagramNormalFormat normalFormat) { if (outputIndex >= outputs.Length) { return; } DiagramOutput o = outputs[outputIndex]; if (o.type == DiagramTextureType.NormalMap) { o.GenerateNormalMap(width, height, buffer, normalFormat); } }