예제 #1
0
        private void Start()
        {
            this.scene = TDLoader.LoadScene();
            int pixelResolutionX = (int)this.scene.camera.pixelResolution.x;
            int pixelResolutionY = (int)this.scene.camera.pixelResolution.y;

            this.cpuTexture           = new Texture2D(pixelResolutionX, pixelResolutionY);
            this.screenPixelPositions = this.GetScreenPixelPositions();
            this.accumulatedColor     = new float3[pixelResolutionX * pixelResolutionY];
            this.numIterations        = 0;
            //Debug.Log(RandomPointInUnitSphere());
            System.Random m_rng        = new System.Random();
            int           kernelHandle = cs.FindKernel("CSMain");

            numIterations = 0;

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();
            this.GPUPrepare();
            //this.Render();
            sw.Stop();
            Debug.Log(sw.Elapsed);

            //this.StartCoroutine(RenderProgressiveCPU());
            this.StartCoroutine(RenderProgressive());
        }
예제 #2
0
        public static TDScene LoadScene()
        {
            TDCamera camera = new TDCamera(Camera.main);

            List <TDSphere> spheres = new List <TDSphere>();

            TDSceneSphere[] sceneSpheres = MonoBehaviour.FindObjectsOfType <TDSceneSphere>();

            foreach (TDSceneSphere sceneSphere in sceneSpheres)
            {
                spheres.Add(new TDSphere(sceneSphere.transform.position,
                                         new Unity.Mathematics.float3(sceneSphere.albedo.r, sceneSphere.albedo.g, sceneSphere.albedo.b),
                                         sceneSphere.emissionIntensity * new Unity.Mathematics.float3(sceneSphere.emission.r, sceneSphere.emission.g, sceneSphere.emission.b),
                                         sceneSphere.transform.lossyScale.x * 0.5f,
                                         TDLoader.GetMaterialIndex(sceneSphere.material),
                                         sceneSphere.fuzz,
                                         sceneSphere.refractiveIndex));
            }

            return(new TDScene(camera, spheres));
        }