Combining Materials on one Mesh

Godot Version

4.5.1

Question

I am making a small game with a cube player with a skin customisation feature, and found a way to overlay materials on top of each other using a sketchy method, since I would have to draw an exponential amount of different combinations for all the different options. I couldn’t find a better way to do it, but I used one material on 6 planes making up the cube shape (since putting a texture wrapped onto the cube weirdly). All faces use the same material, with 3 next_pass on it, acting as layers. Each have distance fade set to PixelAlpha and sampling repeat off, making it so you can see the other layers behind it.

I need three layers total - a border / outline around each face, a design (the square in the middle in the video, all png textures), and the base colour in the background (red).

In the video, each face unrenders the design and border textures at random times (seems to be where the camera is), and I can’t figure out why. If anyone knows why it does this, or know a better way to overlay materials like this, please tell.

Player script

extends RigidBody3D
class_name Player

var base = preload("res://player/materials/base.tres")
var border = preload("res://player/materials/border.tres")
var design = preload("res://player/materials/design.tres")
var player_kit = preload("res://player/materials/_player_kit.tres")

func _ready() -> void:
	# Sync kit to player in-game
	if Customisation.border:
		border.albedo_texture = Customisation.BORDER_TEXTURE
	else:
		border.albedo_texture = Customisation.BORDER_BLANK
	
	design.albedo_texture = Customisation.design
	design.albedo_color = Customisation.design_colour
	
	base.albedo_color = Customisation.base_colour
	
	player_kit.next_pass = border
	player_kit.next_pass.next_pass = design
	player_kit.next_pass.next_pass.next_pass = base

Autoload script

extends Node

var border := true
const BORDER_TEXTURE = preload("res://player/designs/border.png")
const BORDER_BLANK = preload("res://player/designs/design empty.png")

var design_ID := 1
var design := preload("res://player/designs/design box.png")

var base_colour : Color = Color.RED
var design_colour : Color = Color.WHITE

Video:

How many overlays do you need in total? You can mix them in a shader.