Hide navigation sidebar
Hide table of contents sidebar
Back to top
Toggle table of contents sidebar

# `Hydra.utils.texture`

Module responsible for handling ModernGL textures and Blender images.

## Module Contents

Hydra.utils.texture.getOrMakeImage(size: tuple[int, int], name: str) → bpy.types.Image

  Gets or creates an image of the specified name. If sizes are different, then it gets scaled to size.

  Parameters:

    - size (`tuple[int,int]`) – Resolution tuple.

    - name (`str`) – Name of created image.

  Returns:

    Created image.

  Return type:

    `bpy.types.Image`

Hydra.utils.texture.writeImage(name: str, txt: moderngl.Texture) → bpy.types.Image

  Writes texture to an Image of the specified name.

  Parameters:

    - name (`str`) – Image name.

    - txt (`moderngl.Texture`) – Texture to be read.

  Returns:

    Created image.

  Return type:

    `bpy.types.Image`

Hydra.utils.texture.fillImageMono(image: bpy.types.Image, texture: moderngl.Texture)

  Writes single channel texture data to an image.

  Parameters:

    - image (`bpy.types.Image`) – Image to be written to.

    - texture (`moderngl.Texture`) – Texture to be read.

Hydra.utils.texture.fillImage(image: bpy.types.Image, texture: moderngl.Texture)

  Writes four channel texture data to an image.

  Parameters:

    - image (`bpy.types.Image`) – Image to be written to.

    - texture (`moderngl.Texture`) – Texture to be read.

Hydra.utils.texture.createTexture(size: tuple[int, int], pixels: bytes | None = None) → moderngl.Texture

  Creates a single channel `moderngl.Texture` of the specified size.

  Parameters:

    - size (`tuple[int,int]`) – Resolution tuple.

    - pixels (`bytes` or `None`) – Optional texture data.

  Returns:

    Created texture.

  Return type:

    `moderngl.Texture`

Hydra.utils.texture.createTextureFull(size: tuple[int, int]) → moderngl.Texture

  Creates a four channel `moderngl.Texture` of the specified size.

  Parameters:

    size (`tuple[int,int]`) – Resolution tuple.

  Returns:

    Created texture.

  Return type:

    `moderngl.Texture`

Hydra.utils.texture.createColorTexture(size: tuple[int, int], image: bpy.types.Image) → moderngl.Texture

  Creates a four channel `moderngl.Texture` from the specified image. Redraws to new size if needed.

  Parameters:

    - size (`tuple[int,int]`) – Final resolution tuple.

    - image (`bpy.types.Image`) – Image to be read.

  Returns:

    Created texture.

  Return type:

    `moderngl.Texture`

Hydra.utils.texture.clone(txt: moderngl.Texture) → moderngl.Texture

  Clones a `moderngl.Texture`.

  Parameters:

    txt (`mgl.Texture`) – Texture to be cloned.

  Returns:

    Created texture.

  Return type:

    `moderngl.Texture`