Ver código fonte

Cleanup ifdefs

luboslenco 10 meses atrás
pai
commit
23c15d3ade

+ 11 - 0
armorlab/sources/make_material.ts

@@ -3,6 +3,11 @@ let make_material_default_scon: shader_context_t = null;
 let make_material_default_mcon: material_context_t = null;
 let make_material_height_used: bool = false;
 
+type parse_node_preview_result_t = {
+	scon: shader_context_t;
+	mcon: material_context_t;
+};
+
 function make_material_parse_mesh_material() {
 	let m: material_data_t = project_material_data;
 
@@ -141,3 +146,9 @@ function make_material_delete_context(c: shader_context_t) {
 function make_material_parse_brush() {
 	// parser_logic_parse(context_raw.brush.canvas);
 }
+
+function make_material_parse_mesh_preview_material(md: material_data_t = null) {
+}
+
+function make_material_parse_node_preview_material(node: ui_node_t, group: ui_node_canvas_t = null, parents: ui_node_t[] = null): parse_node_preview_result_t {
+}

+ 11 - 0
armorlab/sources/render_path_paint.ts

@@ -1,4 +1,6 @@
 
+let render_path_paint_live_layer: slot_layer_t = null;
+let render_path_paint_live_layer_locked: bool = false;
 let render_path_paint_live_layer_drawn: i32 = 0; ////
 
 function render_path_paint_init() {
@@ -318,3 +320,12 @@ function render_path_paint_bind_layers() {
 function render_path_paint_unbind_layers() {
 
 }
+
+function render_path_paint_use_live_layer(use: bool) {
+}
+
+function render_path_paint_set_plane_mesh() {
+}
+
+function render_path_paint_restore_plane_mesh() {
+}

+ 6 - 0
armorlab/sources/render_path_preview.ts

@@ -0,0 +1,6 @@
+
+function render_path_preview_commands_preview() {
+}
+
+function render_path_preview_commands_decal() {
+}

+ 8 - 0
armorlab/sources/slot_brush.ts

@@ -0,0 +1,8 @@
+type slot_brush_t = {
+	nodes?: ui_nodes_t;
+	canvas?: ui_node_canvas_t;
+	image?: image_t; // 200px
+	image_icon?: image_t; // 50px
+	preview_ready?: bool;
+	id?: i32;
+};

+ 9 - 0
armorlab/sources/slot_font.ts

@@ -0,0 +1,9 @@
+
+type slot_font_t = {
+	image?: image_t; // 200px
+	preview_ready?: bool;
+	id?: i32;
+	font?: g2_font_t;
+	name?: string;
+	file?: string;
+};

+ 17 - 0
armorlab/sources/slot_layer.ts

@@ -6,4 +6,21 @@ type slot_layer_t = {
     texpaint_pack: image_t;
 
     decal_mat: mat4_t;
+    parent?: slot_layer_t;
+    fill_layer?: slot_material_t;
 };
+
+function slot_layer_get_object_mask(raw: slot_layer_t): i32 {
+	return 0;
+}
+
+function slot_layer_create(ext: string = "", type: layer_slot_type_t = layer_slot_type_t.LAYER, parent: slot_layer_t = null): slot_layer_t {
+    return null;
+}
+
+function slot_layer_clear(raw: slot_layer_t, base_color: i32 = 0x00000000, base_image: image_t = null, occlusion: f32 = 1.0, roughness: f32 = base_default_rough, metallic: f32 = 0.0) {
+}
+
+function slot_layer_is_mask(raw: slot_layer_t): bool {
+    return false;
+}

+ 6 - 1
armorlab/sources/slot_material.ts

@@ -2,5 +2,10 @@
 type slot_material_t = {
 	nodes?: ui_nodes_t;
 	canvas?: ui_node_canvas_t;
-
+	preview_ready?: bool;
+	data?: material_data_t;
 };
+
+function slot_material_create(m: material_data_t = null, c: ui_node_canvas_t = null): slot_material_t {
+	return null;
+}

+ 22 - 88
armorpaint/sources/render_path_paint.ts

@@ -97,9 +97,7 @@ function render_path_paint_init() {
 
 	render_path_load_shader("shader_datas/copy_mrt3_pass/copy_mrt3_pass");
 	render_path_load_shader("shader_datas/copy_mrt3_pass/copy_mrt3RGBA64_pass");
-	///if is_paint
 	render_path_load_shader("shader_datas/dilate_pass/dilate_pass");
-	///end
 }
 
 function render_path_paint_commands_paint(dilation: bool = true) {
@@ -131,7 +129,11 @@ function render_path_paint_commands_paint(dilation: bool = true) {
 			render_path_end();
 		}
 
-		///if is_paint
+		///if is_sculpt
+		render_path_sculpt_commands();
+		return;
+		///end
+
 		if (context_raw.tool == workspace_tool_t.COLORID) {
 			render_path_set_target("texpaint_colorid");
 			render_path_clear_target(0xff000000);
@@ -333,49 +335,6 @@ function render_path_paint_commands_paint(dilation: bool = true) {
 				render_path_paint_dilate(true, false);
 			}
 		}
-		///end
-
-		///if is_sculpt
-		let texpaint: string = "texpaint" + tid;
-		render_path_set_target("texpaint_blend1");
-		render_path_bind_target("texpaint_blend0", "tex");
-		render_path_draw_shader("shader_datas/copy_pass/copyR8_pass");
-		let additional: string[] = ["texpaint_blend0"];
-		render_path_set_target(texpaint, additional);
-		render_path_bind_target("gbufferD_undo", "gbufferD");
-		if ((context_raw.xray || config_raw.brush_angle_reject) && config_raw.brush_3d) {
-			render_path_bind_target("gbuffer0", "gbuffer0");
-		}
-		render_path_bind_target("texpaint_blend1", "paintmask");
-
-		// Read texcoords from gbuffer
-		let read_tc: bool = (context_raw.tool == workspace_tool_t.FILL && context_raw.fill_type_handle.position == fill_type_t.FACE) ||
-								context_raw.tool == workspace_tool_t.CLONE ||
-								context_raw.tool == workspace_tool_t.BLUR ||
-								context_raw.tool == workspace_tool_t.SMUDGE;
-		if (read_tc) {
-			render_path_bind_target("gbuffer2", "gbuffer2");
-		}
-		render_path_bind_target("gbuffer0_undo", "gbuffer0_undo");
-
-		let material_contexts: material_context_t[] = [];
-		let shader_contexts: shader_context_t[] = [];
-		let mats: material_data_t[] = project_paint_objects[0].materials;
-		mesh_object_get_contexts(project_paint_objects[0], "paint", mats, material_contexts, shader_contexts);
-
-		let cc_context: shader_context_t = shader_contexts[0];
-		if (const_data_screen_aligned_vb == null) {
-			const_data_create_screen_aligned_data();
-		}
-		g4_set_pipeline(cc_context._.pipe_state);
-		uniforms_set_context_consts(cc_context,_render_path_bind_params);
-		uniforms_set_obj_consts(cc_context, project_paint_objects[0].base);
-		uniforms_set_material_consts(cc_context, material_contexts[0]);
-		g4_set_vertex_buffer(const_data_screen_aligned_vb);
-		g4_set_index_buffer(const_data_screen_aligned_ib);
-		g4_draw();
-		render_path_end();
-		///end
 	}
 }
 
@@ -605,14 +564,7 @@ function render_path_paint_commands_symmetry() {
 }
 
 function render_path_paint_paint_enabled(): bool {
-	///if is_paint
 	let fill_layer: bool = context_raw.layer.fill_layer != null && context_raw.tool != workspace_tool_t.PICKER && context_raw.tool != workspace_tool_t.MATERIAL && context_raw.tool != workspace_tool_t.COLORID;
-	///end
-
-	///if is_sculpt
-	let fill_layer: bool = context_raw.layer.fill_layer != null && context_raw.tool != workspace_tool_t.PICKER && context_raw.tool != workspace_tool_t.MATERIAL;
-	///end
-
 	let group_layer: bool = slot_layer_is_group(context_raw.layer);
 	return !fill_layer && !group_layer && !context_raw.foreground_event;
 }
@@ -632,46 +584,33 @@ function render_path_paint_live_brush_dirty() {
 
 function render_path_paint_begin() {
 
-	///if is_paint
+	///if is_sculpt
+	render_path_sculpt_begin();
+	return;
+	///end
+
 	if (!render_path_paint_dilated) {
 		render_path_paint_dilate(config_raw.dilate == dilate_type_t.DELAYED, true);
 		render_path_paint_dilated = true;
 	}
-	///end
 
 	if (!render_path_paint_paint_enabled()) {
 		return;
 	}
 
-	///if is_paint
 	render_path_paint_push_undo_last = history_push_undo;
-	///end
 
 	if (history_push_undo && history_undo_layers != null) {
 		history_paint();
-
-		///if is_sculpt
-		render_path_set_target("gbuffer0_undo");
-		render_path_bind_target("gbuffer0", "tex");
-		render_path_draw_shader("shader_datas/copy_pass/copy_pass");
-
-		render_path_set_target("gbufferD_undo");
-		render_path_bind_target("_main", "tex");
-		render_path_draw_shader("shader_datas/copy_pass/copy_pass");
-		///end
 	}
 
-	///if is_sculpt
-	if (history_push_undo2 && history_undo_layers != null) {
-		history_paint();
-	}
-	///end
-
 	if (context_raw.paint2d) {
 		render_path_paint_set_plane_mesh();
 	}
 
-	if (render_path_paint_live_layer_drawn > 0) render_path_paint_live_layer_drawn--;
+	if (render_path_paint_live_layer_drawn > 0) {
+		render_path_paint_live_layer_drawn--;
+	}
 
 	if (config_raw.brush_live && context_raw.pdirty <= 0 && context_raw.ddirty <= 0 && context_raw.brush_time == 0) {
 		// Depth is unchanged, draw before gbuffer gets updated
@@ -709,7 +648,6 @@ function render_path_paint_draw() {
 			render_path_paint_dilated = false;
 		}
 
-		///if is_paint
 		if (context_raw.tool == workspace_tool_t.BAKE) {
 
 			///if (arm_direct3d12 || arm_vulkan || arm_metal)
@@ -798,11 +736,6 @@ function render_path_paint_draw() {
 		else { // Paint
 			render_path_paint_commands_paint();
 		}
-		///end
-
-		///if is_sculpt
-		render_path_paint_commands_paint();
-		///end
 	}
 
 	if (context_raw.brush_blend_dirty) {
@@ -921,39 +854,41 @@ function render_path_paint_restore_plane_mesh() {
 }
 
 function render_path_paint_bind_layers() {
-	///if is_paint
+	///if is_sculpt
+	render_path_sculpt_bind_layers();
+	return;
+	///end
+
 	let is_live: bool = config_raw.brush_live && render_path_paint_live_layer_drawn > 0;
 	let is_material_tool: bool = context_raw.tool == workspace_tool_t.MATERIAL;
 	if (is_live || is_material_tool) {
 		render_path_paint_use_live_layer(true);
 	}
-	///end
 
 	for (let i: i32 = 0; i < project_layers.length; ++i) {
 		let l: slot_layer_t = project_layers[i];
 		render_path_bind_target("texpaint" + l.id, "texpaint" + l.id);
 
-		///if is_paint
 		if (slot_layer_is_layer(l)) {
 			render_path_bind_target("texpaint_nor" + l.id, "texpaint_nor" + l.id);
 			render_path_bind_target("texpaint_pack" + l.id, "texpaint_pack" + l.id);
 		}
-		///end
 	}
 }
 
 function render_path_paint_unbind_layers() {
-	///if is_paint
+	///if is_sculpt
+	return;
+	///end
+
 	let is_live: bool = config_raw.brush_live && render_path_paint_live_layer_drawn > 0;
 	let is_material_tool: bool = context_raw.tool == workspace_tool_t.MATERIAL;
 	if (is_live || is_material_tool) {
 		render_path_paint_use_live_layer(false);
 	}
-	///end
 }
 
 function render_path_paint_dilate(base: bool, nor_pack: bool) {
-	///if is_paint
 	if (config_raw.dilate_radius > 0 && !context_raw.paint2d) {
 		util_uv_cache_dilate_map();
 		base_make_temp_img();
@@ -983,5 +918,4 @@ function render_path_paint_dilate(base: bool, nor_pack: bool) {
 			render_path_draw_shader("shader_datas/dilate_pass/dilate_pass");
 		}
 	}
-	///end
 }

+ 76 - 79
armorpaint/sources/slot_layer.ts

@@ -6,11 +6,9 @@ type slot_layer_t = {
 	visible?: bool;
 	parent?: slot_layer_t; // Group (for layers) or layer (for masks)
 	texpaint?: image_t; // Base or mask
-	////if is_paint
 	texpaint_nor?: image_t;
 	texpaint_pack?: image_t;
 	texpaint_preview?: image_t; // Layer preview
-	////end
 	mask_opacity?: f32; // Opacity mask
 	fill_layer?: slot_material_t;
 	show_panel?: bool;
@@ -119,7 +117,6 @@ function slot_layer_create(ext: string = "", type: layer_slot_type_t = layer_slo
 		///end
 	}
 
-	///if is_paint
 	else { // Mask
 		let id: i32 = (raw.id + 1);
 		raw.name = "Mask " + id;
@@ -137,7 +134,6 @@ function slot_layer_create(ext: string = "", type: layer_slot_type_t = layer_slo
 
 		raw.texpaint_preview = image_create_render_target(util_render_layer_preview_size, util_render_layer_preview_size, tex_format_t.RGBA32);
 	}
-	///end
 
 	return raw;
 }
@@ -187,17 +183,14 @@ function slot_layer_unload(raw: slot_layer_t) {
 	}
 
 	let _texpaint: image_t = raw.texpaint;
-	///if is_paint
 	let _texpaint_nor: image_t = raw.texpaint_nor;
 	let _texpaint_pack: image_t = raw.texpaint_pack;
 	let _texpaint_preview: image_t = raw.texpaint_preview;
-	///end
 
 	app_notify_on_next_frame(function (_texpaint: image_t) {
 		image_unload(_texpaint);
 	}, _texpaint);
 
-	///if is_paint
 	if (_texpaint_nor != null) {
 		app_notify_on_next_frame(function (_texpaint_nor: image_t) {
 			image_unload(_texpaint_nor);
@@ -208,16 +201,16 @@ function slot_layer_unload(raw: slot_layer_t) {
 			image_unload(_texpaint_pack);
 		}, _texpaint_pack);
 	}
-	image_unload(_texpaint_preview);
-	///end
+
+	if (_texpaint_preview != null) {
+		image_unload(_texpaint_preview);
+	}
 
 	map_delete(render_path_render_targets, "texpaint" + raw.ext);
-	///if is_paint
 	if (slot_layer_is_layer(raw)) {
 		map_delete(render_path_render_targets, "texpaint_nor" + raw.ext);
 		map_delete(render_path_render_targets, "texpaint_pack" + raw.ext);
 	}
-	///end
 }
 
 function slot_layer_swap(raw: slot_layer_t, other: slot_layer_t) {
@@ -230,14 +223,11 @@ function slot_layer_swap(raw: slot_layer_t, other: slot_layer_t) {
 		raw.texpaint = other.texpaint;
 		other.texpaint = _texpaint;
 
-		///if is_paint
 		let _texpaint_preview: image_t = raw.texpaint_preview;
 		raw.texpaint_preview = other.texpaint_preview;
 		other.texpaint_preview = _texpaint_preview;
-		///end
 	}
 
-	///if is_paint
 	if (slot_layer_is_layer(raw) && slot_layer_is_layer(other)) {
 		let nor0: render_target_t = map_get(render_path_render_targets, "texpaint_nor" + raw.ext);
 		nor0._image = other.texpaint_nor;
@@ -254,7 +244,6 @@ function slot_layer_swap(raw: slot_layer_t, other: slot_layer_t) {
 		other.texpaint_nor = _texpaint_nor;
 		other.texpaint_pack = _texpaint_pack;
 	}
-	///end
 }
 
 function slot_layer_clear(raw: slot_layer_t, base_color: i32 = 0x00000000, base_image: image_t = null, occlusion: f32 = 1.0, roughness: f32 = base_default_rough, metallic: f32 = 0.0) {
@@ -267,7 +256,6 @@ function slot_layer_clear(raw: slot_layer_t, base_color: i32 = 0x00000000, base_
 		g2_end();
 	}
 
-	///if is_paint
 	if (slot_layer_is_layer(raw)) {
 		g4_begin(raw.texpaint_nor);
 		g4_clear(color_from_floats(0.5, 0.5, 1.0, 0.0)); // Nor
@@ -276,7 +264,6 @@ function slot_layer_clear(raw: slot_layer_t, base_color: i32 = 0x00000000, base_
 		g4_clear(color_from_floats(occlusion, roughness, metallic, 0.0)); // Occ, rough, met
 		g4_end();
 	}
-	///end
 
 	context_raw.layer_preview_dirty = true;
 	context_raw.ddirty = 3;
@@ -333,18 +320,22 @@ function slot_layer_duplicate(raw: slot_layer_t): slot_layer_t {
 		g2_draw_image(raw.texpaint, 0, 0);
 		g2_set_pipeline(null);
 		g2_end();
-		///if is_paint
-		g2_begin(l.texpaint_nor);
-		g2_set_pipeline(base_pipe_copy);
-		g2_draw_image(raw.texpaint_nor, 0, 0);
-		g2_set_pipeline(null);
-		g2_end();
-		g2_begin(l.texpaint_pack);
-		g2_set_pipeline(base_pipe_copy);
-		g2_draw_image(raw.texpaint_pack, 0, 0);
-		g2_set_pipeline(null);
-		g2_end();
-		///end
+
+		if (l.texpaint_nor != null) {
+			g2_begin(l.texpaint_nor);
+			g2_set_pipeline(base_pipe_copy);
+			g2_draw_image(raw.texpaint_nor, 0, 0);
+			g2_set_pipeline(null);
+			g2_end();
+		}
+
+		if (l.texpaint_pack != null) {
+			g2_begin(l.texpaint_pack);
+			g2_set_pipeline(base_pipe_copy);
+			g2_draw_image(raw.texpaint_pack, 0, 0);
+			g2_set_pipeline(null);
+			g2_end();
+		}
 	}
 	else if (slot_layer_is_mask(raw)) {
 		g2_begin(l.texpaint);
@@ -354,14 +345,14 @@ function slot_layer_duplicate(raw: slot_layer_t): slot_layer_t {
 		g2_end();
 	}
 
-	///if is_paint
-	g2_begin(l.texpaint_preview);
-	g2_clear(0x00000000);
-	g2_set_pipeline(base_pipe_copy);
-	g2_draw_scaled_image(raw.texpaint_preview, 0, 0, raw.texpaint_preview.width, raw.texpaint_preview.height);
-	g2_set_pipeline(null);
-	g2_end();
-	///end
+	if (l.texpaint_preview != null) {
+		g2_begin(l.texpaint_preview);
+		g2_clear(0x00000000);
+		g2_set_pipeline(base_pipe_copy);
+		g2_draw_scaled_image(raw.texpaint_preview, 0, 0, raw.texpaint_preview.width, raw.texpaint_preview.height);
+		g2_set_pipeline(null);
+		g2_end();
+	}
 
 	l.visible = raw.visible;
 	l.mask_opacity = raw.mask_opacity;
@@ -396,7 +387,8 @@ function slot_layer_resize_and_set_bits(raw: slot_layer_t) {
 
 	if (slot_layer_is_layer(raw)) {
 		///if is_paint
-		let format: tex_format_t = base_bits_handle.position == texture_bits_t.BITS8  ? tex_format_t.RGBA32 :
+		let format: tex_format_t =
+			base_bits_handle.position == texture_bits_t.BITS8  ? tex_format_t.RGBA32 :
 			base_bits_handle.position == texture_bits_t.BITS16 ? tex_format_t.RGBA64 :
 			tex_format_t.RGBA128;
 		///end
@@ -413,47 +405,56 @@ function slot_layer_resize_and_set_bits(raw: slot_layer_t) {
 		g2_set_pipeline(null);
 		g2_end();
 
-		///if is_paint
 		let _texpaint_nor: image_t = raw.texpaint_nor;
-		let _texpaint_pack: image_t = raw.texpaint_pack;
-		raw.texpaint_nor = image_create_render_target(res_x, res_y, format);
-		raw.texpaint_pack = image_create_render_target(res_x, res_y, format);
+		if (raw.texpaint_nor != null) {
+			raw.texpaint_nor = image_create_render_target(res_x, res_y, format);
 
-		g2_begin(raw.texpaint_nor);
-		g2_set_pipeline(base_pipe_copy);
-		g2_draw_scaled_image(_texpaint_nor, 0, 0, res_x, res_y);
-		g2_set_pipeline(null);
-		g2_end();
+			g2_begin(raw.texpaint_nor);
+			g2_set_pipeline(base_pipe_copy);
+			g2_draw_scaled_image(_texpaint_nor, 0, 0, res_x, res_y);
+			g2_set_pipeline(null);
+			g2_end();
+		}
 
-		g2_begin(raw.texpaint_pack);
-		g2_set_pipeline(base_pipe_copy);
-		g2_draw_scaled_image(_texpaint_pack, 0, 0, res_x, res_y);
-		g2_set_pipeline(null);
-		g2_end();
-		///end
+		let _texpaint_pack: image_t = raw.texpaint_pack;
+		if (raw.texpaint_pack != null) {
+			raw.texpaint_pack = image_create_render_target(res_x, res_y, format);
+
+			g2_begin(raw.texpaint_pack);
+			g2_set_pipeline(base_pipe_copy);
+			g2_draw_scaled_image(_texpaint_pack, 0, 0, res_x, res_y);
+			g2_set_pipeline(null);
+			g2_end();
+		}
 
 		app_notify_on_next_frame(function (_texpaint: image_t) {
 			image_unload(_texpaint);
 		}, _texpaint);
 
-		///if is_paint
-		app_notify_on_next_frame(function (_texpaint_nor: image_t) {
-			image_unload(_texpaint_nor);
-		}, _texpaint_nor);
+		if (_texpaint_nor != null) {
+			app_notify_on_next_frame(function (_texpaint_nor: image_t) {
+				image_unload(_texpaint_nor);
+			}, _texpaint_nor);
+		}
 
-		app_notify_on_next_frame(function (_texpaint_pack: image_t) {
-			image_unload(_texpaint_pack);
-		}, _texpaint_pack);
-		///end
+		if (_texpaint_pack != null) {
+			app_notify_on_next_frame(function (_texpaint_pack: image_t) {
+				image_unload(_texpaint_pack);
+			}, _texpaint_pack);
+		}
 
 		let rt: render_target_t = map_get(rts, "texpaint" + raw.ext);
 		rt._image = raw.texpaint;
-		///if is_paint
-		let rt_nor: render_target_t = map_get(rts, "texpaint_nor" + raw.ext);
-		rt_nor._image = raw.texpaint_nor;
-		let rt_pack: render_target_t = map_get(rts, "texpaint_pack" + raw.ext);
-		rt_pack._image = raw.texpaint_pack;
-		///end
+
+		if (raw.texpaint_nor != null) {
+			let rt_nor: render_target_t = map_get(rts, "texpaint_nor" + raw.ext);
+			rt_nor._image = raw.texpaint_nor;
+		}
+
+		if (raw.texpaint_pack != null) {
+			let rt_pack: render_target_t = map_get(rts, "texpaint_pack" + raw.ext);
+			rt_pack._image = raw.texpaint_pack;
+		}
 	}
 	else if (slot_layer_is_mask(raw)) {
 		let _texpaint: image_t = raw.texpaint;
@@ -597,12 +598,11 @@ function slot_layer_get_object_mask(raw: slot_layer_t): i32 {
 }
 
 function slot_layer_is_layer(raw: slot_layer_t): bool {
-	///if is_paint
-	return raw.texpaint != null && raw.texpaint_nor != null;
-	///end
 	///if is_sculpt
 	return raw.texpaint != null;
 	///end
+
+	return raw.texpaint != null && raw.texpaint_nor != null;
 }
 
 function slot_layer_is_group(raw: slot_layer_t): bool {
@@ -622,30 +622,27 @@ function slot_layer_get_containing_group(raw: slot_layer_t): slot_layer_t {
 }
 
 function slot_layer_is_mask(raw: slot_layer_t): bool {
-	///if is_paint
-	return raw.texpaint != null && raw.texpaint_nor == null;
-	///end
 	///if is_sculpt
 	return false;
 	///end
+
+	return raw.texpaint != null && raw.texpaint_nor == null;
 }
 
 function slot_layer_is_group_mask(raw: slot_layer_t): bool {
-	///if is_paint
-	return raw.texpaint != null && raw.texpaint_nor == null && slot_layer_is_group(raw.parent);
-	///end
 	///if is_sculpt
 	return false;
 	///end
+
+	return raw.texpaint != null && raw.texpaint_nor == null && slot_layer_is_group(raw.parent);
 }
 
 function slot_layer_is_layer_mask(raw: slot_layer_t): bool {
-	///if is_paint
-	return raw.texpaint != null && raw.texpaint_nor == null && slot_layer_is_layer(raw.parent);
-	///end
 	///if is_sculpt
 	return false;
 	///end
+
+	return raw.texpaint != null && raw.texpaint_nor == null && slot_layer_is_layer(raw.parent);
 }
 
 function slot_layer_is_in_group(raw: slot_layer_t): bool {

+ 0 - 14
armorpaint/sources/tab_layers.ts

@@ -579,12 +579,7 @@ function tab_layers_draw_layer_highlight(l: slot_layer_t, mini: bool) {
 function tab_layers_handle_layer_icon_state(l: slot_layer_t, i: i32, state: ui_state_t, uix: f32, uiy: f32) {
 	let ui: ui_t = ui_base_ui;
 
-	///if is_paint
 	let texpaint_preview: image_t = l.texpaint_preview;
-	///end
-	///if is_sculpt
-	let texpaint_preview: image_t = l.texpaint;
-	///end
 
 	tab_layers_show_context_menu = false;
 
@@ -648,12 +643,7 @@ function tab_layers_draw_layer_icon(l: slot_layer_t, i: i32, uix: f32, uiy: f32,
 	}
 
 	if (!slot_layer_is_group(l)) {
-		///if is_paint
 		let texpaint_preview: image_t = l.texpaint_preview;
-		///end
-		///if is_sculpt
-		let texpaint_preview: image_t = l.texpaint;
-		///end
 
 		let icon: image_t = l.fill_layer == null ? texpaint_preview : l.fill_layer.image_icon;
 		if (l.fill_layer == null) {
@@ -776,10 +766,8 @@ function tab_layers_draw_layer_context_menu(l: slot_layer_t, mini: bool) {
 				});
 			}
 			else {
-				///if is_paint
 				context_raw.layers_export = export_mode_t.SELECTED;
 				box_export_show_textures();
-				///end
 			}
 		}
 
@@ -1021,7 +1009,6 @@ function tab_layers_draw_layer_context_menu(l: slot_layer_t, mini: bool) {
 }
 
 function tab_layers_make_mask_preview_rgba32(l: slot_layer_t) {
-	///if is_paint
 	if (context_raw.mask_preview_rgba32 == null) {
 		context_raw.mask_preview_rgba32 = image_create_render_target(util_render_layer_preview_size, util_render_layer_preview_size);
 	}
@@ -1039,7 +1026,6 @@ function tab_layers_make_mask_preview_rgba32(l: slot_layer_t) {
 			g2_set_pipeline(null);
 		});
 	}
-	///end
 }
 
 function tab_layers_delete_layer(l: slot_layer_t) {

+ 1 - 0
armorsculpt/project.js

@@ -9,6 +9,7 @@ project.add_project("../base");
 
 project.add_tsfiles("../armorpaint/sources");
 project.add_tsfiles("../armorpaint/sources/nodes");
+project.add_shaders("../armorpaint/shaders/*.glsl");
 project.add_tsfiles("sources");
 project.add_tsfiles("sources/nodes");
 project.add_shaders("shaders/*.glsl");

+ 0 - 0
armorsculpt/shaders/keepme


+ 0 - 11
armorsculpt/shaders/layer_invert.frag.glsl

@@ -1,11 +0,0 @@
-#version 450
-
-uniform sampler2D tex;
-
-in vec2 tex_coord;
-in vec4 color;
-out vec4 frag_color;
-
-void main() {
-	frag_color = vec4(1.0, 1.0, 1.0, 1.0) - textureLod(tex, tex_coord, 0).rgba * color;
-}

+ 0 - 119
armorsculpt/shaders/layer_merge.frag.glsl

@@ -1,119 +0,0 @@
-#version 450
-
-uniform sampler2D tex0;
-uniform sampler2D tex1;
-uniform sampler2D texmask;
-uniform sampler2D texa;
-uniform float opac;
-uniform int blending;
-
-in vec2 tex_coord;
-out vec4 frag_color;
-
-vec3 hsv_to_rgb(const vec3 c) {
-	const vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
-	vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
-	return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
-}
-
-vec3 rgb_to_hsv(const vec3 c) {
-	const vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
-	vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
-	vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
-	float d = q.x - min(q.w, q.y);
-	float e = 1.0e-10;
-	return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
-}
-
-void main() {
-	vec4 col0 = textureLod(tex0, tex_coord, 0);
-	vec4 cola = textureLod(texa, tex_coord, 0);
-	float str = col0.a * opac;
-	str *= textureLod(texmask, tex_coord, 0).r;
-	if (blending == -1) { // Merging _nor and _pack
-		vec4 col1 = textureLod(tex1, tex_coord, 0);
-		frag_color = vec4(mix(cola, col1, str));
-	}
-	else if (blending == -2) { // Merging _nor with normal blending
-		vec4 col1 = textureLod(tex1, tex_coord, 0);
-		// Whiteout blend
-		vec3 n1 = cola.rgb * vec3(2.0, 2.0, 2.0) - vec3(1.0, 1.0, 1.0);
-		vec3 n2 = mix(vec3(0.5, 0.5, 1.0), col1.rgb, str) * vec3(2.0, 2.0, 2.0) - vec3(1.0, 1.0, 1.0);
-		frag_color = vec4(normalize(vec3(n1.xy + n2.xy, n1.z * n2.z)) * vec3(0.5, 0.5, 0.5) + vec3(0.5, 0.5, 0.5), max(col1.a, cola.a));
-	}
-	else if (blending == -3) { // Merging _pack with height blending
-		vec4 col1 = textureLod(tex1, tex_coord, 0);
-		frag_color = vec4(mix(cola.rgb, col1.rgb, str), cola.a + col1.a);
-	}
-	else if (blending == -4) { // Merge _pack.height into _nor
-		float tex_step = 1.0 / textureSize(tex1, 0).x;
-		float height0 = textureLod(tex1, vec2(tex_coord.x - tex_step, tex_coord.y), 0.0).a;
-		float height1 = textureLod(tex1, vec2(tex_coord.x + tex_step, tex_coord.y), 0.0).a;
-		float height2 = textureLod(tex1, vec2(tex_coord.x, tex_coord.y - tex_step), 0.0).a;
-		float height3 = textureLod(tex1, vec2(tex_coord.x, tex_coord.y + tex_step), 0.0).a;
-		float height_dx = height0 - height1;
-		float height_dy = height2 - height3;
-		// Whiteout blend
-		vec3 n1 = col0.rgb * vec3(2.0, 2.0, 2.0) - vec3(1.0, 1.0, 1.0);
-		vec3 n2 = normalize(vec3(height_dx * 16.0, height_dy * 16.0, 1.0));
-		frag_color = vec4(normalize(vec3(n1.xy + n2.xy, n1.z * n2.z)) * vec3(0.5, 0.5, 0.5) + vec3(0.5, 0.5, 0.5), col0.a);
-	}
-	else if (blending == 0) { // Mix
-		frag_color = vec4(mix(cola.rgb, col0.rgb, str), max(col0.a, cola.a));
-	}
-	else if (blending == 1) { // Darken
-		frag_color = vec4(mix(cola.rgb, min(cola.rgb, col0.rgb), str), max(col0.a, cola.a));
-	}
-	else if (blending == 2) { // Multiply
-		frag_color = vec4(mix(cola.rgb, cola.rgb * col0.rgb, str), max(col0.a, cola.a));
-	}
-	else if (blending == 3) { // Burn
-		frag_color = vec4(mix(cola.rgb, vec3(1.0, 1.0, 1.0) - (vec3(1.0, 1.0, 1.0) - cola.rgb) / col0.rgb, str), max(col0.a, cola.a));
-	}
-	else if (blending == 4) { // Lighten
-		frag_color = vec4(max(cola.rgb, col0.rgb * str), max(col0.a, cola.a));
-	}
-	else if (blending == 5) { // Screen
-		frag_color = vec4((vec3(1.0, 1.0, 1.0) - (vec3(1.0 - str, 1.0 - str, 1.0 - str) + str * (vec3(1.0, 1.0, 1.0) - col0.rgb)) * (vec3(1.0, 1.0, 1.0) - cola.rgb)), max(col0.a, cola.a));
-	}
-	else if (blending == 6) { // Dodge
-		frag_color = vec4(mix(cola.rgb, cola.rgb / (vec3(1.0, 1.0, 1.0) - col0.rgb), str), max(col0.a, cola.a));
-	}
-	else if (blending == 7) { // Add
-		frag_color = vec4(mix(cola.rgb, cola.rgb + col0.rgb, str), max(col0.a, cola.a));
-	}
-	else if (blending == 8) { // Overlay
-		frag_color = vec4(mix(cola.rgb, vec3(
-			cola.r < 0.5 ? 2.0 * cola.r * col0.r : 1.0 - 2.0 * (1.0 - cola.r) * (1.0 - col0.r),
-			cola.g < 0.5 ? 2.0 * cola.g * col0.g : 1.0 - 2.0 * (1.0 - cola.g) * (1.0 - col0.g),
-			cola.b < 0.5 ? 2.0 * cola.b * col0.b : 1.0 - 2.0 * (1.0 - cola.b) * (1.0 - col0.b)
-		), str), max(col0.a, cola.a));
-	}
-	else if (blending == 9) { // Soft Light
-		frag_color = vec4(((1.0 - str) * cola.rgb + str * ((vec3(1.0, 1.0, 1.0) - cola.rgb) * col0.rgb * cola.rgb + cola.rgb * (vec3(1.0, 1.0, 1.0) - (vec3(1.0, 1.0, 1.0) - col0.rgb) * (vec3(1.0, 1.0, 1.0) - cola.rgb)))), max(col0.a, cola.a));
-	}
-	else if (blending == 10) { // Linear Light
-		frag_color = vec4((cola.rgb + str * (vec3(2.0, 2.0, 2.0) * (col0.rgb - vec3(0.5, 0.5, 0.5)))), max(col0.a, cola.a));
-	}
-	else if (blending == 11) { // Difference
-		frag_color = vec4(mix(cola.rgb, abs(cola.rgb - col0.rgb), str), max(col0.a, cola.a));
-	}
-	else if (blending == 12) { // Subtract
-		frag_color = vec4(mix(cola.rgb, cola.rgb - col0.rgb, str), max(col0.a, cola.a));
-	}
-	else if (blending == 13) { // Divide
-		frag_color = vec4(vec3(1.0 - str, 1.0 - str, 1.0 - str) * cola.rgb + vec3(str, str, str) * cola.rgb / col0.rgb, max(col0.a, cola.a));
-	}
-	else if (blending == 14) { // Hue
-		frag_color = vec4(mix(cola.rgb, hsv_to_rgb(vec3(rgb_to_hsv(col0.rgb).r, rgb_to_hsv(cola.rgb).g, rgb_to_hsv(cola.rgb).b)), str), max(col0.a, cola.a));
-	}
-	else if (blending == 15) { // Saturation
-		frag_color = vec4(mix(cola.rgb, hsv_to_rgb(vec3(rgb_to_hsv(cola.rgb).r, rgb_to_hsv(col0.rgb).g, rgb_to_hsv(cola.rgb).b)), str), max(col0.a, cola.a));
-	}
-	else if (blending == 16) { // Color
-		frag_color = vec4(mix(cola.rgb, hsv_to_rgb(vec3(rgb_to_hsv(col0.rgb).r, rgb_to_hsv(col0.rgb).g, rgb_to_hsv(cola.rgb).b)), str), max(col0.a, cola.a));
-	}
-	else { // Value
-		frag_color = vec4(mix(cola.rgb, hsv_to_rgb(vec3(rgb_to_hsv(cola.rgb).r, rgb_to_hsv(cola.rgb).g, rgb_to_hsv(col0.rgb).b)), str), max(col0.a, cola.a));
-	}
-}

+ 0 - 31
armorsculpt/shaders/layer_view.frag.glsl

@@ -1,31 +0,0 @@
-#version 450
-
-uniform sampler2D tex;
-uniform int channel;
-
-in vec2 tex_coord;
-in vec4 color;
-out vec4 frag_color;
-
-void main() {
-	if (channel == 1) {
-		frag_color = textureLod(tex, tex_coord, 0).rrra * color;
-	}
-	else if (channel == 2) {
-		frag_color = textureLod(tex, tex_coord, 0).ggga * color;
-	}
-	else if (channel == 3) {
-		frag_color = textureLod(tex, tex_coord, 0).bbba * color;
-	}
-	else if (channel == 4) {
-		frag_color = textureLod(tex, tex_coord, 0).aaaa * color;
-	}
-	else if (channel == 5) {
-		frag_color = textureLod(tex, tex_coord, 0).rgba * color;
-	}
-	else {
-		vec4 tex_sample = textureLod(tex, tex_coord, 0).rgba;
-		tex_sample.rgb *= tex_sample.a;
-		frag_color = tex_sample * color;
-	}
-}

+ 0 - 62
armorsculpt/shaders/mask_merge.frag.glsl

@@ -1,62 +0,0 @@
-#version 450
-
-uniform sampler2D tex0;
-uniform sampler2D texa;
-uniform float opac;
-uniform int blending;
-
-in vec2 tex_coord;
-out vec4 frag_color;
-
-void main() {
-	float col0 = textureLod(tex0, tex_coord, 0).r;
-	float cola = textureLod(texa, tex_coord, 0).r;
-	float str = opac;
-	float out_color = 0.0;
-	if (blending == 0) { // Mix
-		out_color = mix(cola, col0, str);
-	}
-	else if (blending == 1) { // Darken
-		out_color = mix(cola, min(cola, col0), str);
-	}
-	else if (blending == 2) { // Multiply
-		out_color = mix(cola, cola * col0, str);
-	}
-	else if (blending == 3) { // Burn
-		out_color = mix(cola, 1.0 - (1.0 - cola) / col0, str);
-	}
-	else if (blending == 4) { // Lighten
-		out_color = max(cola, col0 * str);
-	}
-	else if (blending == 5) { // Screen
-		out_color = (1.0 - ((1.0 - str) + str * (1.0 - col0)) * (1.0 - cola));
-	}
-	else if (blending == 6) { // Dodge
-		out_color = mix(cola, cola / (1.0 - col0), str);
-	}
-	else if (blending == 7) { // Add
-		out_color = mix(cola, cola + col0, str);
-	}
-	else if (blending == 8) { // Overlay
-		out_color = mix(cola, cola < 0.5 ? 2.0 * cola * col0 : 1.0 - 2.0 * (1.0 - cola) * (1.0 - col0), str);
-	}
-	else if (blending == 9) { // Soft Light
-		out_color = ((1.0 - str) * cola + str * ((1.0 - cola) * col0 * cola + cola * (1.0 - (1.0 - col0) * (1.0 - cola))));
-	}
-	else if (blending == 10) { // Linear Light
-		out_color = (cola + str * (2.0 * (col0 - 0.5)));
-	}
-	else if (blending == 11) { // Difference
-		out_color = mix(cola, abs(cola - col0), str);
-	}
-	else if (blending == 12) { // Subtract
-		out_color = mix(cola, cola - col0, str);
-	}
-	else if (blending == 13) { // Divide
-		out_color = (1.0 - str) * cola + str * cola / col0;
-	}
-	else { // Hue, Saturation, Color, Value
-		out_color = mix(cola, col0, str);
-	}
-	frag_color = vec4(out_color, out_color, out_color, 1.0);
-}

+ 0 - 24
armorsculpt/shaders/mesh_posnor.frag.glsl

@@ -1,24 +0,0 @@
-#version 450
-
-#include "../../base/shaders/std/gbuffer.glsl"
-
-in vec3 wnormal;
-in vec4 wvpposition;
-in vec4 prevwvpposition;
-out vec4 frag_color[3];
-
-void main() {
-	vec3 n = normalize(wnormal);
-	vec3 basecol = vec3(0.8, 0.8, 0.8);
-	float roughness = 0.25;
-	float metallic = 0.0;
-	float occlusion = 1.0;
-	n /= (abs(n.x) + abs(n.y) + abs(n.z));
-	n.xy = n.z >= 0.0 ? n.xy : octahedron_wrap(n.xy);
-	uint matid = 0;
-	frag_color[0] = vec4(n.xy, roughness, pack_f32_i16(metallic, matid));
-	frag_color[1] = vec4(basecol, occlusion);
-	vec2 posa = (wvpposition.xy / wvpposition.w) * 0.5 + 0.5;
-	vec2 posb = (prevwvpposition.xy / prevwvpposition.w) * 0.5 + 0.5;
-	frag_color[2].rg = vec2(posa - posb);
-}

+ 0 - 19
armorsculpt/shaders/mesh_posnor.vert.glsl

@@ -1,19 +0,0 @@
-#version 450
-
-uniform mat3 N;
-uniform mat4 WVP;
-uniform mat4 prevWVP;
-
-in vec4 pos;
-in vec2 nor;
-out vec3 wnormal;
-out vec4 wvpposition;
-out vec4 prevwvpposition;
-
-void main() {
-	vec4 spos = vec4(pos.xyz, 1.0);
-	wnormal = normalize(mul(vec3(nor.xy, pos.w), N));
-	gl_Position = mul(spos, WVP);
-	wvpposition = gl_Position;
-	prevwvpposition = mul(spos, prevWVP);
-}

+ 89 - 0
armorsculpt/sources/render_path_sculpt.ts

@@ -0,0 +1,89 @@
+
+function render_path_sculpt_commands() {
+    let tid: i32 = context_raw.layer.id;
+    let texpaint: string = "texpaint" + tid;
+    render_path_set_target("texpaint_blend1");
+    render_path_bind_target("texpaint_blend0", "tex");
+    render_path_draw_shader("shader_datas/copy_pass/copyR8_pass");
+    let additional: string[] = ["texpaint_blend0"];
+    render_path_set_target(texpaint, additional);
+    render_path_bind_target("gbufferD_undo", "gbufferD");
+    if ((context_raw.xray || config_raw.brush_angle_reject) && config_raw.brush_3d) {
+        render_path_bind_target("gbuffer0", "gbuffer0");
+    }
+    render_path_bind_target("texpaint_blend1", "paintmask");
+
+    // Read texcoords from gbuffer
+    let read_tc: bool = (context_raw.tool == workspace_tool_t.FILL && context_raw.fill_type_handle.position == fill_type_t.FACE) ||
+                            context_raw.tool == workspace_tool_t.CLONE ||
+                            context_raw.tool == workspace_tool_t.BLUR ||
+                            context_raw.tool == workspace_tool_t.SMUDGE;
+    if (read_tc) {
+        render_path_bind_target("gbuffer2", "gbuffer2");
+    }
+    render_path_bind_target("gbuffer0_undo", "gbuffer0_undo");
+
+    let material_contexts: material_context_t[] = [];
+    let shader_contexts: shader_context_t[] = [];
+    let mats: material_data_t[] = project_paint_objects[0].materials;
+    mesh_object_get_contexts(project_paint_objects[0], "paint", mats, material_contexts, shader_contexts);
+
+    let cc_context: shader_context_t = shader_contexts[0];
+    if (const_data_screen_aligned_vb == null) {
+        const_data_create_screen_aligned_data();
+    }
+    g4_set_pipeline(cc_context._.pipe_state);
+    uniforms_set_context_consts(cc_context,_render_path_bind_params);
+    uniforms_set_obj_consts(cc_context, project_paint_objects[0].base);
+    uniforms_set_material_consts(cc_context, material_contexts[0]);
+    g4_set_vertex_buffer(const_data_screen_aligned_vb);
+    g4_set_index_buffer(const_data_screen_aligned_ib);
+    g4_draw();
+    render_path_end();
+}
+
+function render_path_sculpt_begin() {
+
+    if (!render_path_paint_paint_enabled()) {
+        return;
+    }
+
+    render_path_paint_push_undo_last = history_push_undo;
+
+    if (history_push_undo && history_undo_layers != null) {
+        history_paint();
+
+        render_path_set_target("gbuffer0_undo");
+        render_path_bind_target("gbuffer0", "tex");
+        render_path_draw_shader("shader_datas/copy_pass/copy_pass");
+
+        render_path_set_target("gbufferD_undo");
+        render_path_bind_target("_main", "tex");
+        render_path_draw_shader("shader_datas/copy_pass/copy_pass");
+    }
+
+    if (history_push_undo2 && history_undo_layers != null) {
+        history_paint();
+    }
+
+    if (context_raw.paint2d) {
+        render_path_paint_set_plane_mesh();
+    }
+
+    if (render_path_paint_live_layer_drawn > 0) {
+        render_path_paint_live_layer_drawn--;
+    }
+
+    if (config_raw.brush_live && context_raw.pdirty <= 0 && context_raw.ddirty <= 0 && context_raw.brush_time == 0) {
+        // Depth is unchanged, draw before gbuffer gets updated
+        render_path_paint_commands_live_brush();
+    }
+}
+
+function render_path_sculpt_bind_layers() {
+
+	for (let i: i32 = 0; i < project_layers.length; ++i) {
+		let l: slot_layer_t = project_layers[i];
+		render_path_bind_target("texpaint" + l.id, "texpaint" + l.id);
+	}
+}

+ 0 - 29
base/sources/args.ts

@@ -27,8 +27,6 @@ function args_parse() {
 			else if (current_arg == "--b" || current_arg == "--background") {
 				args_background = true;
 			}
-
-			///if (is_paint || is_lab)
 			else if (path_is_texture(current_arg)) {
 				args_asset_path = current_arg;
 			}
@@ -41,9 +39,6 @@ function args_parse() {
 				++i;
 				args_export_textures_path = iron_get_arg(i);
 			}
-			///end
-
-			///if (is_paint || is_sculpt)
 			else if (current_arg == "--reload-mesh") {
 				args_reimport_mesh = true;
 			}
@@ -55,15 +50,11 @@ function args_parse() {
 			else if (path_is_mesh(current_arg) || (i > 1 && !starts_with(current_arg, "-") && path_is_folder(current_arg))) {
 				args_asset_path = current_arg;
 			}
-			///end
-
-			///if is_paint
 			else if (current_arg == "--export-material" && (i + 1) <= iron_get_arg_count()) {
 				args_export_material = true;
 				++i;
 				args_export_material_path = iron_get_arg(i);
 			}
-			///end
 
 			++i;
 		}
@@ -78,19 +69,14 @@ function args_run() {
 			}
 			else if (args_asset_path != "") {
 				import_asset_run(args_asset_path, -1, -1, false);
-				///if is_paint
 				if (path_is_texture(args_asset_path)) {
 					ui_base_show_2d_view(view_2d_type_t.ASSET);
 				}
-				///end
 			}
-			///if (is_paint || is_sculpt)
 			else if (args_reimport_mesh) {
 				project_reimport_mesh();
 			}
-			///end
 
-			///if (is_paint || is_lab)
 			if (args_export_textures) {
 				if (args_export_textures_type == "png" ||
 					args_export_textures_type == "jpg" ||
@@ -99,31 +85,21 @@ function args_run() {
 					if (path_is_folder(args_export_textures_path)) {
 						// Applying the correct format type from args
 						if (args_export_textures_type == "png") {
-							///if is_paint
 							base_bits_handle.position = texture_bits_t.BITS8;
-							///end
 							context_raw.format_type = texture_ldr_format_t.PNG;
 						}
 						else if (args_export_textures_type == "jpg") {
-							///if is_paint
 							base_bits_handle.position = texture_bits_t.BITS8;
-							///end
 							context_raw.format_type = texture_ldr_format_t.JPG;
 						}
 						else if (args_export_textures_type == "exr16") {
-							///if is_paint
 							base_bits_handle.position = texture_bits_t.BITS16;
-							///end
 						}
 						else if (args_export_textures_type == "exr32") {
-							///if is_paint
 							base_bits_handle.position = texture_bits_t.BITS32;
-							///end
 						}
 
-						///if is_paint
 						context_raw.layers_export = export_mode_t.VISIBLE;
-						///end
 
 						// Get export preset and apply the correct one from args
 						box_export_files = file_read_directory(path_data() + path_sep + "export_presets");
@@ -157,9 +133,7 @@ function args_run() {
 					iron_log(tr("Invalid texture type"));
 				}
 			}
-			///end
 
-			///if (is_paint || is_sculpt)
 			else if (args_export_mesh) {
 				if (path_is_folder(args_export_mesh_path)) {
 					let f: string = ui_files_filename;
@@ -172,14 +146,11 @@ function args_run() {
 					iron_log(tr("Invalid export directory"));
 				}
 			}
-			///end
 
-			///if is_paint
 			else if (args_export_material) {
 				context_raw.write_icon_on_export = true;
 				export_arm_run_material(args_export_material_path);
 			}
-			///end
 
 			if (args_background) {
 				sys_stop();

+ 1 - 2
base/sources/base.ts

@@ -63,7 +63,6 @@ let base_opac_merge_mask: kinc_const_loc_t;
 let base_blending_merge_mask: kinc_const_loc_t;
 let base_temp_mask_image: image_t = null;
 
-///if is_lab
 let base_pipe_copy_r: pipeline_t;
 let base_pipe_copy_g: pipeline_t;
 let base_pipe_copy_b: pipeline_t;
@@ -72,7 +71,7 @@ let base_pipe_copy_a_tex: kinc_tex_unit_t;
 let base_pipe_inpaint_preview: pipeline_t;
 let base_tex0_inpaint_preview: kinc_tex_unit_t;
 let base_texa_inpaint_preview: kinc_tex_unit_t;
-///end
+
 let base_temp_image: image_t = null;
 let base_expa: image_t = null;
 let base_expb: image_t = null;

+ 0 - 2
base/sources/box_export.ts

@@ -3,12 +3,10 @@ let box_export_htab: ui_handle_t = ui_handle_create();
 let box_export_files: string[] = null;
 let box_export_mesh_handle: ui_handle_t = ui_handle_create();
 
-///if (is_paint || is_lab)
 let box_export_hpreset: ui_handle_t = ui_handle_create();
 let box_export_preset: export_preset_t = null;
 let box_export_channels: string[] = ["base_r", "base_g", "base_b", "height", "metal", "nor_r", "nor_g", "nor_g_directx", "nor_b", "occ", "opac", "rough", "smooth", "emis", "subs", "0.0", "1.0"];
 let box_export_color_spaces: string[] = ["linear", "srgb"];
-///end
 
 ///if (is_paint || is_lab)
 function box_export_show_textures() {

+ 8 - 1
base/sources/export_arm.ts

@@ -265,9 +265,16 @@ function export_arm_export_node(n: ui_node_t, assets: asset_t[] = null) {
 	// }
 }
 
+///if is_lab
+function export_arm_run_material(path: string) {
+}
+///end
+
 ///if (is_paint || is_sculpt)
 function export_arm_run_material(path: string) {
-	if (!ends_with(path, ".arm")) path += ".arm";
+	if (!ends_with(path, ".arm")) {
+		path += ".arm";
+	}
 	let mnodes: ui_node_canvas_t[] = [];
 	let mgroups: ui_node_canvas_t[] = null;
 	let m: slot_material_t = context_raw.material;

+ 3 - 15
base/sources/export_texture.ts

@@ -1,6 +1,4 @@
 
-///if (is_paint || is_lab)
-
 let export_texture_gamma: f32 = 1.0 / 2.2;
 
 function export_texture_run(path: string, bake_material: bool = false) {
@@ -154,13 +152,7 @@ function export_texture_run_bake_material(path: string) {
 }
 ///end
 
-///if is_paint
 function export_texture_run_layers(path: string, layers: slot_layer_t[], object_name: string = "", bake_material: bool = false) {
-///end
-
-///if is_lab
-function export_texture_run_layers(path: string, layers: any[], object_name: string = "") {
-///end
 
 	let texture_size_x: i32 = config_get_texture_res_x();
 	let texture_size_y: i32 = config_get_texture_res_y();
@@ -328,16 +320,14 @@ function export_texture_run_layers(path: string, layers: any[], object_name: str
 	///end
 	///end
 
-	///if is_paint
 	let texpaint: image_t = base_expa;
 	let texpaint_nor: image_t = base_expb;
 	let texpaint_pack: image_t = base_expc;
-	///end
 
 	///if is_lab
-	let texpaint: image_t = brush_output_node_inst.texpaint;
-	let texpaint_nor: image_t = brush_output_node_inst.texpaint_nor;
-	let texpaint_pack: image_t = brush_output_node_inst.texpaint_pack;
+	texpaint = brush_output_node_inst.texpaint;
+	texpaint_nor = brush_output_node_inst.texpaint_nor;
+	texpaint_pack = brush_output_node_inst.texpaint_pack;
 	///end
 
 	let pixpaint: buffer_t = null;
@@ -566,5 +556,3 @@ type export_preset_texture_t = {
 	channels?: string[];
 	color_space?: string;
 };
-
-///end

+ 1 - 1
base/sources/project.ts

@@ -19,7 +19,7 @@ let project_atlas_names: string[] = null;
 ///end
 ///if is_lab
 let project_material_data: material_data_t = null; ////
-let project_materials: any[] = null; ////
+let project_materials: slot_material_t[] = null; ////
 let project_nodes: ui_nodes_t;
 let project_canvas: ui_node_canvas_t;
 let project_default_canvas: buffer_t = null;

+ 0 - 4
base/sources/ui_toolbar.ts

@@ -1,6 +1,4 @@
 
-///if (is_paint || is_sculpt)
-
 let ui_toolbar_default_w: i32 = 36;
 
 let ui_toolbar_handle: ui_handle_t = ui_handle_create();
@@ -236,5 +234,3 @@ function ui_toolbar_draw_highlight() {
 	g2_set_color(ui.ops.theme.HIGHLIGHT_COL);
 	ui_draw_rect(true, ui._x + -1,  ui._y + 2, size + 2, size + 2);
 }
-
-///end

+ 10 - 22
base/sources/uniforms_ext.ts

@@ -107,11 +107,9 @@ function uniforms_ext_f32_link(object: object_t, mat: material_data_t, link: str
 	else if (link == "_object_id") {
 		return array_index_of(project_paint_objects, object.ext);
 	}
-	///if is_paint
 	else if (link == "_dilate_radius") {
 		return util_uv_dilatemap != null ? config_raw.dilate_radius : 0.0;
 	}
-	///end
 	else if (link == "_decal_layer_dim") {
 		let sc: vec4_t = mat4_get_scale(context_raw.layer.decal_mat);
 		return sc.z * 0.5;
@@ -324,37 +322,31 @@ function uniforms_ext_mat4_link(object: object_t, mat: material_data_t, link: st
 
 function uniforms_ext_tex_link(object: object_t, mat: material_data_t, link: string): image_t {
 	if (link == "_texpaint_undo") {
-		///if (is_paint || is_sculpt)
+		///if is_lab
+		return null;
+		///end
+
 		let i: i32 = history_undo_i - 1 < 0 ? config_raw.undo_steps - 1 : history_undo_i - 1;
 		let rt: render_target_t = map_get(render_path_render_targets, "texpaint_undo" + i);
 		return rt._image;
-		///end
-
+	}
+	else if (link == "_texpaint_nor_undo") {
 		///if is_lab
 		return null;
 		///end
-	}
-	else if (link == "_texpaint_nor_undo") {
-		///if (is_paint || is_sculpt)
+
 		let i: i32 = history_undo_i - 1 < 0 ? config_raw.undo_steps - 1 : history_undo_i - 1;
 		let rt: render_target_t = map_get(render_path_render_targets, "texpaint_nor_undo" + i);
 		return rt._image;
-		///end
-
+	}
+	else if (link == "_texpaint_pack_undo") {
 		///if is_lab
 		return null;
 		///end
-	}
-	else if (link == "_texpaint_pack_undo") {
-		///if (is_paint || is_sculpt)
+
 		let i: i32 = history_undo_i - 1 < 0 ? config_raw.undo_steps - 1 : history_undo_i - 1;
 		let rt: render_target_t = map_get(render_path_render_targets, "texpaint_pack_undo" + i);
 		return rt._image;
-		///end
-
-		///if is_lab
-		return null;
-		///end
 	}
 	else if (link == "_ltc_mat") {
 		if (const_data_ltc_mat_tex == null) {
@@ -368,7 +360,6 @@ function uniforms_ext_tex_link(object: object_t, mat: material_data_t, link: str
 		}
 		return const_data_ltc_mag_tex;
 	}
-	///if (is_paint || is_sculpt)
 	else if (link == "_texcolorid") {
 		if (project_assets.length == 0) {
 			let rt: render_target_t = map_get(render_path_render_targets, "empty_white");
@@ -391,9 +382,7 @@ function uniforms_ext_tex_link(object: object_t, mat: material_data_t, link: str
 		let rt: render_target_t = map_get(render_path_render_targets, "texparticle");
 		return rt._image;
 	}
-	///end
 
-	///if is_paint
 	else if (link == "_texuvmap") {
 		if (!util_uv_uvmap_cached) {
 			app_notify_on_init(util_uv_cache_uv_map);
@@ -419,7 +408,6 @@ function uniforms_ext_tex_link(object: object_t, mat: material_data_t, link: str
 	else if (link == "_texdilatemap") {
 		return util_uv_dilatemap;
 	}
-	///end
 
 	if (starts_with(link, "_texpaint_pack_vert")) {
 		let tid: string = substring(link, link.length - 1, link.length);

+ 0 - 4
base/sources/util_render.ts

@@ -1,6 +1,4 @@
 
-///if (is_paint || is_sculpt)
-
 let util_render_material_preview_size: i32 = 256;
 let util_render_decal_preview_size: i32 = 512;
 let util_render_layer_preview_size: i32 = 200;
@@ -463,5 +461,3 @@ function util_render_create_screen_aligned_full_data() {
 	}
 	g4_index_buffer_unlock(util_render_screen_aligned_full_ib);
 }
-
-///end

+ 0 - 4
base/sources/util_uv.ts

@@ -1,6 +1,4 @@
 
-///if (is_paint || is_sculpt)
-
 let util_uv_uvmap: image_t = null;
 let util_uv_uvmap_cached: bool = false;
 let util_uv_trianglemap: image_t = null;
@@ -204,5 +202,3 @@ type coord_t = {
 	x?: i32;
 	y?: i32;
 }
-
-///end