Пример #1
0
	def view_draw(self, context):
		print("LuxCore view_draw call")
		
		# Check if the size of the window is changed
		if (self.filmWidth != context.region.width) or (self.filmHeight != context.region.height):
			self.view_update(context)
		
		# Update statistics
		self.session.UpdateStats()

		stats = self.session.GetStats();
		print("[Elapsed time: %3d][Samples %4d][Avg. samples/sec % 3.2fM on %.1fK tris]" % (
				stats.Get("stats.renderengine.time").GetFloat(),
				stats.Get("stats.renderengine.pass").GetInt(),
				(stats.Get("stats.renderengine.total.samplesec").GetFloat()  / 1000000.0),
				(stats.Get("stats.dataset.trianglecount").GetFloat() / 1000.0)))
		
		# Update the screen
		self.session.GetFilm().GetOutputFloat(pyluxcore.FilmOutputType.RGB_TONEMAPPED, self.imageBufferFloat)
		glBuffer = bgl.Buffer(bgl.GL_FLOAT, [self.filmWidth * self.filmHeight * 3], self.imageBufferFloat)
		bgl.glRasterPos2i(0, 0)
		bgl.glDrawPixels(self.filmWidth, self.filmHeight, bgl.GL_RGB, bgl.GL_FLOAT, glBuffer);
		
		# Trigger another update
		self.tag_redraw()
Пример #2
0
    def view_draw_image(self, context, width, height, raw):
        region = context.region
        view = context.region_data

        vmat = view.view_matrix.copy()
        vmat_inv = vmat.inverted()
        pmat = view.perspective_matrix * vmat_inv

        viewport = [region.x, region.y, region.width, region.height]

        self.update_view(vmat, pmat, viewport)
        #raw = [[255, 0, 0, 255]] * (width * height)
        pixel_count = width * height
        print("VIEW DRAW RAW:" + str(len(raw)) + " count:" +
              str(pixel_count * 4))
        bitmap = bgl.Buffer(bgl.GL_BYTE, [pixel_count * 4], raw)
        # bgl.glBitmap(self.size_x, self.size_y, 0, 0, 0, 0, bitmap)
        scalex = 1.0 / width * 2
        scaley = 1.0 / height * 2
        bgl.glRasterPos2i(0, 0)
        # bgl.glWindowPos2i(0,0)
        #bgl.glPixelZoom( scalex,-scaley );
        bgl.glDrawPixels(
            width,
            height,
            # Blender.BGL.GL_BGRA, Blender.BGL.GL_UNSIGNED_BYTE,
            # 0x80E1 0x1908
            0x1908,
            0x1401,
            # bgl.GL_BGRA, bgl.GL_UNSIGNED_BYTE,
            bitmap)
Пример #3
0
    def view_draw(self, context):
        print("LuxCore view_draw call")

        # Check if the size of the window is changed
        if (self.filmWidth != context.region.width) or (self.filmHeight !=
                                                        context.region.height):
            self.view_update(context)

        # Update statistics
        self.session.UpdateStats()

        stats = self.session.GetStats()
        print(
            "[Elapsed time: %3d][Samples %4d][Avg. samples/sec % 3.2fM on %.1fK tris]"
            % (stats.Get("stats.renderengine.time").GetFloat(),
               stats.Get("stats.renderengine.pass").GetInt(),
               (stats.Get("stats.renderengine.total.samplesec").GetFloat() /
                1000000.0),
               (stats.Get("stats.dataset.trianglecount").GetFloat() / 1000.0)))

        # Update the screen
        self.session.GetFilm().GetOutputFloat(
            pyluxcore.FilmOutputType.RGB_TONEMAPPED, self.imageBufferFloat)
        glBuffer = bgl.Buffer(bgl.GL_FLOAT,
                              [self.filmWidth * self.filmHeight * 3],
                              self.imageBufferFloat)
        bgl.glRasterPos2i(0, 0)
        bgl.glDrawPixels(self.filmWidth, self.filmHeight, bgl.GL_RGB,
                         bgl.GL_FLOAT, glBuffer)

        # Trigger another update
        self.tag_redraw()
Пример #4
0
 def processMessage(self, header_sizeBytes, header_messageType, data):
     if header_messageType == FromServer.Result:
         self.renderedView = True
         resolution = struct.unpack_from('=HH', memoryview(data))
         imageSizeBytes = resolution[0] * resolution[1] * 4
         glBuffer = bgl.Buffer(bgl.GL_BYTE, [imageSizeBytes],
                               list(data[4:4 + imageSizeBytes]))
         bgl.glRasterPos2i(0, 0)
         bgl.glDrawPixels(resolution[0], resolution[1], bgl.GL_RGBA,
                          bgl.GL_UNSIGNED_BYTE, glBuffer)
Пример #5
0
 def view_draw_image(self, width, height, raw):
     # raw = [[0, 255, 0, 255]] * (width * height)
     pixel_count = width * height
     bitmap = bgl.Buffer(bgl.GL_BYTE, [pixel_count * 4], raw)
     # bgl.glBitmap(self.size_x, self.size_y, 0, 0, 0, 0, bitmap)
     bgl.glRasterPos2i(0, 0)
     bgl.glDrawPixels(width, height,
                      # Blender.BGL.GL_BGRA, Blender.BGL.GL_UNSIGNED_BYTE,
                      0x80E1, 0x1401,
                      # bgl.GL_BGRA, bgl.GL_UNSIGNED_BYTE,
                      bitmap
                      )
Пример #6
0
    def view_draw(self, context):
        region = context.region
        view_3d = context.region_data

        pixels = self.do_render(
            context.scene, region.width, region.height, view_3d.view_matrix,
            view_3d.window_matrix,
            view_3d.view_matrix.inverted().transposed()[3][:3])

        pixel_count = region.width * region.height
        bitmap = bgl.Buffer(bgl.GL_FLOAT, [pixel_count * 3], pixels)

        bgl.glRasterPos2i(0, 0)
        bgl.glDrawPixels(region.width, region.height, bgl.GL_RGB, bgl.GL_FLOAT,
                         bitmap)
Пример #7
0
 def view_draw(self, context):
     bgl.glRasterPos2i(0, 0)
     bgl.glDrawPixels(self.width, self.height, bgl.GL_RGB, bgl.GL_FLOAT,
                      self.glbuffer)
     bgl.glDisable(bgl.GL_BLEND)