示例#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);
        }
示例#2
0
 public void SetSampler(SamplerType samplerType, int numSamples, int numSets = 83)
 {
     m_Samplers = new SamplerBase[Environment.ProcessorCount];
     for (int i = 0; i < m_Samplers.Length; i++)
     {
         m_Samplers[i] = SamplerFactory.Create(samplerType, numSamples, numSets);
     }
     //m_Sampler = sampler;
 }
示例#3
0
            public Job(RenderConfig config, Scene scene, W renderer, ConcurrentQueue <IRenderWork <T, W> > works, ConcurrentQueue <T> results, ManualResetEvent resetEvent)
            {
                m_Works      = works;
                m_Results    = results;
                m_ResetEvent = resetEvent;

                m_Scene    = scene;
                m_Renderer = renderer;

                m_Sampler = SamplerFactory.Create(config.samplerType, config.numSamples, config.numSets);
            }
示例#4
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);
        }