Browse Source

Fix mask blend

luboslenco 1 month ago
parent
commit
c98e564c11
2 changed files with 20 additions and 14 deletions
  1. 11 11
      armorpaint/sources/make_material.ts
  2. 9 3
      base/sources/ts/tab_layers.ts

+ 11 - 11
armorpaint/sources/make_material.ts

@@ -460,31 +460,31 @@ function make_material_blend_mode(kong: node_shader_t, blending: i32, cola: stri
 
 
 function make_material_blend_mode_mask(blending: i32, cola: string, colb: string, opac: string): string {
 function make_material_blend_mode_mask(blending: i32, cola: string, colb: string, opac: string): string {
 	if (blending == blend_type_t.MIX) {
 	if (blending == blend_type_t.MIX) {
-		return "lerp3(" + cola + ", " + colb + ", " + opac + ")";
+		return "lerp(" + cola + ", " + colb + ", " + opac + ")";
 	}
 	}
 	else if (blending == blend_type_t.DARKEN) {
 	else if (blending == blend_type_t.DARKEN) {
-		return "lerp3(" + cola + ", min3(" + cola + ", " + colb + "), " + opac + ")";
+		return "lerp(" + cola + ", min(" + cola + ", " + colb + "), " + opac + ")";
 	}
 	}
 	else if (blending == blend_type_t.MULTIPLY) {
 	else if (blending == blend_type_t.MULTIPLY) {
-		return "lerp3(" + cola + ", " + cola + " * " + colb + ", " + opac + ")";
+		return "lerp(" + cola + ", " + cola + " * " + colb + ", " + opac + ")";
 	}
 	}
 	else if (blending == blend_type_t.BURN) {
 	else if (blending == blend_type_t.BURN) {
-		return "lerp3(" + cola + ", 1.0 - (1.0 - " + cola + ") / " + colb + ", " + opac + ")";
+		return "lerp(" + cola + ", 1.0 - (1.0 - " + cola + ") / " + colb + ", " + opac + ")";
 	}
 	}
 	else if (blending == blend_type_t.LIGHTEN) {
 	else if (blending == blend_type_t.LIGHTEN) {
-		return "max3(" + cola + ", " + colb + " * " + opac + ")";
+		return "max(" + cola + ", " + colb + " * " + opac + ")";
 	}
 	}
 	else if (blending == blend_type_t.SCREEN) {
 	else if (blending == blend_type_t.SCREEN) {
 		return "(1.0 - ((1.0 - " + opac + ") + " + opac + " * (1.0 - " + colb + ")) * (1.0 - " + cola + "))";
 		return "(1.0 - ((1.0 - " + opac + ") + " + opac + " * (1.0 - " + colb + ")) * (1.0 - " + cola + "))";
 	}
 	}
 	else if (blending == blend_type_t.DODGE) {
 	else if (blending == blend_type_t.DODGE) {
-		return "lerp3(" + cola + ", " + cola + " / (1.0 - " + colb + "), " + opac + ")";
+		return "lerp(" + cola + ", " + cola + " / (1.0 - " + colb + "), " + opac + ")";
 	}
 	}
 	else if (blending == blend_type_t.ADD) {
 	else if (blending == blend_type_t.ADD) {
-		return "lerp3(" + cola + ", " + cola + " + " + colb + ", " + opac + ")";
+		return "lerp(" + cola + ", " + cola + " + " + colb + ", " + opac + ")";
 	}
 	}
 	else if (blending == blend_type_t.OVERLAY) {
 	else if (blending == blend_type_t.OVERLAY) {
-		return "lerp3(" + cola + ", " + cola + " < 0.5 ? 2.0 * " + cola + " * " + colb + " : 1.0 - 2.0 * (1.0 - " + cola + ") * (1.0 - " + colb + "), " + opac + ")";
+		return "lerp(" + cola + ", " + cola + " < 0.5 ? 2.0 * " + cola + " * " + colb + " : 1.0 - 2.0 * (1.0 - " + cola + ") * (1.0 - " + colb + "), " + opac + ")";
 	}
 	}
 	else if (blending == blend_type_t.SOFT_LIGHT) {
 	else if (blending == blend_type_t.SOFT_LIGHT) {
 		return "((1.0 - " + opac + ") * " + cola + " + " + opac + " * ((1.0 - " + cola + ") * " + colb + " * " + cola + " + " + cola + " * (1.0 - (1.0 - " + colb + ") * (1.0 - " + cola + "))))";
 		return "((1.0 - " + opac + ") * " + cola + " + " + opac + " * ((1.0 - " + cola + ") * " + colb + " * " + cola + " + " + cola + " * (1.0 - (1.0 - " + colb + ") * (1.0 - " + cola + "))))";
@@ -493,16 +493,16 @@ function make_material_blend_mode_mask(blending: i32, cola: string, colb: string
 		return "(" + cola + " + " + opac + " * (2.0 * (" + colb + " - 0.5)))";
 		return "(" + cola + " + " + opac + " * (2.0 * (" + colb + " - 0.5)))";
 	}
 	}
 	else if (blending == blend_type_t.DIFFERENCE) {
 	else if (blending == blend_type_t.DIFFERENCE) {
-		return "lerp3(" + cola + ", abs3(" + cola + " - " + colb + "), " + opac + ")";
+		return "lerp(" + cola + ", abs(" + cola + " - " + colb + "), " + opac + ")";
 	}
 	}
 	else if (blending == blend_type_t.SUBTRACT) {
 	else if (blending == blend_type_t.SUBTRACT) {
-		return "lerp3(" + cola + ", " + cola + " - " + colb + ", " + opac + ")";
+		return "lerp(" + cola + ", " + cola + " - " + colb + ", " + opac + ")";
 	}
 	}
 	else if (blending == blend_type_t.DIVIDE) {
 	else if (blending == blend_type_t.DIVIDE) {
 		return "(1.0 - " + opac + ") * " + cola + " + " + opac + " * " + cola + " / " + colb + "";
 		return "(1.0 - " + opac + ") * " + cola + " + " + opac + " * " + cola + " / " + colb + "";
 	}
 	}
 	else { // BlendHue, BlendSaturation, BlendColor, BlendValue
 	else { // BlendHue, BlendSaturation, BlendColor, BlendValue
-		return "lerp3(" + cola + ", " + colb + ", " + opac + ")";
+		return "lerp(" + cola + ", " + colb + ", " + opac + ")";
 	}
 	}
 }
 }
 
 

+ 9 - 3
base/sources/ts/tab_layers.ts

@@ -110,7 +110,9 @@ function tab_layers_button_new(text: string) {
 				}, m);
 				}, m);
 				context_raw.layer_preview_dirty = true;
 				context_raw.layer_preview_dirty = true;
 				history_new_black_mask();
 				history_new_black_mask();
