Exemplo n.º 1
0
    void Start()
    {
        var graph = MixtureDatabase.GetGraphFromTexture(graphTexture);

        graph.SetParameterValue("Source", source);
        graph.SetParameterValue("Target", target);

        // make sure compression is not enabled for the readback
        graph.outputNode.mainOutput.enableCompression = false;

        // Create the destination texture
        var       settings    = graph.outputNode.settings;
        Texture2D destination = new Texture2D(
            settings.GetResolvedWidth(graph),
            settings.GetResolvedHeight(graph),
            settings.GetGraphicsFormat(graph),
            TextureCreationFlags.None
            );

        // Process the graph
        MixtureGraphProcessor processor = new MixtureGraphProcessor(graph);

        processor.Run();

        // Readback the result
        graph.ReadbackMainTexture(destination);

        // TODO: debug
        // image.texture = debugRT;

        // Write the file at the target destination
        var bytes = ImageConversion.EncodeToPNG(destination);

        File.WriteAllBytes(outputPath, bytes);
    }
Exemplo n.º 2
0
    void Start()
    {
        var graph = MixtureDatabase.GetGraphFromTexture(graphTexture);

        var variant = ScriptableObject.CreateInstance <MixtureVariant>();

        variant.SetParent(graph);

        variant.SetParameterValue("Source", source);
        variant.SetParameterValue("Target", target);

        variant.ProcessGraphWithOverrides();

        // Create the destination texture
        var       settings    = graph.outputNode.settings;
        Texture2D destination = new Texture2D(
            settings.GetResolvedWidth(graph),
            settings.GetResolvedHeight(graph),
            settings.GetGraphicsFormat(graph),
            TextureCreationFlags.None
            );

        // Readback the result
        graph.ReadbackMainTexture(destination);

        // Write the file at the target destination
        var bytes = ImageConversion.EncodeToPNG(destination);

        File.WriteAllBytes(outputPath, bytes);
    }