public void SetOutputSizeEnumTest() { Substance.Game.Substance subs = SubstanceExtensionsTestData.Instance.TestSubstance; SubstanceGraph graph = subs.graphs[0]; int cachedSize = graph.GetInputVector2Int(SubstanceGraphExtensions.OutputSizeParameter)[0]; SubstanceOutputSize newSize = cachedSize == 9 ? SubstanceOutputSize._1024 : SubstanceOutputSize._512; Debug.Log(graph.GetGeneratedTextures()[0].width); graph.SetOutputSize(newSize); //NativeFunctions.cppProcessOutputQueue(); graph.QueueForRender(); Substance.Game.Substance.RenderSubstancesSync(); int width = graph.GetGeneratedTextures()[0].width; Debug.Log(graph.GetGeneratedTextures()[0].width); Assert.AreEqual(width, (newSize == SubstanceOutputSize._1024 ? 1024 : 512)); graph.SetOutputSize(cachedSize); //NativeFunctions.cppProcessOutputQueue(); graph.QueueForRender(); Substance.Game.Substance.RenderSubstancesSync(); }
public void SetOutputSizeTest() { Substance.Game.Substance subs = SubstanceExtensionsTestData.Instance.TestSubstance; SubstanceGraph graph = subs.graphs[0]; int cachedSize = graph.GetInputVector2Int(SubstanceGraphExtensions.OutputSizeParameter)[0]; int newSize = cachedSize == 9 ? 10 : 9; graph.SetOutputSize(newSize); graph.QueueForRender(); Substance.Game.Substance.RenderSubstancesSync(); int width = graph.GetGeneratedTextures()[0].width; Debug.Log(string.Format("{0} | {1} | {2} - {3}", width, (newSize == 10 ? 1024 : 512), cachedSize, newSize)); Assert.AreEqual(width, (newSize == 10 ? 1024 : 512)); graph.SetOutputSize(cachedSize); graph.QueueForRender(); Substance.Game.Substance.RenderSubstancesSync(); }
/// <summary> /// Returns the output size of a graph, in proper pixel width and height. ie (1024, 1024) /// </summary> /// <param name="graph">The graph to get the output size of.</param> public static Vector2Int GetOutputSize(this SubstanceGraph graph) { int[] ints = graph.GetInputVector2Int(OutputSizeParameter); int x = 1024; int y = 1024; switch (ints[0]) { case 5: x = 32; break; case 6: x = 64; break; case 7: x = 128; break; case 8: x = 256; break; case 9: x = 512; break; case 10: x = 1024; break; case 11: x = 2046; break; case 12: x = 4096; break; } switch (ints[1]) { case 5: y = 32; break; case 6: y = 64; break; case 7: y = 128; break; case 8: y = 256; break; case 9: y = 512; break; case 10: y = 1024; break; case 11: y = 2046; break; case 12: y = 4096; break; } return(new Vector2Int(x, y)); }
/// <summary> /// Returns the output size of a graph, in internal substance int values. ie (10, 10) /// </summary> /// <param name="graph">The graph to get the output size of.</param> public static Vector2Int GetOutputSizeInt(this SubstanceGraph graph) { int[] ints = graph.GetInputVector2Int(OutputSizeParameter); return(new Vector2Int(ints[0], ints[1])); }