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.texture.set_image_texture(image, texture)
Override the GPU texture used by a
bpy.types.Imagedatablock. Material Image Texture nodes will sample fromtextureinstead of uploading pixel data from CPU memory. PassNoneto 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:
image (
bpy.types.Image) – The Image datablock to override.texture (
gpu.types.GPUTexture| None) – Texture to use, orNoneto clear.