Description
Changelog
Reviews (0)

Mixed Texture 2D

A small Godot 4.7 addon that adds a MixedTexture2D resource: a Texture2D baked from an array of layers, each with its own blend mode, opacity, scale and wrap mode. Enable the Mixed Texture 2D plugin to use it (or just copy the addons/godot-mixed-texture-2d folder — the types register via class_name).

Because MixedTexture2D is a real Texture2D, you can assign it anywhere a texture is expected (Sprite2D, TextureRect, materials, exports).

Usage

var base := MixedTextureLayer2D.new()
base.texture = preload("res://noise_a.tres")

var top := MixedTextureLayer2D.new()
top.texture = preload("res://noise_b.tres")
top.blend_mode = MixedTextureLayer2D.BlendMode.OVERLAY
top.opacity = 0.8
top.scale = Vector2(2, 2)          # tile the source twice as large
top.wrap_mode = MixedTextureLayer2D.WrapMode.MIRROR

var mixed := MixedTexture2D.new()
mixed.size = Vector2i(256, 256)    # output resolution
mixed.layers = [base, top]         # composited bottom-to-top

$Sprite2D.texture = mixed

You can also create a MixedTexture2D and its layers directly in the inspector.

MixedTexture2D properties

  • size – output resolution
  • layers – the MixedTextureLayer2Ds, composited bottom-to-top
  • alpha_mode – how the output alpha is produced:
    • KEEP (default) – use the composited alpha
    • PREMULTIPLIED – treat the baked RGB as premultiplied alpha
    A shape built with the opaque blend modes ( ADD/DIFFERENCE/DARKEN/LIGHTEN) over black is effectively a premultiplied-alpha image: the color is already color × coverage, and those modes can't carve the alpha channel themselves. PREMULTIPLIED recovers coverage as alpha (the brightest channel) and divides the color back out, turning e.g. a gold star on black into a gold star on transparency. Unlike a naive luminance/value key, it stays correct on soft edges (no double-darkening).

Layer properties

  • texture – the source Texture2D
  • blend_modeNORMAL, MULTIPLY, ADD, SUBTRACT, SCREEN, OVERLAY, DARKEN, LIGHTEN, DIFFERENCE
  • opacity0..1
  • enabled – toggle the layer off without removing it
  • scale / offset – place and resize the source in output space
  • wrap_mode – how to fill the output: REPEAT, CLAMP, MIRROR

Notes

  • The composite is baked on a background thread (via WorkerThreadPool) whenever a property changes, so editing stays responsive. It is not stored in the saved resource, so it always reflects the current sources.
  • Each layer follows its source texture's changed signal, so a source that isn't ready yet or changes later is skipped while empty and rebaked once it updates.

Changelog for version 0.1.0

No changelog provided for this version.

Reviews

MixedTexture2D has no reviews yet.

Login to write a review.