示例#1
0
    private uint current_stage;                                              // The stage wwhich is currently being worked on

    // ----------------------------------------------------------------------------------------------------------------------------------------------------------------
    // START
    // ----------------------------------------------------------------------------------------------------------------------------------------------------------------

    void Start()
    {
        if (ImageToReproduce.width > 1024 || ImageToReproduce.height > 1024)
        {
            Debug.LogError("image provided is bigger than 1024. This probabaly not what you want");
        }

        current_search_domain_visualisation = new RenderTexture(ImageToReproduce.width, ImageToReproduce.height, 0);


        // ____________________________________________________________________________________________________
        // Construct the scale stages
        List <ScaleStage> temp = new List <ScaleStage>();

        for (int i = 0; i < run_settings.stagesSeries.Length; i++)
        {
            for (int j = 0; j < run_settings.stagesSeries[i].numberOfStagesInTheSeries; j++)
            {
                ScaleStage ss = new ScaleStage(run_settings.runGlobalSettings, run_settings.stagesSeries[i]);
                temp.Add(ss);
            }
        }

        stages = temp.ToArray();

        // ____________________________________________________________________________________________________
        // Camera Initialisation
        Camera main_cam = Camera.main;

        if (!main_cam)
        {
            Debug.LogError("Main Camera not found, add a camera to " +
                           "the scene and add the main camera tag to it");
        }

        main_cam.orthographic     = true;                                                                     // Make sure the camera is ortho. Perspecitve camera has a transformation matrix which will screw with everything
        main_cam.aspect           = (float)ImageToReproduce.width / (float)ImageToReproduce.height;
        main_cam.orthographicSize = 1;
        // ____________________________________________________________________________________________________
        // Command Buffer initialization

        compute_shaders.Construct_Computes();                                                                 // This sets up all the book keeping needed forthe shaders across different stages such as finding the kernel handels

        current_background = new RenderTexture(ImageToReproduce.width, ImageToReproduce.height, 0);           // The current background is used to clear the render target of the camera after each drawing. Each stage paints on top of results of the previous stage
        current_background.Create();
        Graphics.Blit(Texture2D.whiteTexture, current_background);


        // ____________________________________________________________________________________________________
        // Stage initialisation

        current_stage = (uint)stages.Length - 1;                                                              // Starting from the last stage and counting down.
        stages[current_stage].initialise_stage(ImageToReproduce,
                                               current_background, compute_shaders, blackAnwWhite, current_stage, this);
    }
示例#2
0
 public ScaleStage(ScaleStage other)                                    // Copy Constructor
 {
     evolution_settings = new Evolution_Settings(other.evolution_settings);
     fitness_settings   = new Fitness_Settings(other.fitness_settings);
     scale_settings     = new Scale_Settings(other.scale_settings);
 }