From 2fffe5c58f26fd0f57a6019bca16963d9f8ffc7c Mon Sep 17 00:00:00 2001 From: luboslenco Date: Thu, 8 Feb 2024 21:05:19 +0100 Subject: [PATCH] Refactor --- armorlab/Sources/nodes/InpaintNode.ts | 2 +- armorlab/Sources/nodes/RGBNode.ts | 2 +- armorlab/Sources/nodes/TilingNode.ts | 2 +- armorpaint/Sources/MakeMaterial.ts | 2 +- armorpaint/Sources/SlotLayer.ts | 16 ++-- armorsculpt/Sources/ImportMesh.ts | 2 +- base/Sources/Base.ts | 106 +++++++++++++------------- base/Sources/Config.ts | 10 +-- base/Sources/ImportArm.ts | 8 +- base/Sources/ImportEnvmap.ts | 12 +-- base/Sources/LineDraw.ts | 18 ++--- base/Sources/MakeVoxel.ts | 8 +- base/Sources/Project.ts | 2 +- base/Sources/RenderPathBase.ts | 9 --- base/Sources/RenderPathDeferred.ts | 4 +- base/Sources/TabBrowser.ts | 4 +- base/Sources/UIBase.ts | 6 +- base/Sources/UIBox.ts | 8 +- base/Sources/UIFiles.ts | 6 +- base/Sources/UINodes.ts | 12 +-- base/Sources/UIView2D.ts | 14 ++-- base/Sources/UniformsExt.ts | 18 +++-- base/Sources/UtilRender.ts | 16 ++-- base/Sources/UtilUV.ts | 16 ++-- base/Sources/nodes/ColorNode.ts | 2 +- base/Sources/nodes/FloatNode.ts | 2 +- base/Sources/nodes/VectorNode.ts | 2 +- 27 files changed, 152 insertions(+), 157 deletions(-) diff --git a/armorlab/Sources/nodes/InpaintNode.ts b/armorlab/Sources/nodes/InpaintNode.ts index 0a801214..801a2a30 100644 --- a/armorlab/Sources/nodes/InpaintNode.ts +++ b/armorlab/Sources/nodes/InpaintNode.ts @@ -23,7 +23,7 @@ class InpaintNode extends LogicNode { } if (InpaintNode.mask == null) { - InpaintNode.mask = image_create_render_target(Config.getTextureResX(), Config.getTextureResY(), TextureFormat.R8); + InpaintNode.mask = image_create_render_target(Config.getTextureResX(), Config.getTextureResY(), tex_format_t.R8); Base.notifyOnNextFrame(() => { g4_begin(InpaintNode.mask); g4_clear(color_from_floats(1.0, 1.0, 1.0, 1.0)); diff --git a/armorlab/Sources/nodes/RGBNode.ts b/armorlab/Sources/nodes/RGBNode.ts index 3f81ca13..825dcf4f 100644 --- a/armorlab/Sources/nodes/RGBNode.ts +++ b/armorlab/Sources/nodes/RGBNode.ts @@ -21,7 +21,7 @@ class RGBNode extends LogicNode { f32a[1] = default_value[1]; f32a[2] = default_value[2]; f32a[3] = default_value[3]; - this.image = image_from_bytes(f32a.buffer, 1, 1, TextureFormat.RGBA128); + this.image = image_from_bytes(f32a.buffer, 1, 1, tex_format_t.RGBA128); done(this.image); } diff --git a/armorlab/Sources/nodes/TilingNode.ts b/armorlab/Sources/nodes/TilingNode.ts index 53fa8efd..f81599a0 100644 --- a/armorlab/Sources/nodes/TilingNode.ts +++ b/armorlab/Sources/nodes/TilingNode.ts @@ -77,7 +77,7 @@ class TilingNode extends LogicNode { // u8a[y * 512 + x] = 0; // } // } - let mask = image_from_bytes(u8a.buffer, 512, 512, TextureFormat.R8); + let mask = image_from_bytes(u8a.buffer, 512, 512, tex_format_t.R8); InpaintNode.prompt = TilingNode.prompt; InpaintNode.strength = TilingNode.strength; diff --git a/armorpaint/Sources/MakeMaterial.ts b/armorpaint/Sources/MakeMaterial.ts index bebc94bb..649b4a41 100644 --- a/armorpaint/Sources/MakeMaterial.ts +++ b/armorpaint/Sources/MakeMaterial.ts @@ -302,7 +302,7 @@ class MakeMaterial { let resY = Math.floor(Config.getTextureResY()); if (image == null || image.width != resX || image.height != resY) { if (image != null) image_unload(image); - image = image_create_render_target(resX, resY, TextureFormat.R8); + image = image_create_render_target(resX, resY, tex_format_t.R8); Context.raw.nodePreviews.set(id, image); } diff --git a/armorpaint/Sources/SlotLayer.ts b/armorpaint/Sources/SlotLayer.ts index e370668d..15495e2f 100644 --- a/armorpaint/Sources/SlotLayer.ts +++ b/armorpaint/Sources/SlotLayer.ts @@ -89,7 +89,7 @@ class SlotLayer { raw.texpaint_pack = render_path_create_render_target(t).image; } - raw.texpaint_preview = image_create_render_target(UtilRender.layerPreviewSize, UtilRender.layerPreviewSize, TextureFormat.RGBA32); + raw.texpaint_preview = image_create_render_target(UtilRender.layerPreviewSize, UtilRender.layerPreviewSize, tex_format_t.RGBA32); ///end } @@ -108,7 +108,7 @@ class SlotLayer { raw.texpaint = render_path_create_render_target(t).image; } - raw.texpaint_preview = image_create_render_target(UtilRender.layerPreviewSize, UtilRender.layerPreviewSize, TextureFormat.RGBA32); + raw.texpaint_preview = image_create_render_target(UtilRender.layerPreviewSize, UtilRender.layerPreviewSize, tex_format_t.RGBA32); } ///end @@ -226,7 +226,7 @@ class SlotLayer { static invertMask = (raw: SlotLayerRaw) => { if (Base.pipeInvert8 == null) Base.makePipe(); - let inverted = image_create_render_target(raw.texpaint.width, raw.texpaint.height, TextureFormat.RGBA32); + let inverted = image_create_render_target(raw.texpaint.width, raw.texpaint.height, tex_format_t.RGBA32); g2_begin(inverted, false); g2_set_pipeline(Base.pipeInvert8); g2_draw_image(raw.texpaint, 0, 0); @@ -330,13 +330,13 @@ class SlotLayer { if (SlotLayer.isLayer(raw)) { ///if is_paint - let format = Base.bitsHandle.position == TextureBits.Bits8 ? TextureFormat.RGBA32 : - Base.bitsHandle.position == TextureBits.Bits16 ? TextureFormat.RGBA64 : - TextureFormat.RGBA128; + let format = Base.bitsHandle.position == TextureBits.Bits8 ? tex_format_t.RGBA32 : + Base.bitsHandle.position == TextureBits.Bits16 ? tex_format_t.RGBA64 : + tex_format_t.RGBA128; ///end ///if is_sculpt - let format = TextureFormat.RGBA128; + let format = tex_format_t.RGBA128; ///end let _texpaint = raw.texpaint; @@ -383,7 +383,7 @@ class SlotLayer { } else if (SlotLayer.isMask(raw)) { let _texpaint = raw.texpaint; - raw.texpaint = image_create_render_target(resX, resY, TextureFormat.RGBA32); + raw.texpaint = image_create_render_target(resX, resY, tex_format_t.RGBA32); g2_begin(raw.texpaint, false); g2_set_pipeline(Base.pipeCopy8); diff --git a/armorsculpt/Sources/ImportMesh.ts b/armorsculpt/Sources/ImportMesh.ts index 66553706..2c1d1139 100644 --- a/armorsculpt/Sources/ImportMesh.ts +++ b/armorsculpt/Sources/ImportMesh.ts @@ -127,7 +127,7 @@ class ImportMesh { f32[i * 4 + 2] = mesh.posa[index * 4 + 2] / 32767; f32[i * 4 + 3] = 1.0; } - let imgmesh = image_from_bytes(f32.buffer, Config.getTextureResX(), Config.getTextureResY(), TextureFormat.RGBA128); + let imgmesh = image_from_bytes(f32.buffer, Config.getTextureResX(), Config.getTextureResY(), tex_format_t.RGBA128); let texpaint = Project.layers[0].texpaint; g2_begin(texpaint, false); g2_set_pipeline(Base.pipeCopy128); diff --git a/base/Sources/Base.ts b/base/Sources/Base.ts index dcd24b99..423a7b42 100644 --- a/base/Sources/Base.ts +++ b/base/Sources/Base.ts @@ -126,8 +126,8 @@ class Base { () => {}, // Pause () => { // Background // Release keys after alt-tab / win-tab - keyboard_up_listener(KeyCode.Alt); - keyboard_up_listener(KeyCode.Win); + keyboard_up_listener(key_code_t.ALT); + keyboard_up_listener(key_code_t.WIN); }, () => { // Shutdown ///if (krom_android || krom_ios) @@ -840,17 +840,17 @@ class Base { } static toggleFullscreen = () => { - if (sys_mode() == WindowMode.Windowed) { + if (sys_mode() == window_mode_t.WINDOWED) { ///if (krom_windows || krom_linux || krom_darwin) Config.raw.window_w = sys_width(); Config.raw.window_h = sys_height(); Config.raw.window_x = sys_x(); Config.raw.window_y = sys_y(); ///end - sys_mode_set(WindowMode.Fullscreen); + sys_mode_set(window_mode_t.FULLSCREEN); } else { - sys_mode_set(WindowMode.Windowed); + sys_mode_set(window_mode_t.WINDOWED); sys_resize(Config.raw.window_w, Config.raw.window_h); sys_move(Config.raw.window_x, Config.raw.window_y); } @@ -1062,14 +1062,14 @@ class Base { }); rts.get("texpaint_blend0").width = Config.getTextureResX(); rts.get("texpaint_blend0").height = Config.getTextureResY(); - rts.get("texpaint_blend0").image = image_create_render_target(Config.getTextureResX(), Config.getTextureResY(), TextureFormat.R8); + rts.get("texpaint_blend0").image = image_create_render_target(Config.getTextureResX(), Config.getTextureResY(), tex_format_t.R8); let _texpaint_blend1 = rts.get("texpaint_blend1").image; Base.notifyOnNextFrame(() => { image_unload(_texpaint_blend1); }); rts.get("texpaint_blend1").width = Config.getTextureResX(); rts.get("texpaint_blend1").height = Config.getTextureResY(); - rts.get("texpaint_blend1").image = image_create_render_target(Config.getTextureResX(), Config.getTextureResY(), TextureFormat.R8); + rts.get("texpaint_blend1").image = image_create_render_target(Config.getTextureResX(), Config.getTextureResY(), tex_format_t.R8); Context.raw.brushBlendDirty = true; if (rts.get("texpaint_blur") != null) { let _texpaint_blur = rts.get("texpaint_blur").image; @@ -1099,7 +1099,7 @@ class Base { pipe.vertex_shader = sys_get_shader("pass.vert"); pipe.fragment_shader = sys_get_shader("layer_merge.frag"); let vs = vertex_struct_create(); - vertex_struct_add(vs, "pos", VertexData.F32_2X); + vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); pipe.input_layout = [vs]; pipe.color_write_masks_red = [red]; pipe.color_write_masks_green = [green]; @@ -1130,9 +1130,9 @@ class Base { Base.pipeCopy.vertex_shader = sys_get_shader("layer_view.vert"); Base.pipeCopy.fragment_shader = sys_get_shader("layer_copy.frag"); let vs = vertex_struct_create(); - vertex_struct_add(vs, "pos", VertexData.F32_3X); - vertex_struct_add(vs, "tex", VertexData.F32_2X); - vertex_struct_add(vs, "col", VertexData.U8_4X_Normalized); + vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); + vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); + vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); Base.pipeCopy.input_layout = [vs]; pipeline_compile(Base.pipeCopy); } @@ -1142,9 +1142,9 @@ class Base { Base.pipeCopyBGRA.vertex_shader = sys_get_shader("layer_view.vert"); Base.pipeCopyBGRA.fragment_shader = sys_get_shader("layer_copy_bgra.frag"); let vs = vertex_struct_create(); - vertex_struct_add(vs, "pos", VertexData.F32_3X); - vertex_struct_add(vs, "tex", VertexData.F32_2X); - vertex_struct_add(vs, "col", VertexData.U8_4X_Normalized); + vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); + vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); + vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); Base.pipeCopyBGRA.input_layout = [vs]; pipeline_compile(Base.pipeCopyBGRA); } @@ -1155,12 +1155,12 @@ class Base { Base.pipeCopy8.vertex_shader = sys_get_shader("layer_view.vert"); Base.pipeCopy8.fragment_shader = sys_get_shader("layer_copy.frag"); let vs = vertex_struct_create(); - vertex_struct_add(vs, "pos", VertexData.F32_3X); - vertex_struct_add(vs, "tex", VertexData.F32_2X); - vertex_struct_add(vs, "col", VertexData.U8_4X_Normalized); + vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); + vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); + vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); Base.pipeCopy8.input_layout = [vs]; Base.pipeCopy8.color_attachment_count = 1; - Base.pipeCopy8.color_attachments[0] = TextureFormat.R8; + Base.pipeCopy8.color_attachments[0] = tex_format_t.R8; pipeline_compile(Base.pipeCopy8); } @@ -1169,12 +1169,12 @@ class Base { Base.pipeCopy128.vertex_shader = sys_get_shader("layer_view.vert"); Base.pipeCopy128.fragment_shader = sys_get_shader("layer_copy.frag"); let vs = vertex_struct_create(); - vertex_struct_add(vs, "pos", VertexData.F32_3X); - vertex_struct_add(vs, "tex", VertexData.F32_2X); - vertex_struct_add(vs, "col", VertexData.U8_4X_Normalized); + vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); + vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); + vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); Base.pipeCopy128.input_layout = [vs]; Base.pipeCopy128.color_attachment_count = 1; - Base.pipeCopy128.color_attachments[0] = TextureFormat.RGBA128; + Base.pipeCopy128.color_attachments[0] = tex_format_t.RGBA128; pipeline_compile(Base.pipeCopy128); } ///else @@ -1188,12 +1188,12 @@ class Base { Base.pipeInvert8.vertex_shader = sys_get_shader("layer_view.vert"); Base.pipeInvert8.fragment_shader = sys_get_shader("layer_invert.frag"); let vs = vertex_struct_create(); - vertex_struct_add(vs, "pos", VertexData.F32_3X); - vertex_struct_add(vs, "tex", VertexData.F32_2X); - vertex_struct_add(vs, "col", VertexData.U8_4X_Normalized); + vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); + vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); + vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); Base.pipeInvert8.input_layout = [vs]; Base.pipeInvert8.color_attachment_count = 1; - Base.pipeInvert8.color_attachments[0] = TextureFormat.R8; + Base.pipeInvert8.color_attachments[0] = tex_format_t.R8; pipeline_compile(Base.pipeInvert8); } @@ -1202,7 +1202,7 @@ class Base { Base.pipeApplyMask.vertex_shader = sys_get_shader("pass.vert"); Base.pipeApplyMask.fragment_shader = sys_get_shader("mask_apply.frag"); let vs = vertex_struct_create(); - vertex_struct_add(vs, "pos", VertexData.F32_2X); + vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); Base.pipeApplyMask.input_layout = [vs]; pipeline_compile(Base.pipeApplyMask); Base.tex0Mask = pipeline_get_tex_unit(Base.pipeApplyMask, "tex0"); @@ -1214,7 +1214,7 @@ class Base { Base.pipeMergeMask.vertex_shader = sys_get_shader("pass.vert"); Base.pipeMergeMask.fragment_shader = sys_get_shader("mask_merge.frag"); let vs = vertex_struct_create(); - vertex_struct_add(vs, "pos", VertexData.F32_2X); + vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); Base.pipeMergeMask.input_layout = [vs]; pipeline_compile(Base.pipeMergeMask); Base.tex0MergeMask = pipeline_get_tex_unit(Base.pipeMergeMask, "tex0"); @@ -1228,7 +1228,7 @@ class Base { Base.pipeColorIdToMask.vertex_shader = sys_get_shader("pass.vert"); Base.pipeColorIdToMask.fragment_shader = sys_get_shader("mask_colorid.frag"); let vs = vertex_struct_create(); - vertex_struct_add(vs, "pos", VertexData.F32_2X); + vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); Base.pipeColorIdToMask.input_layout = [vs]; pipeline_compile(Base.pipeColorIdToMask); Base.texpaintColorId = pipeline_get_tex_unit(Base.pipeColorIdToMask, "texpaint_colorid"); @@ -1242,9 +1242,9 @@ class Base { Base.pipeCopyR.vertex_shader = sys_get_shader("layer_view.vert"); Base.pipeCopyR.fragment_shader = sys_get_shader("layer_copy.frag"); let vs = vertex_struct_create(); - vertex_struct_add(vs, "pos", VertexData.F32_3X); - vertex_struct_add(vs, "tex", VertexData.F32_2X); - vertex_struct_add(vs, "col", VertexData.U8_4X_Normalized); + vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); + vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); + vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); Base.pipeCopyR.input_layout = [vs]; Base.pipeCopyR.color_write_masks_green = [false]; Base.pipeCopyR.color_write_masks_blue = [false]; @@ -1257,9 +1257,9 @@ class Base { Base.pipeCopyG.vertex_shader = sys_get_shader("layer_view.vert"); Base.pipeCopyG.fragment_shader = sys_get_shader("layer_copy.frag"); let vs = vertex_struct_create(); - vertex_struct_add(vs, "pos", VertexData.F32_3X); - vertex_struct_add(vs, "tex", VertexData.F32_2X); - vertex_struct_add(vs, "col", VertexData.U8_4X_Normalized); + vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); + vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); + vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); Base.pipeCopyG.input_layout = [vs]; Base.pipeCopyG.color_write_masks_red = [false]; Base.pipeCopyG.color_write_masks_blue = [false]; @@ -1272,9 +1272,9 @@ class Base { Base.pipeCopyB.vertex_shader = sys_get_shader("layer_view.vert"); Base.pipeCopyB.fragment_shader = sys_get_shader("layer_copy.frag"); let vs = vertex_struct_create(); - vertex_struct_add(vs, "pos", VertexData.F32_3X); - vertex_struct_add(vs, "tex", VertexData.F32_2X); - vertex_struct_add(vs, "col", VertexData.U8_4X_Normalized); + vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); + vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); + vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); Base.pipeCopyB.input_layout = [vs]; Base.pipeCopyB.color_write_masks_red = [false]; Base.pipeCopyB.color_write_masks_green = [false]; @@ -1287,7 +1287,7 @@ class Base { Base.pipeInpaintPreview.vertex_shader = sys_get_shader("pass.vert"); Base.pipeInpaintPreview.fragment_shader = sys_get_shader("inpaint_preview.frag"); let vs = vertex_struct_create(); - vertex_struct_add(vs, "pos", VertexData.F32_2X); + vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); Base.pipeInpaintPreview.input_layout = [vs]; pipeline_compile(Base.pipeInpaintPreview); Base.tex0InpaintPreview = pipeline_get_tex_unit(Base.pipeInpaintPreview, "tex0"); @@ -1301,9 +1301,9 @@ class Base { Base.pipeCopyRGB.vertex_shader = sys_get_shader("layer_view.vert"); Base.pipeCopyRGB.fragment_shader = sys_get_shader("layer_copy.frag"); let vs = vertex_struct_create(); - vertex_struct_add(vs, "pos", VertexData.F32_3X); - vertex_struct_add(vs, "tex", VertexData.F32_2X); - vertex_struct_add(vs, "col", VertexData.U8_4X_Normalized); + vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); + vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); + vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); Base.pipeCopyRGB.input_layout = [vs]; Base.pipeCopyRGB.color_write_masks_alpha = [false]; pipeline_compile(Base.pipeCopyRGB); @@ -1315,7 +1315,7 @@ class Base { Base.pipeCopyA.vertex_shader = sys_get_shader("pass.vert"); Base.pipeCopyA.fragment_shader = sys_get_shader("layer_copy_rrrr.frag"); let vs = vertex_struct_create(); - vertex_struct_add(vs, "pos", VertexData.F32_2X); + vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); Base.pipeCopyA.input_layout = [vs]; Base.pipeCopyA.color_write_masks_red = [false]; Base.pipeCopyA.color_write_masks_green = [false]; @@ -1331,17 +1331,17 @@ class Base { Base.pipeCursor.fragment_shader = sys_get_shader("cursor.frag"); let vs = vertex_struct_create(); ///if (krom_metal || krom_vulkan) - vertex_struct_add(vs, "tex", VertexData.I16_2X_Normalized); + vertex_struct_add(vs, "tex", vertex_data_t.I16_2X_NORM); ///else - vertex_struct_add(vs, "pos", VertexData.I16_4X_Normalized); - vertex_struct_add(vs, "nor", VertexData.I16_2X_Normalized); - vertex_struct_add(vs, "tex", VertexData.I16_2X_Normalized); + vertex_struct_add(vs, "pos", vertex_data_t.I16_4X_NORM); + vertex_struct_add(vs, "nor", vertex_data_t.I16_2X_NORM); + vertex_struct_add(vs, "tex", vertex_data_t.I16_2X_NORM); ///end Base.pipeCursor.input_layout = [vs]; - Base.pipeCursor.blend_source = BlendingFactor.SourceAlpha; - Base.pipeCursor.blend_dest = BlendingFactor.InverseSourceAlpha; + Base.pipeCursor.blend_source = blend_factor_t.SOURCE_ALPHA; + Base.pipeCursor.blend_dest = blend_factor_t.INV_SOURCE_ALPHA; Base.pipeCursor.depth_write = false; - Base.pipeCursor.depth_mode = CompareMode.Always; + Base.pipeCursor.depth_mode = compare_mode_t.ALWAYS; pipeline_compile(Base.pipeCursor); Base.cursorVP = pipeline_get_const_loc(Base.pipeCursor, "VP"); Base.cursorInvVP = pipeline_get_const_loc(Base.pipeCursor, "invVP"); @@ -1400,7 +1400,7 @@ class Base { Base.tempMaskImage = null; } if (Base.tempMaskImage == null) { - Base.tempMaskImage = image_create_render_target(Config.getTextureResX(), Config.getTextureResY(), TextureFormat.R8); + Base.tempMaskImage = image_create_render_target(Config.getTextureResX(), Config.getTextureResY(), tex_format_t.R8); } } ///end @@ -2182,9 +2182,9 @@ class Base { } image_unload(render_path_render_targets.get("texpaint_blend0").image); - render_path_render_targets.get("texpaint_blend0").image = image_create_render_target(Config.getTextureResX(), Config.getTextureResY(), TextureFormat.R8); + render_path_render_targets.get("texpaint_blend0").image = image_create_render_target(Config.getTextureResX(), Config.getTextureResY(), tex_format_t.R8); image_unload(render_path_render_targets.get("texpaint_blend1").image); - render_path_render_targets.get("texpaint_blend1").image = image_create_render_target(Config.getTextureResX(), Config.getTextureResY(), TextureFormat.R8); + render_path_render_targets.get("texpaint_blend1").image = image_create_render_target(Config.getTextureResX(), Config.getTextureResY(), tex_format_t.R8); if (render_path_render_targets.get("texpaint_node") != null) { render_path_render_targets.delete("texpaint_node"); diff --git a/base/Sources/Config.ts b/base/Sources/Config.ts index adad78d1..94b914e9 100644 --- a/base/Sources/Config.ts +++ b/base/Sources/Config.ts @@ -125,11 +125,11 @@ class Config { } static getOptions = (): kinc_sys_ops_t => { - let windowMode = Config.raw.window_mode == 0 ? WindowMode.Windowed : WindowMode.Fullscreen; - let windowFeatures = WindowFeatures.FeatureNone; - if (Config.raw.window_resizable) windowFeatures |= WindowFeatures.FeatureResizable; - if (Config.raw.window_maximizable) windowFeatures |= WindowFeatures.FeatureMaximizable; - if (Config.raw.window_minimizable) windowFeatures |= WindowFeatures.FeatureMinimizable; + let windowMode = Config.raw.window_mode == 0 ? window_mode_t.WINDOWED : window_mode_t.FULLSCREEN; + let windowFeatures = window_features_t.NONE; + if (Config.raw.window_resizable) windowFeatures |= window_features_t.RESIZABLE; + if (Config.raw.window_maximizable) windowFeatures |= window_features_t.MAXIMIZABLE; + if (Config.raw.window_minimizable) windowFeatures |= window_features_t.MINIMIZABLE; let title = "untitled - " + manifest_title; return { title: title, diff --git a/base/Sources/ImportArm.ts b/base/Sources/ImportArm.ts index 09f06837..3cca3717 100644 --- a/base/Sources/ImportArm.ts +++ b/base/Sources/ImportArm.ts @@ -67,7 +67,7 @@ class ImportArm { let bitsPos = l0.bpp == 8 ? TextureBits.Bits8 : l0.bpp == 16 ? TextureBits.Bits16 : TextureBits.Bits32; Base.bitsHandle.position = bitsPos; let bytesPerPixel = Math.floor(l0.bpp / 8); - let format = l0.bpp == 8 ? TextureFormat.RGBA32 : l0.bpp == 16 ? TextureFormat.RGBA64 : TextureFormat.RGBA128; + let format = l0.bpp == 8 ? tex_format_t.RGBA32 : l0.bpp == 16 ? tex_format_t.RGBA64 : tex_format_t.RGBA128; ///end let base = Path.baseDir(path); @@ -182,14 +182,14 @@ class ImportArm { }); rts.get("texpaint_blend0").width = Config.getTextureResX(); rts.get("texpaint_blend0").height = Config.getTextureResY(); - rts.get("texpaint_blend0").image = image_create_render_target(Config.getTextureResX(), Config.getTextureResY(), TextureFormat.R8, DepthFormat.NoDepthAndStencil); + rts.get("texpaint_blend0").image = image_create_render_target(Config.getTextureResX(), Config.getTextureResY(), tex_format_t.R8, depth_format_t.NO_DEPTH); let _texpaint_blend1 = rts.get("texpaint_blend1").image; Base.notifyOnNextFrame(() => { image_unload(_texpaint_blend1); }); rts.get("texpaint_blend1").width = Config.getTextureResX(); rts.get("texpaint_blend1").height = Config.getTextureResY(); - rts.get("texpaint_blend1").image = image_create_render_target(Config.getTextureResX(), Config.getTextureResY(), TextureFormat.R8, DepthFormat.NoDepthAndStencil); + rts.get("texpaint_blend1").image = image_create_render_target(Config.getTextureResX(), Config.getTextureResY(), tex_format_t.R8, depth_format_t.NO_DEPTH); Context.raw.brushBlendDirty = true; } @@ -222,7 +222,7 @@ class ImportArm { ///end if (isMask) { - _texpaint = image_from_bytes(lz4_decode(ld.texpaint, ld.res * ld.res * 4), ld.res, ld.res, TextureFormat.RGBA32); + _texpaint = image_from_bytes(lz4_decode(ld.texpaint, ld.res * ld.res * 4), ld.res, ld.res, tex_format_t.RGBA32); g2_begin(l.texpaint, false); // g2_set_pipeline(Base.pipeCopy8); g2_set_pipeline(project.is_bgra ? Base.pipeCopyBGRA : Base.pipeCopy); // Full bits for undo support, R8 is used diff --git a/base/Sources/ImportEnvmap.ts b/base/Sources/ImportEnvmap.ts index fe4c2265..4985d58e 100644 --- a/base/Sources/ImportEnvmap.ts +++ b/base/Sources/ImportEnvmap.ts @@ -19,20 +19,20 @@ class ImportEnvmap { ImportEnvmap.pipeline.vertex_shader = sys_get_shader("pass.vert"); ImportEnvmap.pipeline.fragment_shader = sys_get_shader("prefilter_envmap.frag"); let vs = vertex_struct_create(); - vertex_struct_add(vs, "pos", VertexData.F32_2X); + vertex_struct_add(vs, "pos", vertex_data_t.F32_2X); ImportEnvmap.pipeline.input_layout = [vs]; ImportEnvmap.pipeline.color_attachment_count = 1; - ImportEnvmap.pipeline.color_attachments[0] = TextureFormat.RGBA128; + ImportEnvmap.pipeline.color_attachments[0] = tex_format_t.RGBA128; pipeline_compile(ImportEnvmap.pipeline); ImportEnvmap.paramsLocation = pipeline_get_const_loc(ImportEnvmap.pipeline, "params"); ImportEnvmap.radianceLocation = pipeline_get_tex_unit(ImportEnvmap.pipeline, "radiance"); - ImportEnvmap.radiance = image_create_render_target(1024, 512, TextureFormat.RGBA128); + ImportEnvmap.radiance = image_create_render_target(1024, 512, tex_format_t.RGBA128); ImportEnvmap.mips = []; let w = 512; for (let i = 0; i < 10; ++i) { - ImportEnvmap.mips.push(image_create_render_target(w, w > 1 ? Math.floor(w / 2) : 1, TextureFormat.RGBA128)); + ImportEnvmap.mips.push(image_create_render_target(w, w > 1 ? Math.floor(w / 2) : 1, tex_format_t.RGBA128)); w = Math.floor(w / 2); } @@ -53,7 +53,7 @@ class ImportEnvmap { image_unload(_radianceCpu); }); } - ImportEnvmap.radianceCpu = image_from_bytes(radiancePixels, ImportEnvmap.radiance.width, ImportEnvmap.radiance.height, TextureFormat.RGBA128, Usage.DynamicUsage); + ImportEnvmap.radianceCpu = image_from_bytes(radiancePixels, ImportEnvmap.radiance.width, ImportEnvmap.radiance.height, tex_format_t.RGBA128, usage_t.DYNAMIC); // Radiance if (ImportEnvmap.mipsCpu != null) { @@ -69,7 +69,7 @@ class ImportEnvmap { ImportEnvmap.mipsCpu = []; for (let i = 0; i < ImportEnvmap.mips.length; ++i) { ImportEnvmap.getRadianceMip(ImportEnvmap.mips[i], i, ImportEnvmap.radiance); - ImportEnvmap.mipsCpu.push(image_from_bytes(image_get_pixels(ImportEnvmap.mips[i]), ImportEnvmap.mips[i].width, ImportEnvmap.mips[i].height, TextureFormat.RGBA128, Usage.DynamicUsage)); + ImportEnvmap.mipsCpu.push(image_from_bytes(image_get_pixels(ImportEnvmap.mips[i]), ImportEnvmap.mips[i].width, ImportEnvmap.mips[i].height, tex_format_t.RGBA128, usage_t.DYNAMIC)); } image_set_mipmaps(ImportEnvmap.radianceCpu, ImportEnvmap.mipsCpu); diff --git a/base/Sources/LineDraw.ts b/base/Sources/LineDraw.ts index 5a8cd082..039fed41 100644 --- a/base/Sources/LineDraw.ts +++ b/base/Sources/LineDraw.ts @@ -27,24 +27,24 @@ class LineDraw { if (LineDraw.pipeline == null) { let structure = vertex_struct_create(); - vertex_struct_add(structure, "pos", VertexData.F32_3X); - vertex_struct_add(structure, "col", VertexData.F32_3X); + vertex_struct_add(structure, "pos", vertex_data_t.F32_3X); + vertex_struct_add(structure, "col", vertex_data_t.F32_3X); LineDraw.pipeline = pipeline_create(); LineDraw.pipeline.input_layout = [structure]; LineDraw.pipeline.fragment_shader = sys_get_shader("line.frag"); LineDraw.pipeline.vertex_shader = sys_get_shader("line.vert"); LineDraw.pipeline.depth_write = true; - LineDraw.pipeline.depth_mode = CompareMode.Less; - LineDraw.pipeline.cull_mode = CullMode.None; + LineDraw.pipeline.depth_mode = compare_mode_t.LESS; + LineDraw.pipeline.cull_mode = cull_mode_t.NONE; LineDraw.pipeline.color_attachment_count = 3; - LineDraw.pipeline.color_attachments[0] = TextureFormat.RGBA64; - LineDraw.pipeline.color_attachments[1] = TextureFormat.RGBA64; - LineDraw.pipeline.color_attachments[2] = TextureFormat.RGBA64; - LineDraw.pipeline.depth_attachment = DepthFormat.DepthOnly; + LineDraw.pipeline.color_attachments[0] = tex_format_t.RGBA64; + LineDraw.pipeline.color_attachments[1] = tex_format_t.RGBA64; + LineDraw.pipeline.color_attachments[2] = tex_format_t.RGBA64; + LineDraw.pipeline.depth_attachment = depth_format_t.DEPTH24; pipeline_compile(LineDraw.pipeline); LineDraw.vpID = pipeline_get_const_loc(LineDraw.pipeline, "VP"); LineDraw.vp = mat4_identity(); - LineDraw.vertexBuffer = vertex_buffer_create(LineDraw.maxVertices, structure, Usage.DynamicUsage); + LineDraw.vertexBuffer = vertex_buffer_create(LineDraw.maxVertices, structure, usage_t.DYNAMIC); LineDraw.indexBuffer = index_buffer_create(LineDraw.maxIndices); } diff --git a/base/Sources/MakeVoxel.ts b/base/Sources/MakeVoxel.ts index 5cef896a..263db5c0 100644 --- a/base/Sources/MakeVoxel.ts +++ b/base/Sources/MakeVoxel.ts @@ -4,9 +4,9 @@ class MakeVoxel { ///if arm_voxels static run = (data: shader_context_t) => { let structure = vertex_struct_create(); - vertex_struct_add(structure, "pos", VertexData.I16_4X_Normalized); - vertex_struct_add(structure, "nor", VertexData.I16_2X_Normalized); - vertex_struct_add(structure, "tex", VertexData.I16_2X_Normalized); + vertex_struct_add(structure, "pos", vertex_data_t.I16_4X_NORM); + vertex_struct_add(structure, "nor", vertex_data_t.I16_2X_NORM); + vertex_struct_add(structure, "tex", vertex_data_t.I16_2X_NORM); let pipeState = data._pipe_state; pipeState.input_layout = [structure]; @@ -24,7 +24,7 @@ class MakeVoxel { // ///end let ds = MakeMaterial.getDisplaceStrength(); - pipeState.vertex_shader = shader_from_source(MakeVoxel.voxelSource(), ShaderType.Vertex); + pipeState.vertex_shader = shader_from_source(MakeVoxel.voxelSource(), shader_type_t.VERTEX); pipeline_compile(pipeState); data.constants = [{ name: "W", type: "mat4", link: "_worldMatrix" }, { name: "N", type: "mat3", link: "_normalMatrix" }]; diff --git a/base/Sources/Project.ts b/base/Sources/Project.ts index 24406ec5..e7e62317 100644 --- a/base/Sources/Project.ts +++ b/base/Sources/Project.ts @@ -178,7 +178,7 @@ class Project { f32a[i * 4 + 3] = 1.0; } - let imgmesh = image_from_bytes(f32a.buffer, Config.getTextureResX(), Config.getTextureResY(), TextureFormat.RGBA128); + let imgmesh = image_from_bytes(f32a.buffer, Config.getTextureResX(), Config.getTextureResY(), tex_format_t.RGBA128); let texpaint = Project.layers[0].texpaint; g2_begin(texpaint, false); g2_set_pipeline(Base.pipeCopy128); diff --git a/base/Sources/RenderPathBase.ts b/base/Sources/RenderPathBase.ts index f9a6a85f..560d9978 100644 --- a/base/Sources/RenderPathBase.ts +++ b/base/Sources/RenderPathBase.ts @@ -213,15 +213,6 @@ class RenderPathBase { render_path_load_shader("shader_datas/bloom_pass/bloom_downsample_pass"); render_path_load_shader("shader_datas/bloom_pass/bloom_upsample_pass"); - - uniforms_i32_links.push((_: any, __: any, link: string) => { - if (link == "_bloomCurrentMip") return RenderPathBase.bloomCurrentMip; - return null; - }); - uniforms_f32_links.push((_: any, __: any, link: string) => { - if (link == "_bloomSampleScale") return RenderPathBase.bloomSampleScale; - return null; - }); } let bloomRadius = 6.5; diff --git a/base/Sources/RenderPathDeferred.ts b/base/Sources/RenderPathDeferred.ts index d1318bb3..ce803a59 100644 --- a/base/Sources/RenderPathDeferred.ts +++ b/base/Sources/RenderPathDeferred.ts @@ -95,7 +95,7 @@ class RenderPathDeferred { let b = new ArrayBuffer(1); let v = new DataView(b); v.setUint8(0, 255); - t.image = image_from_bytes(b, t.width, t.height, TextureFormat.R8); + t.image = image_from_bytes(b, t.width, t.height, tex_format_t.R8); render_path_render_targets.set(t.name, t); } { @@ -110,7 +110,7 @@ class RenderPathDeferred { v.setUint8(1, 0); v.setUint8(2, 0); v.setUint8(3, 0); - t.image = image_from_bytes(b, t.width, t.height, TextureFormat.RGBA32); + t.image = image_from_bytes(b, t.width, t.height, tex_format_t.RGBA32); render_path_render_targets.set(t.name, t); } diff --git a/base/Sources/TabBrowser.ts b/base/Sources/TabBrowser.ts index fa202105..36e12a31 100644 --- a/base/Sources/TabBrowser.ts +++ b/base/Sources/TabBrowser.ts @@ -62,12 +62,12 @@ class TabBrowser { let refresh = false; let inFocus = ui.input_x > ui._window_x && ui.input_x < ui._window_x + ui._window_w && ui.input_y > ui._window_y && ui.input_y < ui._window_y + ui._window_h; - if (zui_button(tr("Refresh")) || (inFocus && ui.is_key_pressed && ui.key == KeyCode.F5)) { + if (zui_button(tr("Refresh")) || (inFocus && ui.is_key_pressed && ui.key == key_code_t.F5)) { refresh = true; } TabBrowser.hsearch.text = zui_text_input(TabBrowser.hsearch, tr("Search"), Align.Left, true, true); if (ui.is_hovered) zui_tooltip(tr("ctrl+f to search") + "\n" + tr("esc to cancel")); - if (ui.is_ctrl_down && ui.is_key_pressed && ui.key == KeyCode.F) { // Start searching via ctrl+f + if (ui.is_ctrl_down && ui.is_key_pressed && ui.key == key_code_t.F) { // Start searching via ctrl+f zui_start_text_edit(TabBrowser.hsearch); } if (TabBrowser.hsearch.text != "" && (zui_button(tr("X")) || ui.is_escape_down)) { diff --git a/base/Sources/UIBase.ts b/base/Sources/UIBase.ts index 2348000a..d206d0c2 100644 --- a/base/Sources/UIBase.ts +++ b/base/Sources/UIBase.ts @@ -783,8 +783,8 @@ class UIBase { if (searchHandle.changed) UIBase.operatorSearchOffset = 0; if (ui.is_key_pressed) { // Move selection - if (ui.key == KeyCode.Down && UIBase.operatorSearchOffset < 6) UIBase.operatorSearchOffset++; - if (ui.key == KeyCode.Up && UIBase.operatorSearchOffset > 0) UIBase.operatorSearchOffset--; + if (ui.key == key_code_t.DOWN && UIBase.operatorSearchOffset < 6) UIBase.operatorSearchOffset++; + if (ui.key == key_code_t.UP && UIBase.operatorSearchOffset > 0) UIBase.operatorSearchOffset--; } let enter = keyboard_down("enter"); let count = 0; @@ -1502,7 +1502,7 @@ class UIBase { static onDeselectText = () => { ///if krom_ios - keyboard_up_listener(KeyCode.Shift); + keyboard_up_listener(key_code_t.SHIFT); ///end } diff --git a/base/Sources/UIBox.ts b/base/Sources/UIBox.ts index b6874915..026f6907 100644 --- a/base/Sources/UIBox.ts +++ b/base/Sources/UIBox.ts @@ -153,14 +153,14 @@ class UIBox { ///if (krom_android || krom_ios) static tweenIn = () => { tween_reset(); - tween_to({target: UIBox, props: { tweenAlpha: 0.5 }, duration: 0.2, ease: Ease.ExpoOut}); + tween_to({target: UIBox, props: { tweenAlpha: 0.5 }, duration: 0.2, ease: ease_t.EXPO_OUT}); UIBox.hwnd.drag_y = Math.floor(sys_height() / 2); - tween_to({target: UIBox.hwnd, props: { dragY: 0 }, duration: 0.2, ease: Ease.ExpoOut, tick: () => { Base.redrawUI(); }}); + tween_to({target: UIBox.hwnd, props: { dragY: 0 }, duration: 0.2, ease: ease_t.EXPO_OUT, tick: () => { Base.redrawUI(); }}); } static tweenOut = () => { - tween_to({target: UIBox, props: { tweenAlpha: 0.0 }, duration: 0.2, ease: Ease.ExpoIn, done: UIBox.hideInternal}); - tween_to({target: UIBox.hwnd, props: { dragY: sys_height() / 2 }, duration: 0.2, ease: Ease.ExpoIn}); + tween_to({target: UIBox, props: { tweenAlpha: 0.0 }, duration: 0.2, ease: ease_t.EXPO_IN, done: UIBox.hideInternal}); + tween_to({target: UIBox.hwnd, props: { dragY: sys_height() / 2 }, duration: 0.2, ease: ease_t.EXPO_IN}); } ///end diff --git a/base/Sources/UIFiles.ts b/base/Sources/UIFiles.ts index e8ac3d84..c0d26b74 100644 --- a/base/Sources/UIFiles.ts +++ b/base/Sources/UIFiles.ts @@ -72,10 +72,10 @@ class UIFiles { static releaseKeys = () => { // File dialog may prevent firing key up events - keyboard_up_listener(KeyCode.Shift); - keyboard_up_listener(KeyCode.Control); + keyboard_up_listener(key_code_t.SHIFT); + keyboard_up_listener(key_code_t.CONTROL); ///if krom_darwin - keyboard_up_listener(KeyCode.Meta); + keyboard_up_listener(key_code_t.META); ///end } diff --git a/base/Sources/UINodes.ts b/base/Sources/UINodes.ts index f685554b..5b8d2626 100644 --- a/base/Sources/UINodes.ts +++ b/base/Sources/UINodes.ts @@ -443,10 +443,10 @@ class UINodes { let nodes = UINodes.getNodes(); if (nodes.nodesSelectedId.length > 0 && UINodes.ui.is_key_pressed) { - if (UINodes.ui.key == KeyCode.Left) for (let n of nodes.nodesSelectedId) zui_get_node(UINodes.getCanvas(true).nodes, n).x -= 1; - else if (UINodes.ui.key == KeyCode.Right) for (let n of nodes.nodesSelectedId) zui_get_node(UINodes.getCanvas(true).nodes, n).x += 1; - if (UINodes.ui.key == KeyCode.Up) for (let n of nodes.nodesSelectedId) zui_get_node(UINodes.getCanvas(true).nodes, n).y -= 1; - else if (UINodes.ui.key == KeyCode.Down) for (let n of nodes.nodesSelectedId) zui_get_node(UINodes.getCanvas(true).nodes, n).y += 1; + if (UINodes.ui.key == key_code_t.LEFT) for (let n of nodes.nodesSelectedId) zui_get_node(UINodes.getCanvas(true).nodes, n).x -= 1; + else if (UINodes.ui.key == key_code_t.RIGHT) for (let n of nodes.nodesSelectedId) zui_get_node(UINodes.getCanvas(true).nodes, n).x += 1; + if (UINodes.ui.key == key_code_t.UP) for (let n of nodes.nodesSelectedId) zui_get_node(UINodes.getCanvas(true).nodes, n).y -= 1; + else if (UINodes.ui.key == key_code_t.DOWN) for (let n of nodes.nodesSelectedId) zui_get_node(UINodes.getCanvas(true).nodes, n).y += 1; } // Node search popup @@ -488,8 +488,8 @@ class UINodes { if (searchHandle.changed) UINodes.nodeSearchOffset = 0; if (ui.is_key_pressed) { // Move selection - if (ui.key == KeyCode.Down && UINodes.nodeSearchOffset < 6) UINodes.nodeSearchOffset++; - if (ui.key == KeyCode.Up && UINodes.nodeSearchOffset > 0) UINodes.nodeSearchOffset--; + if (ui.key == key_code_t.DOWN && UINodes.nodeSearchOffset < 6) UINodes.nodeSearchOffset++; + if (ui.key == key_code_t.UP && UINodes.nodeSearchOffset > 0) UINodes.nodeSearchOffset--; } let enter = keyboard_down("enter"); let count = 0; diff --git a/base/Sources/UIView2D.ts b/base/Sources/UIView2D.ts index c67debb2..5258990d 100644 --- a/base/Sources/UIView2D.ts +++ b/base/Sources/UIView2D.ts @@ -35,12 +35,12 @@ class UIView2D { UIView2D.pipe.vertex_shader = sys_get_shader("layer_view.vert"); UIView2D.pipe.fragment_shader = sys_get_shader("layer_view.frag"); let vs = vertex_struct_create(); - vertex_struct_add(vs, "pos", VertexData.F32_3X); - vertex_struct_add(vs, "tex", VertexData.F32_2X); - vertex_struct_add(vs, "col", VertexData.U8_4X_Normalized); + vertex_struct_add(vs, "pos", vertex_data_t.F32_3X); + vertex_struct_add(vs, "tex", vertex_data_t.F32_2X); + vertex_struct_add(vs, "col", vertex_data_t.U8_4X_NORM); UIView2D.pipe.input_layout = [vs]; - UIView2D.pipe.blend_source = BlendingFactor.BlendOne; - UIView2D.pipe.blend_dest = BlendingFactor.BlendZero; + UIView2D.pipe.blend_source = blend_factor_t.BLEND_ONE; + UIView2D.pipe.blend_dest = blend_factor_t.BLEND_ZERO; UIView2D.pipe.color_write_masks_alpha[0] = false; pipeline_compile(UIView2D.pipe); UIView2D.channelLocation = pipeline_get_const_loc(UIView2D.pipe, "channel"); @@ -196,7 +196,7 @@ class UIView2D { g2_set_pipeline(UIView2D.pipe); ///end if (!Context.raw.textureFilter) { - g2_set_image_scale_quality(ImageScaleQuality.Low); + g2_set_bilinear_filter(false); } ///if krom_opengl Krom.setPipeline(UIView2D.pipe.pipeline_); @@ -222,7 +222,7 @@ class UIView2D { if (UIView2D.type == View2DType.View2DLayer) { g2_set_pipeline(null); if (!Context.raw.textureFilter) { - g2_set_image_scale_quality(ImageScaleQuality.High); + g2_set_bilinear_filter(true); } } diff --git a/base/Sources/UniformsExt.ts b/base/Sources/UniformsExt.ts index 27a1efae..446ecfc2 100644 --- a/base/Sources/UniformsExt.ts +++ b/base/Sources/UniformsExt.ts @@ -5,16 +5,17 @@ class UniformsExt { static orthoP = mat4_ortho(-0.5, 0.5, -0.5, 0.5, -0.5, 0.5); static init = () => { - uniforms_i32_links = [UniformsExt.linkInt]; - uniforms_f32_links = [UniformsExt.linkFloat]; - uniforms_vec2_links = [UniformsExt.linkVec2]; - uniforms_vec3_links = [UniformsExt.linkVec3]; - uniforms_vec4_links = [UniformsExt.linkVec4]; - uniforms_mat4_links = [UniformsExt.linkMat4]; - uniforms_tex_links = [UniformsExt.linkTex]; + uniforms_i32_links = UniformsExt.linkInt; + uniforms_f32_links = UniformsExt.linkFloat; + uniforms_vec2_links = UniformsExt.linkVec2; + uniforms_vec3_links = UniformsExt.linkVec3; + uniforms_vec4_links = UniformsExt.linkVec4; + uniforms_mat4_links = UniformsExt.linkMat4; + uniforms_tex_links = UniformsExt.linkTex; } static linkInt = (object: object_t, mat: material_data_t, link: string): Null => { + if (link == "_bloomCurrentMip") return RenderPathBase.bloomCurrentMip; return null; } @@ -66,6 +67,9 @@ class UniformsExt { case "_coneAperture": { return Context.raw.vxaoAperture; } + case "_bloomSampleScale": { + return RenderPathBase.bloomSampleScale; + } ///if (is_paint || is_sculpt) case "_brushScaleX": { diff --git a/base/Sources/UtilRender.ts b/base/Sources/UtilRender.ts index 550449f4..2fb6a6e0 100644 --- a/base/Sources/UtilRender.ts +++ b/base/Sources/UtilRender.ts @@ -161,9 +161,9 @@ class UtilRender { } if (Context.raw.textToolImage == null) { ///if krom_metal - Context.raw.textToolImage = image_create_render_target(texW, texW, TextureFormat.RGBA32); + Context.raw.textToolImage = image_create_render_target(texW, texW, tex_format_t.RGBA32); ///else - Context.raw.textToolImage = image_create_render_target(texW, texW, TextureFormat.R8); + Context.raw.textToolImage = image_create_render_target(texW, texW, tex_format_t.R8); ///end } g2_begin(Context.raw.textToolImage, true, 0xff000000); @@ -186,7 +186,7 @@ class UtilRender { let textW = Math.floor(font_width(font, fontSize, text)) + 8; let textH = Math.floor(font_height(font, fontSize)) + 8; if (Context.raw.font.image == null) { - Context.raw.font.image = image_create_render_target(512, 512, TextureFormat.RGBA32); + Context.raw.font.image = image_create_render_target(512, 512, tex_format_t.RGBA32); } g2_begin(Context.raw.font.image, true, 0x00000000); g2_set_font(font); @@ -428,11 +428,11 @@ class UtilRender { // Mandatory vertex data names and sizes let structure = vertex_struct_create(); - vertex_struct_add(structure, "pos", VertexData.I16_4X_Normalized); - vertex_struct_add(structure, "nor", VertexData.I16_2X_Normalized); - vertex_struct_add(structure, "tex", VertexData.I16_2X_Normalized); - vertex_struct_add(structure, "col", VertexData.I16_4X_Normalized); - UtilRender.screenAlignedFullVB = vertex_buffer_create(Math.floor(data.length / Math.floor(vertex_struct_byte_size(structure) / 4)), structure, Usage.StaticUsage); + vertex_struct_add(structure, "pos", vertex_data_t.I16_4X_NORM); + vertex_struct_add(structure, "nor", vertex_data_t.I16_2X_NORM); + vertex_struct_add(structure, "tex", vertex_data_t.I16_2X_NORM); + vertex_struct_add(structure, "col", vertex_data_t.I16_4X_NORM); + UtilRender.screenAlignedFullVB = vertex_buffer_create(Math.floor(data.length / Math.floor(vertex_struct_byte_size(structure) / 4)), structure, usage_t.STATIC); let vertices = vertex_buffer_lock(UtilRender.screenAlignedFullVB); for (let i = 0; i < Math.floor(vertices.byteLength / 2); ++i) vertices.setInt16(i * 2, data[i], true); vertex_buffer_unlock(UtilRender.screenAlignedFullVB); diff --git a/base/Sources/UtilUV.ts b/base/Sources/UtilUV.ts index a72dbc23..253d8d2c 100644 --- a/base/Sources/UtilUV.ts +++ b/base/Sources/UtilUV.ts @@ -100,7 +100,7 @@ class UtilUV { if (UtilUV.dilatemapCached) return; if (UtilUV.dilatemap == null) { - UtilUV.dilatemap = image_create_render_target(Config.getTextureResX(), Config.getTextureResY(), TextureFormat.R8); + UtilUV.dilatemap = image_create_render_target(Config.getTextureResX(), Config.getTextureResY(), tex_format_t.R8); } if (UtilUV.pipeDilate == null) { @@ -109,16 +109,16 @@ class UtilUV { UtilUV.pipeDilate.fragment_shader = sys_get_shader("dilate_map.frag"); let vs = vertex_struct_create(); ///if (krom_metal || krom_vulkan) - vertex_struct_add(vs, "tex", VertexData.I16_2X_Normalized); + vertex_struct_add(vs, "tex", vertex_data_t.I16_2X_NORM); ///else - vertex_struct_add(vs, "pos", VertexData.I16_4X_Normalized); - vertex_struct_add(vs, "nor", VertexData.I16_2X_Normalized); - vertex_struct_add(vs, "tex", VertexData.I16_2X_Normalized); + vertex_struct_add(vs, "pos", vertex_data_t.I16_4X_NORM); + vertex_struct_add(vs, "nor", vertex_data_t.I16_2X_NORM); + vertex_struct_add(vs, "tex", vertex_data_t.I16_2X_NORM); ///end UtilUV.pipeDilate.input_layout = [vs]; UtilUV.pipeDilate.depth_write = false; - UtilUV.pipeDilate.depth_mode = CompareMode.Always; - UtilUV.pipeDilate.color_attachments[0] = TextureFormat.R8; + UtilUV.pipeDilate.depth_mode = compare_mode_t.ALWAYS; + UtilUV.pipeDilate.color_attachments[0] = tex_format_t.R8; pipeline_compile(UtilUV.pipeDilate); // dilateTexUnpack = getConstantLocation(UtilUV.pipeDilate, "texUnpack"); } @@ -175,7 +175,7 @@ class UtilUV { if (UtilUV.uvislandmap != null) { image_unload(UtilUV.uvislandmap); } - UtilUV.uvislandmap = image_from_bytes(bytes, w, h, TextureFormat.R8); + UtilUV.uvislandmap = image_from_bytes(bytes, w, h, tex_format_t.R8); UtilUV.uvislandmapCached = true; } } diff --git a/base/Sources/nodes/ColorNode.ts b/base/Sources/nodes/ColorNode.ts index ae4e9986..aebabd47 100644 --- a/base/Sources/nodes/ColorNode.ts +++ b/base/Sources/nodes/ColorNode.ts @@ -23,7 +23,7 @@ class ColorNode extends LogicNode { v.setFloat32(4, this.value.y, true); v.setFloat32(8, this.value.z, true); v.setFloat32(12, this.value.w, true); - this.image = image_from_bytes(b, 1, 1, TextureFormat.RGBA128); + this.image = image_from_bytes(b, 1, 1, tex_format_t.RGBA128); done(this.image); } diff --git a/base/Sources/nodes/FloatNode.ts b/base/Sources/nodes/FloatNode.ts index b42c3f50..5685c7c0 100644 --- a/base/Sources/nodes/FloatNode.ts +++ b/base/Sources/nodes/FloatNode.ts @@ -23,7 +23,7 @@ class FloatNode extends LogicNode { v.setFloat32(4, this.value, true); v.setFloat32(8, this.value, true); v.setFloat32(12, 1.0, true); - this.image = image_from_bytes(b, 1, 1, TextureFormat.RGBA128); + this.image = image_from_bytes(b, 1, 1, tex_format_t.RGBA128); done(this.image); } diff --git a/base/Sources/nodes/VectorNode.ts b/base/Sources/nodes/VectorNode.ts index f5369edf..0672a1d6 100644 --- a/base/Sources/nodes/VectorNode.ts +++ b/base/Sources/nodes/VectorNode.ts @@ -38,7 +38,7 @@ class VectorNode extends LogicNode { v.setFloat32(4, (this.inputs[1].node as any).value, true); v.setFloat32(8, (this.inputs[2].node as any).value, true); v.setFloat32(12, 1.0, true); - this.image = image_from_bytes(b, 1, 1, TextureFormat.RGBA128); + this.image = image_from_bytes(b, 1, 1, tex_format_t.RGBA128); done(this.image); }); });