Esempio n. 1
0
        void SetupChapters()
        {
            var size = Constants.DefaultImageSize * m_SelectedScaleOption;

            m_ChaptersOneAndTwo = new ChaptersOneAndTwo(size.x, size.y);
            m_ChapterThree      = new ChapterThree(size.x, size.y);
            m_ChapterFour       = new ChapterFour(size.x, size.y);
            m_ChapterFive       = new ChapterFive(size.x, size.y);
            m_ChapterFiveTwo    = new ChapterFiveTwo(size.x, size.y);
            m_ChapterSix        = new ChapterSix(size.x, size.y);
            m_ChapterSeven      = new ChapterSeven(size.x, size.y);

            // from chapter 8 on, the same implementation is re-used
            m_ChapterEight = new BatchedTracer(ExampleSphereSets.ChapterEight(),
                                               CameraFrame.Default, size.x, size.y);
            m_ChapterNine = new BatchedTracer(ExampleSphereSets.FiveWithDielectric(),
                                              CameraFrame.Default, size.x, size.y);
            m_ChapterTen = new BatchedTracer(ExampleSphereSets.FiveWithDielectric(),
                                             CameraFrame.ChapterTen, size.x, size.y);
            m_ChapterEleven = new BatchedTracer(ExampleSphereSets.FiveWithDielectric(),
                                                CameraFrame.ChapterEleven, size.x, size.y);

            // make sure we get a random seed for our random scene
            var tempRng = new Unity.Mathematics.Random();

            tempRng.InitState((uint)UnityEngine.Random.Range(1, 1000));
            m_ChapterTwelve = new BatchedTracer(ExampleSphereSets.RandomScene(500, tempRng.NextUInt()),
                                                CameraFrame.ChapterTwelve, size.x, size.y);
        }
Esempio n. 2
0
 // used for chapter 11 & 12 - the job that supports focus is different from the one that doesn't,
 // so we need to start a different coroutine on click
 void DrawChapterWithFocusSupport(BatchedTracer chapter, string chapterNumber)
 {
     DrawLaterChapter(chapter, chapterNumber, (tracer) =>
     {
         var routineEnumerator = tracer.BatchCoroutine(m_SamplesPerPixel, Repaint);
         tracer.Routine        = EditorCoroutineUtility.StartCoroutine(routineEnumerator, this);
     });
 }
Esempio n. 3
0
        void DrawLaterChapter(BatchedTracer chapter, string chapterNumber, Action <BatchedTracer> onClick)
        {
            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Sample Count", EditorStyles.boldLabel);
            EditorGUILayout.BeginHorizontal(k_LargeHeaderHeight, GUILayout.ExpandHeight(true));
            EditorGUILayout.LabelField("Completed: " + chapter.CompletedSampleCount,
                                       k_CompletedSamplesStyle, k_LargeHeaderHeight);
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();

            if (GUILayout.Button($"Draw Chapter {chapterNumber} Image"))
            {
                onClick(chapter);
            }

            DrawTexture(chapter.texture);
            EditorGUILayout.Separator();
            EditorGUILayout.Space();
        }
Esempio n. 4
0
        void ScaleChapters()
        {
            var size = Constants.DefaultImageSize * m_SelectedScaleOption;

            m_ChaptersOneAndTwo.Resize(size);
            m_ChapterThree.Resize(size);
            m_ChapterFour.Resize(size);
            m_ChapterFive.Resize(size);
            m_ChapterFiveTwo.Resize(size);
            m_ChapterSix.Resize(size);
            m_ChapterSeven.Resize(size);
            m_ChapterEight.Resize(size);
            m_ChapterNine.Resize(size);
            m_ChapterTen.Resize(size);
            m_ChapterEleven.Resize(size);

            m_ChapterTwelve.Dispose();
            var tempRng = new Unity.Mathematics.Random();

            tempRng.InitState((uint)UnityEngine.Random.Range(1, 1000));
            m_ChapterTwelve = new BatchedTracer(ExampleSphereSets.RandomScene(500, tempRng.NextUInt()),
                                                CameraFrame.ChapterTwelve, size.x, size.y);
        }
Esempio n. 5
0
        void OnEnable()
        {
            minSize = new Vector2(200, 100);
            maxSize = new Vector2(1600, 800);
            EnsureRaySceneManager();

            m_RayTracer = new BatchedTracer(m_SceneManager.Spheres, CameraFrame.Default, 400, 200)
            {
                ClearOnDraw = true
            };
            m_TracerRenderTexture = m_RayTracer.texture;
            m_SceneManager        = FindObjectOfType <RaytracingSceneManager>();
            m_SceneManager.UpdateWorld();
            m_SceneManager.onSceneChanged += OnSceneChange;

            if (FindObjectOfType <RaytracingSceneManager>() == null)
            {
                EditorSceneManager.LoadScene("ChapterEight");
            }

            m_SceneManager.UpdateWorld();
            OnSceneChange();
        }