def process(self): if not self.inputs['Float'].is_linked: return n_id = node_id(self) self.delete_texture() nvBGL2.callback_disable(n_id) size_tex = 0 width = 0 height = 0 # why is cMode a sequence like (bool,) ? see uniform_bool(name, seq) in # https://docs.blender.org/api/blender2.8/gpu.types.html is_multi_channel = self.color_mode in ('RGB', 'RGBA') cMode = (is_multi_channel, ) if self.to_image_viewer: mode = self.color_mode pixels = np.array( self.inputs['Float'].sv_get(deepcopy=False)).flatten() width, height = self.texture_width_height resized_np_array = np.resize(pixels, self.calculate_total_size()) transfer_to_image(resized_np_array, self.texture_name, width, height, mode) if self.activate: texture = self.get_buffer() width, height = self.texture_width_height # x, y = self.xy_offset gl_color_constant = gl_color_dict.get(self.color_mode) name = bgl.Buffer(bgl.GL_INT, 1) bgl.glGenTextures(1, name) self.texture[n_id] = name[0] init_texture(width, height, name[0], texture, gl_color_constant) width, height = self.get_dimensions(width, height) batch, shader = generate_batch_shader((width, height)) draw_data = { 'tree_name': self.id_data.name[:], 'node_name': self.name[:], 'mode': 'custom_function_context', 'custom_function': simple_screen, 'loc': get_drawing_location, 'args': (texture, self.texture[n_id], width, height, batch, shader, cMode) } nvBGL2.callback_enable(n_id, draw_data)
def process(self): # upgrades older versions of ProfileMK3 to the version that has self.file_pointer if self.image and not self.image_pointer: image = self.get_bpy_data_from_name(self.image, bpy.data.images) if image: self.image_pointer = image n_id = node_id(self) self.delete_texture() nvBGL2.callback_disable(n_id) # why is cMode a sequence like (bool,) ? see uniform_bool(name, seq) in # https://docs.blender.org/api/blender2.8/gpu.types.html gl_color_constant = gl_color_dict.get(self.color_mode) is_multi_channel = self.color_mode in ('RGB', 'RGBA') cMode = (is_multi_channel, ) if self.output_mode == 'bgl': # x, y = self.xy_offset width, height, colm = self.width_custom_tex, self.height_custom_tex, self.color_mode total_size = width * height * factor_buffer_dict.get(colm) texture = bgl.Buffer( bgl.GL_FLOAT, total_size, np.resize(self.inputs[0].sv_get(), total_size).tolist()) name = bgl.Buffer(bgl.GL_INT, 1) bgl.glGenTextures(1, name) self.texture[n_id] = name[0] init_texture(width, height, name[0], texture, gl_color_constant) width, height = self.get_dimensions(width, height) batch, shader = generate_batch_shader((width, height)) draw_data = { 'tree_name': self.id_data.name[:], 'node_name': self.name[:], 'mode': 'custom_function_context', 'custom_function': simple_screen, 'loc': get_drawing_location, 'args': (texture, self.texture[n_id], width, height, batch, shader, cMode) } nvBGL2.callback_enable(n_id, draw_data) else: Im = bpy.data.images[self.image] Im.pixels = np.resize(self.inputs[0].sv_get(), len(Im.pixels))