Beispiel #1
0
        protected override IRenderResult OnRenderDebugSinglePixel(int x, int y, RenderConfig config)
        {
            CameraBase camera = m_Scene.camera;

            if (camera == null)
            {
                throw new System.ArgumentNullException();
            }

            Texture result = new Texture(config.width, config.height);

            result.Fill(Color.black);

            var sampler = SamplerFactory.Create(config.samplerType, config.numSamples, config.numSets);

            camera.SetRenderTarget(result);


            Color col = Color.black;

            sampler.ResetSampler(); //重置采样器状态
            while (sampler.NextSample())
            {
                Ray ray = m_Scene.camera.GetRay(x, y, sampler);
                col += this.PathTracing(ray, sampler);
            }

            col /= sampler.numSamples;

            col.a = 1.0f;
            result.SetPixel(x, y, col);

            return(result);
        }
Beispiel #2
0
        public Texture RenderSinglePixel(int x, int y, int tracingTimes, SamplerType samplerType, int numSamples, int width, int height, int numSets = 83)
        {
            Texture result = new Texture(width, height);

            result.Fill(Color.black);
            m_Tracer           = new PathTracer(tracingTimes, 0.000001);
            m_Tracer.sceneData = m_SceneData;
            //m_Camera.SetSampler(samplerType, numSamples, numSets);
            var sampler = SamplerFactory.Create(samplerType, numSamples, numSets);

            m_Camera.SetRenderTarget(result);
            try
            {
                m_Camera.RenderPixel(x, y, sampler, this);
            }
            catch (System.Exception e)
            {
                Log.Err(e.Message);
            }

            return(result);
        }