private void ComputeTessellationOptions(SVGParser.SceneInfo sceneInfo, int targetResolution, float multiplier, out float stepDist, out float maxCord, out float maxTangent) { // These tessellation options were found by trial and error to find values that made // visual sense with a variety of SVG assets. // "Pixels per Unit" doesn't make sense for UI Toolkit since it will be displayed in // a pixels space. We adjust the magic values below accordingly. #if UNITY_2019_3_OR_NEWER float ppu = (SvgType == SVGType.UIToolkit) ? 1.0f : SvgPixelsPerUnit; #else float ppu = SvgPixelsPerUnit; #endif var bbox = VectorUtils.ApproximateSceneNodeBounds(sceneInfo.Scene.Root); float maxDim = Mathf.Max(bbox.width, bbox.height) / ppu; // The scene ratio gives a rough estimate of coverage % of the vector scene on the screen. // Higher values should result in a more dense tessellation. float sceneRatio = maxDim / (targetResolution * multiplier); stepDist = float.MaxValue; // No need for uniform step distance #if UNITY_2019_3_OR_NEWER if (SvgType == SVGType.UIToolkit) { maxCord = Mathf.Max(0.01f, 2.0f * sceneRatio); maxTangent = Mathf.Max(0.1f, 3.0f * sceneRatio); } else #endif { maxCord = Mathf.Max(0.01f, 75.0f * sceneRatio); maxTangent = Mathf.Max(0.1f, 100.0f * sceneRatio); } }
private void ComputeTessellationOptions(SVGParser.SceneInfo sceneInfo, int targetResolution, float multiplier, out float stepDist, out float maxCord, out float maxTangent) { var bbox = VectorUtils.ApproximateSceneNodeBounds(sceneInfo.Scene.Root); float maxDim = Mathf.Max(bbox.width, bbox.height) / SvgPixelsPerUnit; // The scene ratio gives a rough estimate of coverage % of the vector scene on the screen. // Higher values should result in a more dense tessellation. float sceneRatio = maxDim / (targetResolution * multiplier); stepDist = float.MaxValue; // No need for uniform step distance maxCord = Mathf.Max(0.01f, 75.0f * sceneRatio); maxTangent = Mathf.Max(0.1f, 100.0f * sceneRatio); }