XRay shader not rendering through MultiMeshInstance3D

Godot Version

4.5.1

Question

I have a shader for a Sprite3D that’s trying to render an xray render-through effect for occluding geometry. Here’s the shader:

shader_type spatial;
render_mode blend_mix, depth_test_disabled;
uniform sampler2D texture_albedo : source_color;
uniform sampler2D depth_texture : hint_depth_texture, repeat_disable, filter_nearest;

void fragment() {
	vec4 albedo_tex = texture(texture_albedo, UV);
	ALBEDO = albedo_tex.rgb;
	ALPHA = albedo_tex.a;
	float depth_tex = texture(depth_texture, SCREEN_UV).r;
	if (depth_tex > FRAGCOORD.z) {
		// Render blue when occluding
		ALBEDO = vec3(0.0, 0.0, 1.0);
	}
}

The effect is working for simple MeshInstance3D occluders, but not for the MultiMeshInstance3D I’m using for foliage. Here’s the shader I’m using for the MultiMeshInstance3D:

shader_type spatial;
render_mode cull_disabled, depth_prepass_alpha, depth_draw_opaque;

varying float layer;

uniform sampler2DArray albedos : source_color, filter_linear_mipmap;

vec4 get_texture(vec2 uv, float lay) {
	return texture(albedos, vec3(uv.x, uv.y, lay));
}

void vertex() {
	layer = INSTANCE_CUSTOM.a;
}

void fragment() {
	vec4 tex = get_texture(UV, layer);
	ALBEDO = tex.rgb;
	ALPHA = tex.a;
}

I think the problem is with the ALPHA = tex.a part, because when I comment that out, the xray effect works, but of course the foliage texture isn’t rendering properly.

What should I do?

Increase the render priority of the xray material.

That doesn’t seem to have any effect…

EDIT: hang on a minute, it did work. Thanks