-				layers_update_fill_layers();
+				sys_notify_on_init(function () {
+					layers_update_fill_layers();
+				});
 			}
 			}
 			if (ui_menu_button(tr("White Mask"))) {
 			if (ui_menu_button(tr("White Mask"))) {
 				if (slot_layer_is_mask(l)) {
 				if (slot_layer_is_mask(l)) {
@@ -124,7 +126,9 @@ function tab_layers_button_new(text: string) {
 				}, m);
 				}, m);
 				context_raw.layer_preview_dirty = true;
 				context_raw.layer_preview_dirty = true;
 				history_new_white_mask();
 				history_new_white_mask();
-				layers_update_fill_layers();
+				sys_notify_on_init(function () {
+					layers_update_fill_layers();
+				});
 			}
 			}
 			if (ui_menu_button(tr("Fill Mask"))) {
 			if (ui_menu_button(tr("Fill Mask"))) {
 				if (slot_layer_is_mask(l)) {
 				if (slot_layer_is_mask(l)) {
@@ -138,7 +142,9 @@ function tab_layers_button_new(text: string) {
 				}, m);
 				}, m);
 				context_raw.layer_preview_dirty = true;
 				context_raw.layer_preview_dirty = true;
 				history_new_fill_mask();
 				history_new_fill_mask();
-				layers_update_fill_layers();
+				sys_notify_on_init(function () {
+					layers_update_fill_layers();
+				});
 			}
 			}
 			ui.enabled = !slot_layer_is_group(context_raw.layer) && !slot_layer_is_in_group(context_raw.layer);
 			ui.enabled = !slot_layer_is_group(context_raw.layer) && !slot_layer_is_in_group(context_raw.layer);
 			if (ui_menu_button(tr("Group"))) {
 			if (ui_menu_button(tr("Group"))) {