i wouldn’t use a half painted texture. i’d use one texture for the top and one for the bottom then lerp between them using a mask.
replace the colors and “if mask” with texture samples.