Пример #1
0
        public RenderPipeline(RhinoDoc doc, Rhino.Commands.RunMode mode, Rhino.PlugIns.RenderPlugIn plugin, ModalRenderEngine aRC)
            : base(doc, mode, plugin, RenderSize(doc),
					"RhinoCycles", Rhino.Render.RenderWindow.StandardChannels.RGBA, false, false)
        {
            cyclesEngine = aRC;
        }
Пример #2
0
        public override bool StartRenderer(int w, int h, RhinoDoc doc, ViewInfo rhinoView, ViewportInfo viewportInfo, bool forCapture, RenderWindow renderWindow)
        {
            _started = true;
            if (forCapture)
            {
                ModalRenderEngine mre = new ModalRenderEngine(doc, PlugIn.IdFromName("RhinoCycles"), rhinoView, viewportInfo);
                _cycles = null;
                _modal = mre;

                mre.Settings = RcCore.It.EngineSettings;
                mre.Settings.UseInteractiveRenderer = false;
                mre.Settings.SetQuality(doc.RenderSettings.AntialiasLevel);

                var rs = new Size(w, h);

                mre.RenderWindow = renderWindow;

                mre.RenderDimension = rs;
                mre.Database.RenderDimension = rs;

                mre.Settings.Verbose = true;

                mre.StatusTextUpdated += Mre_StatusTextUpdated;

                mre.Database.LinearWorkflowChanged += DatabaseLinearWorkflowChanged;

                mre.SetFloatTextureAsByteTexture(false); // mre.Settings.RenderDeviceIsOpenCl);

                mre.CreateWorld(); // has to be done on main thread, so lets do this just before starting render session

                _modalThread = new Thread(RenderOffscreen)
                {
                    Name = $"Cycles offscreen viewport rendering with ModalRenderEngine {_serial}"
                };
                _modalThread.Start(mre);

                return true;
            }

            _available = false; // the renderer hasn't started yet. It'll tell us when it has.
            _frameAvailable = false;

            _cycles = new ViewportRenderEngine(doc.RuntimeSerialNumber, PlugIn.IdFromName("RhinoCycles"), rhinoView);

            _cycles.StatusTextUpdated += CyclesStatusTextUpdated; // render engine tells us status texts for the hud
            _cycles.RenderStarted += CyclesRenderStarted; // render engine tells us when it actually is rendering
            _cycles.StartSynchronizing += CyclesStartSynchronizing;
            _cycles.Synchronized += CyclesSynchronized;
            _cycles.PassRendered += CyclesPassRendered;
            _cycles.Database.LinearWorkflowChanged += DatabaseLinearWorkflowChanged;
            _cycles.SamplesChanged += CyclesSamplesChanged;

            _cycles.Settings = RcCore.It.EngineSettings;
            _cycles.Settings.SetQuality(doc.RenderSettings.AntialiasLevel);

            var renderSize = Rhino.Render.RenderPipeline.RenderSize(doc);

            _cycles.RenderWindow = renderWindow;
            _cycles.RenderDimension = renderSize;

            _cycles.Settings.Verbose = true;

            _maxSamples = _cycles.Settings.Samples;

            _cycles.SetFloatTextureAsByteTexture(false); // m_cycles.Settings.RenderDeviceIsOpenCl);

            _cycles.CreateWorld(); // has to be done on main thread, so lets do this just before starting render session

            _startTime = DateTime.UtcNow;

            _cycles.StartRenderThread(_cycles.Renderer, $"A cool Cycles viewport rendering thread {_serial}");

            return true;
        }