GPU Texture Utilities (gpu.texture)

This module provides utilities for textures.

gpu.texture.from_image(image)

Get GPUTexture corresponding to an Image data-block. The GPUTexture memory is shared with Blender. Note: Colors read from the texture will be in scene linear color space and have premultiplied or straight alpha matching the image alpha mode.

Parameters:

image (bpy.types.Image) – The Image data-block.

Returns:

The GPUTexture used by the image.

Return type:

gpu.types.GPUTexture

gpu.texture.set_image_texture(image, texture)

Override the GPU texture used by a bpy.types.Image datablock. Material Image Texture nodes will sample from texture instead of uploading pixel data from CPU memory. Pass None to clear the override and restore normal behaviour.

Warning

The image does not take ownership of the texture. You must keep it alive for as long as the image may be rendered, and free it manually with gpu.types.GPUTexture.free().

Parameters: