Skip to content

Commit

Permalink
minits fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
luboslenco committed Jul 24, 2024
1 parent 2cba247 commit 92b9dac
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 31 deletions.
9 changes: 5 additions & 4 deletions armorlab/sources/render_path_paint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,12 @@ function render_path_paint_draw_cursor(mx: f32, my: f32, radius: f32, tint_r: f3
g4_set_float3(base_cursor_camera_right, right.x, right.y, right.z);
g4_set_float3(base_cursor_tint, tint_r, tint_g, tint_b);
g4_set_mat(base_cursor_vp, scene_camera.vp);
let helpMat = mat4_identity();
mat4_get_inv(helpMat, scene_camera.vp);
g4_set_mat(base_cursor_inv_vp, helpMat);
let help_mat = mat4_identity();
mat4_get_inv(help_mat, scene_camera.vp);
g4_set_mat(base_cursor_inv_vp, help_mat);
///if (krom_metal || krom_vulkan)
g4_set_vertex_buffer(mesh_data_get(geom, [{name: "tex", data: "short2norm"}]));
let vs: vertex_structure_t[] = [{name: "tex", data: "short2norm"}];
g4_set_vertex_buffer(mesh_data_get(geom, vs));
///else
g4_set_vertex_buffer(geom._vertexBuffer);
///end
Expand Down
2 changes: 1 addition & 1 deletion armorpaint/sources/render_path_paint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ function render_path_paint_draw_cursor(mx: f32, my: f32, radius: f32, tint_r: f3
mat4_get_inv(help_mat, scene_camera.vp);
g4_set_mat(base_cursor_inv_vp, help_mat);
///if (krom_metal || krom_vulkan)
let vs: vertex_element_t = [
let vs: vertex_element_t[] = [
{
name: "tex",
data: "short2norm"
Expand Down
21 changes: 11 additions & 10 deletions base/sources/export_arm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,10 +325,11 @@ function export_arm_run_material(path: string) {
let micons: buffer_t[] = null;
if (!is_cloud) {
///if (krom_metal || krom_vulkan)
micons = [lz4_encode(export_arm_bgra_swap(image_get_pixels(m.image)))];
let buf: buffer_t = lz4_encode(export_arm_bgra_swap(image_get_pixels(m.image)));
///else
micons = [lz4_encode(image_get_pixels(m.image))];
let buf: buffer_t = lz4_encode(image_get_pixels(m.image));
///end
micons = [buf];
}

let raw: project_format_t = {
Expand Down Expand Up @@ -357,12 +358,11 @@ function export_arm_run_material(path: string) {
///end

///if (krom_metal || krom_vulkan)
function export_arm_bgra_swap(buffer: buffer_t) {
let view: buffer_view_t = buffer_view_create(buffer);
for (let i: i32 = 0; i < math_floor(buffer_size(buffer) / 4); ++i) {
let r: i32 = buffer_view_get_u8(view, i * 4);
buffer_view_set_u8(view, i * 4, buffer_view_get_u8(view, i * 4 + 2));
buffer_view_set_u8(view, i * 4 + 2, r);
function export_arm_bgra_swap(buffer: buffer_t): buffer_t {
for (let i: i32 = 0; i < math_floor((buffer.length) / 4); ++i) {
let r: i32 = buffer[i * 4];
buffer[i * 4] = buffer[i * 4 + 2];
buffer[i * 4 + 2] = r;
}
return buffer;
}
Expand Down Expand Up @@ -396,10 +396,11 @@ function export_arm_run_brush(path: string) {
let bicons: buffer_t[] = null;
if (!is_cloud) {
///if (krom_metal || krom_vulkan)
bicons = [lz4_encode(export_arm_bgra_swap(image_get_pixels(b.image)))];
let buf: buffer_t = lz4_encode(export_arm_bgra_swap(image_get_pixels(b.image)));
///else
bicons = [lz4_encode(image_get_pixels(b.image))];
let buf: buffer_t = lz4_encode(image_get_pixels(b.image));
///end
bicons = [buf];
}

let raw: project_format_t = {
Expand Down
6 changes: 3 additions & 3 deletions base/sources/render_path_raytrace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function render_path_raytrace_commands(use_live_layer: bool) {
let bnoise_scramble: image_t = map_get(scene_embedded, "bnoise_scramble.k");
let bnoise_rank: image_t = map_get(scene_embedded, "bnoise_rank.k");

let l: any = base_flatten(true);
let l: slot_layer_t = base_flatten(true);
krom_raytrace_set_textures(l.texpaint, l.texpaint_nor, l.texpaint_pack, saved_envmap.texture_, bnoise_sobol.texture_, bnoise_scramble.texture_, bnoise_rank.texture_);
}

Expand Down Expand Up @@ -117,8 +117,8 @@ function render_path_raytrace_commands(use_live_layer: bool) {
render_path_raytrace_f32a[22] *= scene_meshes[0].data.scale_tex;
///end

let framebuffer: image_t = map_get(render_path_render_targets, "buf")._image;
krom_raytrace_dispatch_rays(framebuffer.render_target_, render_path_raytrace_f32a.buffer);
let framebuffer: render_target_t = map_get(render_path_render_targets, "buf");
krom_raytrace_dispatch_rays(framebuffer._image.render_target_, render_path_raytrace_f32a);

if (context_raw.ddirty == 1 || context_raw.pdirty == 1) {
///if krom_metal
Expand Down
30 changes: 18 additions & 12 deletions base/sources/render_path_raytrace_bake.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@ function render_path_raytrace_bake_commands(parse_paint_material: (b?: bool)=>vo
render_path_raytrace_bake_last_layer = null;

if (map_get(render_path_render_targets, "baketex0") != null) {
image_unload(map_get(render_path_render_targets, "baketex0")._image);
image_unload(map_get(render_path_render_targets, "baketex1")._image);
image_unload(map_get(render_path_render_targets, "baketex2")._image);
let baketex0: render_target_t = map_get(render_path_render_targets, "baketex0");
let baketex1: render_target_t = map_get(render_path_render_targets, "baketex1");
let baketex2: render_target_t = map_get(render_path_render_targets, "baketex2");
image_unload(baketex0._image);
image_unload(baketex1._image);
image_unload(baketex2._image);
}

{
Expand Down Expand Up @@ -52,10 +55,11 @@ function render_path_raytrace_bake_commands(parse_paint_material: (b?: bool)=>vo

let _bake_type: bake_type_t = context_raw.bake_type;
context_raw.bake_type = bake_type_t.INIT;
parse_paint_material();
parse_paint_material(true);
render_path_set_target("baketex0");
render_path_clear_target(0x00000000); // Pixels with alpha of 0.0 are skipped during raytracing
render_path_set_target("baketex0", ["baketex1"]);
let additional: string[] = ["baketex1"];
render_path_set_target("baketex0", additional);
render_path_draw_meshes("paint");
context_raw.bake_type = _bake_type;
app_notify_on_next_frame(parse_paint_material);
Expand All @@ -75,13 +79,13 @@ function render_path_raytrace_bake_commands(parse_paint_material: (b?: bool)=>vo
render_path_raytrace_last_envmap = saved_envmap;
render_path_raytrace_bake_last_layer = context_raw.layer.texpaint;

let baketex0: image_t = map_get(render_path_render_targets, "baketex0")._image;
let baketex1: image_t = map_get(render_path_render_targets, "baketex1")._image;
let baketex0: render_target_t = map_get(render_path_render_targets, "baketex0");
let baketex1: render_target_t = map_get(render_path_render_targets, "baketex1");
let texpaint_undo: render_target_t = map_get(render_path_render_targets, "texpaint_undo" + history_undo_i);
let bnoise_sobol: image_t = map_get(scene_embedded, "bnoise_sobol.k");
let bnoise_scramble: image_t = map_get(scene_embedded, "bnoise_scramble.k");
let bnoise_rank: image_t = map_get(scene_embedded, "bnoise_rank.k");
let texpaint_undo: image_t = map_get(render_path_render_targets, "texpaint_undo" + history_undo_i)._image;
krom_raytrace_set_textures(baketex0, baketex1, texpaint_undo, saved_envmap.texture_, bnoise_sobol.texture_, bnoise_scramble.texture_, bnoise_rank.texture_);
krom_raytrace_set_textures(baketex0._image, baketex1._image, texpaint_undo._image, saved_envmap.texture_, bnoise_sobol.texture_, bnoise_scramble.texture_, bnoise_rank.texture_);
}

if (context_raw.brush_time > 0) {
Expand All @@ -99,10 +103,12 @@ function render_path_raytrace_bake_commands(parse_paint_material: (b?: bool)=>vo
f32a[5] = context_raw.bake_up_axis;
f32a[6] = context_raw.envmap_angle;

let framebuffer: image_t = map_get(render_path_render_targets, "baketex2")._image;
krom_raytrace_dispatch_rays(framebuffer.render_target_, f32a.buffer);
let framebuffer: render_target_t = map_get(render_path_render_targets, "baketex2");
krom_raytrace_dispatch_rays(framebuffer._image.render_target_, f32a);

render_path_set_target("texpaint" + context_raw.layer.id);
let id: i32 = context_raw.layer.id;
let texpaint_id: string = "texpaint" + id;
render_path_set_target(texpaint_id);
render_path_bind_target("baketex2", "tex");
render_path_draw_shader("shader_datas/copy_pass/copy_pass");

Expand Down
8 changes: 7 additions & 1 deletion base/sources/util_uv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,13 @@ function util_uv_cache_dilate_map() {
g4_clear(0x00000000);
g4_set_pipeline(util_uv_pipe_dilate);
///if (krom_metal || krom_vulkan)
g4_set_vertex_buffer(mesh_data_get(geom, [{name: "tex", data: "short2norm"}]));
let vs: vertex_element_t[] = [
{
name: "tex",
data: "short2norm"
}
];
g4_set_vertex_buffer(mesh_data_get(geom, vs));
///else
g4_set_vertex_buffer(geom._.vertex_buffer);
///end
Expand Down

0 comments on commit 92b9dac

Please sign in to comment.