diff --git a/Sources/arm/Config.hx b/Sources/arm/Config.hx index 820e3ae1..d2800372 100644 --- a/Sources/arm/Config.hx +++ b/Sources/arm/Config.hx @@ -51,13 +51,20 @@ class Config { raw.rp_bloom = false; raw.rp_gi = false; raw.rp_motionblur = false; + #if krom_android + raw.rp_ssgi = false; + #else raw.rp_ssgi = true; + #end raw.rp_ssr = false; raw.rp_supersample = 1.0; var disp = Display.primary; if (disp != null && disp.width >= 3000 && disp.height >= 2000) { raw.window_scale = 2.0; } + #if krom_android + raw.window_scale = 2.0; + #end } #if arm_painter diff --git a/Sources/arm/node/MakePaint.hx b/Sources/arm/node/MakePaint.hx index 744ec287..91d1d203 100644 --- a/Sources/arm/node/MakePaint.hx +++ b/Sources/arm/node/MakePaint.hx @@ -269,15 +269,16 @@ class MakePaint { if (UITrait.inst.pickerMaskHandle.position == MaskMaterial) { matid = UITrait.inst.materialIdPicked / 255; // Keep existing material id in place when mask is set } - frag.write('float matid = $matid;'); + var matidString = Material.vec1(matid); + frag.write('float matid = $matidString;'); // TODO: Use emission/subsurface matid // matid % 3 == 0 - normal, 1 - emission, 2 - subsurface if (Context.material.paintSubs) { - frag.write('if (subs > 0) { matid = 254 / 255; }'); + frag.write('if (subs > 0.0) { matid = float(254) / float(255); }'); } if (Context.material.paintEmis) { - frag.write('if (emis > 0) { matid = 255 / 255; }'); + frag.write('if (emis > 0.0) { matid = float(255) / float(255); }'); } if (layered) { diff --git a/Sources/arm/node/Material.hx b/Sources/arm/node/Material.hx index 439ed413..80621bd0 100644 --- a/Sources/arm/node/Material.hx +++ b/Sources/arm/node/Material.hx @@ -1450,23 +1450,23 @@ class Material { sample_bump = false; } - static function vec1(v: Float): String { - #if kha_webgl + public static inline function vec1(v: Float): String { + #if (kha_webgl ||krom_android) return 'float($v)'; #else return '$v'; #end } - static function vec3(v: Array): String { - #if kha_webgl + public static inline function vec3(v: Array): String { + #if (kha_webgl ||krom_android) return 'vec3(float(${v[0]}), float(${v[1]}), float(${v[2]}))'; #else return 'vec3(${v[0]}, ${v[1]}, ${v[2]})'; #end } - static function to_vec3(s: String): String { + public static inline function to_vec3(s: String): String { #if (kha_direct3d11 || kha_direct3d12) return '($s).xxx'; #else diff --git a/Sources/arm/node/MaterialShader.hx b/Sources/arm/node/MaterialShader.hx index d92d778f..d02d8dcf 100644 --- a/Sources/arm/node/MaterialShader.hx +++ b/Sources/arm/node/MaterialShader.hx @@ -481,10 +481,10 @@ class MaterialShader { #else // kha_opengl - #if kha_webgl + #if (kha_webgl || krom_android) var s = '#version 300 es\n'; if (shader_type == 'frag') { - s += 'precision mediump float;\n'; + s += 'precision highp float;\n'; s += 'precision mediump int;\n'; } #else diff --git a/Sources/arm/sys/File.hx b/Sources/arm/sys/File.hx index 6dab3ca9..7aba7c31 100644 --- a/Sources/arm/sys/File.hx +++ b/Sources/arm/sys/File.hx @@ -18,7 +18,7 @@ class File { #end public static function readDirectory(path: String, foldersOnly = false): Array { - #if (krom_windows || krom_linux) + #if (krom_windows || krom_linux || krom_android) return Krom.readDirectory(path, foldersOnly).split("\n"); #else var save = Path.data() + Path.sep + "tmp.txt"; diff --git a/Sources/arm/ui/BoxExport.hx b/Sources/arm/ui/BoxExport.hx index 53a59d6a..c50a9d3d 100644 --- a/Sources/arm/ui/BoxExport.hx +++ b/Sources/arm/ui/BoxExport.hx @@ -217,10 +217,18 @@ class BoxExport { } static function fetchPresets() { + #if krom_android + + files = ["generic"]; + + #else + files = File.readDirectory(Path.data() + Path.sep + "export_presets"); for (i in 0...files.length) { files[i] = files[i].substr(0, files[i].length - 5); // Strip .json } + + #end } static function parsePreset() { diff --git a/Sources/arm/ui/BoxPreferences.hx b/Sources/arm/ui/BoxPreferences.hx index 04917df4..0d0def70 100644 --- a/Sources/arm/ui/BoxPreferences.hx +++ b/Sources/arm/ui/BoxPreferences.hx @@ -54,7 +54,9 @@ class BoxPreferences { UITrait.inst.tagUIRedraw(); } + #if (!krom_android) UITrait.inst.nativeBrowser = ui.check(Id.handle({selected: UITrait.inst.nativeBrowser}), "Native File Browser"); + #end UITrait.inst.cacheDraws = ui.check(Id.handle({selected: UITrait.inst.cacheDraws}), "Cache UI Draws"); if (ui.isHovered) ui.tooltip("Enabling may reduce GPU usage"); @@ -150,7 +152,7 @@ class BoxPreferences { Config.raw.window_vsync = ui.check(vsyncHandle, "VSync"); if (vsyncHandle.changed) Config.save(); - #if (!kha_direct3d12) + #if rp_voxelao ui.check(UITrait.inst.hvxao, "Voxel AO"); if (ui.isHovered) ui.tooltip("Cone-traced AO and shadows"); if (UITrait.inst.hvxao.changed) { diff --git a/Sources/arm/ui/UIFiles.hx b/Sources/arm/ui/UIFiles.hx index dd8ee8ef..a7b570db 100644 --- a/Sources/arm/ui/UIFiles.hx +++ b/Sources/arm/ui/UIFiles.hx @@ -201,6 +201,8 @@ class UIFiles { #if krom_windows handle.text = "C:\\Users"; // %HOMEDRIVE% + %HomePath% + #elseif krom_android + handle.text = "/sdcard"; #else handle.text = "/"; // ~ diff --git a/Sources/arm/ui/UITrait.hx b/Sources/arm/ui/UITrait.hx index 23ea7708..39c2fb20 100644 --- a/Sources/arm/ui/UITrait.hx +++ b/Sources/arm/ui/UITrait.hx @@ -132,7 +132,11 @@ class UITrait { public var viewportMode = ViewRender; public var hscaleWasChanged = false; public var exportMeshFormat = FormatObj; + #if krom_android + public var nativeBrowser = false; + #else public var nativeBrowser = true; + #end public var cacheDraws = false; public var showAssetNames = false; diff --git a/khafile.js b/khafile.js index ad2b98eb..2d680f27 100644 --- a/khafile.js +++ b/khafile.js @@ -1,4 +1,5 @@ let project = new Project('ArmorPaint'); +let android = false; // Temp project.addSources('Sources'); project.addLibrary("iron"); @@ -13,10 +14,15 @@ project.addAssets("Assets/themes/*", { notinlist: true, destination: "data/theme project.addDefine('arm_taa'); project.addDefine('arm_veloc'); project.addDefine('arm_particles'); -project.addDefine('arm_data_dir'); // project.addDefine('arm_noembed'); +if (!android) { + project.addDefine('arm_data_dir'); +} -if (process.platform === 'win32') { +if (android) { + project.addDefine('krom_android'); +} +else if (process.platform === 'win32') { project.addDefine('krom_windows'); } else if (process.platform === 'linux') { @@ -48,15 +54,20 @@ if (raytrace) { } else { project.addAssets("Assets/readme/readme.txt", { notinlist: true, destination: "{name}" }); - project.addDefine('rp_voxelao'); - project.addDefine('arm_voxelgi_revox'); + if (!android) { + project.addDefine('rp_voxelao'); + project.addDefine('arm_voxelgi_revox'); + } } if (process.platform === 'darwin') { project.addAssets("Assets/readme/readme_macos.txt", { notinlist: true, destination: "INSTRUCTIONS.txt" }); } -if (process.platform === 'win32' && win_hlsl) { +if (android) { + +} +else if (process.platform === 'win32' && win_hlsl) { project.addShaders("Shaders/voxel_hlsl/*.glsl", { noprocessing: true, noembed: false }); } else { @@ -73,7 +84,10 @@ else { // painter, creator project.addDefine('arm_skip_envmap'); project.addDefine('arm_resizable'); - if (process.platform === 'win32') { + if (android) { + + } + else if (process.platform === 'win32') { project.addAssets("Assets/bin/cmft.exe", { notinlist: true, destination: "data/{name}" }); } else if (process.platform === 'linux') { @@ -89,7 +103,7 @@ else { // painter, creator project.addAssets("Assets/painter/export_presets/*", { notinlist: true, destination: "data/export_presets/{name}" }); project.addAssets("Assets/painter/keymap_presets/*", { notinlist: true, destination: "data/keymap_presets/{name}" }); - if (process.platform === 'win32' && win_hlsl) { + if (process.platform === 'win32' && win_hlsl && !android) { project.addShaders("Shaders/painter/hlsl/*.glsl", { noprocessing: true, noembed: false }); } else {