void Test_Color_Orientation(Camera camera, GraphicsFormat format, byte[] data, string label, string path) { var colors = ArrayUtilities.Cast <Color32>(data); var length = ArrayUtilities.Count <Color32>(colors); var top = (Color)colors[length - 1]; var bot = (Color)colors[0]; // HDRP has all sorts of effects that alter color significantly, so we compare differently. if (SRPSupport.GetCurrentPipelineRenderingType() == RenderingPipelineType.URP || SRPSupport.GetCurrentPipelineRenderingType() == RenderingPipelineType.HDRP) { var failed = !ColorCloser(top, Color.red, Color.black) || !ColorCloser(bot, Color.black, Color.red); if (failed) { Log.I($"{label} : Failed: Colors top {top.ToString()} bottom {bot.ToString()}"); } var texture = ConvertToRGBATexture(format, data, camera.pixelWidth, camera.pixelHeight); File.WriteAllBytes(CaptureImageEncoder.EnforceFileExtension(failed ? path + "_FAILED" : path, CaptureImageEncoder.ImageFormat.Jpg), texture.EncodeToJPG()); Assert.True(ColorCloser(top, Color.red, Color.black)); Assert.True(ColorCloser(bot, Color.black, Color.red)); } else { var tolerance = 0.01f; var failed = !CompareColors(top, Color.red, tolerance) || !CompareColors(bot, Color.black, tolerance); if (failed) { Log.I($"{label} : Failed: Colors top {top.ToString()} bottom {bot.ToString()}"); } var texture = ConvertToRGBATexture(format, data, camera.pixelWidth, camera.pixelHeight); File.WriteAllBytes(CaptureImageEncoder.EnforceFileExtension(failed ? path + "_FAILED" : path, CaptureImageEncoder.ImageFormat.Jpg), texture.EncodeToJPG()); Assert.True(CompareColors(top, Color.red, tolerance)); Assert.True(CompareColors(bot, Color.black, tolerance)); } }
void Test_Depth_Orientation_ushort(Camera camera, GraphicsFormat format, byte[] data, string label, string path) { var depth = ArrayUtilities.Cast <ushort>(data); var length = ArrayUtilities.Count <ushort>(depth); // Depth is laid out left to right, bottom to top. var top = CalculateAverageDepthForLine(depth, camera.pixelWidth, camera.pixelHeight - 1); var bot = CalculateAverageDepthForLine(depth, camera.pixelWidth, 0); // Top should be closer, and both planes should have depth info. var condition = top < bot && top > 0 && top < ushort.MaxValue && bot > 0 && bot < ushort.MaxValue; var texture = ConvertToRGBATexture(format, data, camera.pixelWidth, camera.pixelHeight); File.WriteAllBytes(CaptureImageEncoder.EnforceFileExtension(condition ? path : path + "_FAILED", CaptureImageEncoder.ImageFormat.Jpg), texture.EncodeToJPG()); Log.I($"{label} : Average depth top({top}) bottom({bot})"); Assert.True(condition); }