Untitled
unknown
plain_text
2 years ago
806 B
3
Indexable
Never
import bpy import gpu width = 32 height = 32 modal_redraw = False image_name = "color_buffer_copy" framebuffer = None viewport_info = None pixelBuffer = None def draw(): if not image_name in bpy.data.images: framebuffer_image = bpy.data.images.new(image_name , 32, 32, float_buffer=True) else: framebuffer_image = bpy.data.images[image_name] framebuffer = gpu.state.active_framebuffer_get() viewport_info = gpu.state.viewport_get() width = viewport_info[2] height = viewport_info[3] framebuffer_image.scale(width, height) pixelBuffer = framebuffer.read_color(0, 0, width, height, 4, 0, 'FLOAT') pixelBuffer.dimensions = width * height * 4 framebuffer_image.pixels.foreach_set(pixelBuffer) if __name__ == "__main__": draw()