// LoadScene loads a scene func (rr *RemoteRaytracer) LoadScene(data []byte) error { var err error scene, err := scene.LoadFromBytes(data) if err != nil { return err } scene.Init() rr.Raytracer.SetScene(scene) return nil }
func runRender(c *cli.Context) error { scenePath, image := getArguments(c) quiet := c.GlobalBool("quiet") if !quiet { log.Printf( "will render %d samples of %s to %s of size %dx%d with %d threads", c.Int("total-samples"), scenePath, image, c.Int("width"), c.Int("height"), c.Int("max-jobs"), ) } width, height := c.Int("width"), c.Int("height") totalSamples := c.Int("total-samples") threads := c.Int("max-jobs") renderedImages := make(chan *hdrimage.Image) scene, err := scene.LoadFromFile(scenePath) if err != nil { return fmt.Errorf("can't open scene: %s", err) } scene.Init() go func() { renderer(width, height, renderedImages, scene, 42, totalSamples, threads, quiet) close(renderedImages) }() averageImage := hdrimage.New(width, height) averageImage.Divisor = 0 for currentImage := range renderedImages { averageImage.Add(currentImage) averageImage.Divisor += currentImage.Divisor } return savePng(averageImage, image) }