diff --git a/android/particlefire/AndroidManifest.xml b/android/particlefire/AndroidManifest.xml index ca1a6a5b..49383d38 100644 --- a/android/particlefire/AndroidManifest.xml +++ b/android/particlefire/AndroidManifest.xml @@ -15,6 +15,7 @@ android:label="Particle Fire" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:launchMode="singleTask" + android:screenOrientation="landscape" android:configChanges="orientation|screenSize|keyboardHidden"> diff --git a/android/particlefire/build.bat b/android/particlefire/build.bat deleted file mode 100644 index 3e2b8e90..00000000 --- a/android/particlefire/build.bat +++ /dev/null @@ -1,30 +0,0 @@ -cd jni -call ndk-build -if %ERRORLEVEL% EQU 0 ( - echo ndk-build has failed, build cancelled - cd.. - - mkdir "assets\shaders\base" - xcopy "..\..\data\shaders\base\*.spv" "assets\shaders\base" /Y - - - mkdir "assets\shaders\particlefire" - xcopy "..\..\data\shaders\particlefire\*.spv" "assets\shaders\particlefire" /Y - - mkdir "assets\textures" - xcopy "..\..\data\textures\fireplace_colormap_bc3.ktx" "assets\textures" /Y - xcopy "..\..\data\textures\fireplace_normalmap_bc3.ktx" "assets\textures" /Y - xcopy "..\..\data\textures\particle_fire.ktx" "assets\textures" /Y - xcopy "..\..\data\textures\particle_smoke.ktx" "assets\textures" /Y - - mkdir "assets\models" - xcopy "..\..\data\models\fireplace.obj" "assets\models" /Y - - mkdir "res\drawable" - xcopy "..\..\android\images\icon.png" "res\drawable" /Y - - call ant debug -Dout.final.file=vulkanParticlefire.apk -) ELSE ( - echo error : ndk-build failed with errors! - cd.. -) diff --git a/android/particlefire/build.py b/android/particlefire/build.py new file mode 100644 index 00000000..35cdd15f --- /dev/null +++ b/android/particlefire/build.py @@ -0,0 +1,47 @@ +import os +import shutil +import subprocess +import sys +import glob + +APK_NAME = "vulkanTessellation" +SHADER_DIR = "tessellation" +ASSETS_MODELS = ["deer.dae"] +ASSETS_TEXTURES = ["deer_bc3_unorm.ktx", "deer_astc_8x8_unorm.ktx", "deer_etc2_unorm.ktx"] + +if subprocess.call("ndk-build", shell=True) == 0: + print("Build successful") + + # Assets + os.makedirs("./assets/shaders/base", exist_ok=True) + os.makedirs("./assets/shaders/%s" % SHADER_DIR, exist_ok=True) + os.makedirs("./assets/textures", exist_ok=True) + os.makedirs("./assets/models/lowpoly", exist_ok=True) + os.makedirs("./res/drawable", exist_ok=True) + + # Shaders + # Base + for file in glob.glob("../../data/shaders/base/*.spv"): + shutil.copy(file, "./assets/shaders/base") + # Sample + for file in glob.glob("../../data/shaders/%s/*.spv" %SHADER_DIR): + shutil.copy(file, "./assets/shaders/%s" % SHADER_DIR) + # Textures + for file in ASSETS_TEXTURES: + shutil.copy("../../data/textures/%s" % file, "./assets/textures") + # Models + for file in ASSETS_MODELS: + shutil.copy("../../data/models/lowpoly/%s" % file, "./assets/models/lowpoly") + + # Icon + shutil.copy("../../android/images/icon.png", "./res/drawable") + + if subprocess.call("ant debug -Dout.final.file=%s.apk" % APK_NAME, shell=True) == 0: + if len(sys.argv) > 1: + if sys.argv[1] == "-deploy": + if subprocess.call("adb install -r %s.apk" % APK_NAME, shell=True) != 0: + print("Could not deploy to device!") + else: + print("Error during build process!") +else: + print("Error building project!") diff --git a/data/textures/fireplace_colormap_astc_8x8_unorm.ktx b/data/textures/fireplace_colormap_astc_8x8_unorm.ktx new file mode 100644 index 00000000..e0aa85aa Binary files /dev/null and b/data/textures/fireplace_colormap_astc_8x8_unorm.ktx differ diff --git a/data/textures/fireplace_colormap_bc3.ktx b/data/textures/fireplace_colormap_bc3_unorm.ktx similarity index 100% rename from data/textures/fireplace_colormap_bc3.ktx rename to data/textures/fireplace_colormap_bc3_unorm.ktx diff --git a/data/textures/fireplace_colormap_etc2_unorm.ktx b/data/textures/fireplace_colormap_etc2_unorm.ktx new file mode 100644 index 00000000..948547a3 Binary files /dev/null and b/data/textures/fireplace_colormap_etc2_unorm.ktx differ diff --git a/data/textures/fireplace_normalmap_astc_8x8_unorm.ktx b/data/textures/fireplace_normalmap_astc_8x8_unorm.ktx new file mode 100644 index 00000000..621fc215 Binary files /dev/null and b/data/textures/fireplace_normalmap_astc_8x8_unorm.ktx differ diff --git a/data/textures/fireplace_normalmap_bc3.ktx b/data/textures/fireplace_normalmap_bc3_unorm.ktx similarity index 100% rename from data/textures/fireplace_normalmap_bc3.ktx rename to data/textures/fireplace_normalmap_bc3_unorm.ktx diff --git a/data/textures/fireplace_normalmap_etc2_unorm.ktx b/data/textures/fireplace_normalmap_etc2_unorm.ktx new file mode 100644 index 00000000..8ac9531c Binary files /dev/null and b/data/textures/fireplace_normalmap_etc2_unorm.ktx differ diff --git a/particlefire/particlefire.cpp b/particlefire/particlefire.cpp index ea87ff56..e463e560 100644 --- a/particlefire/particlefire.cpp +++ b/particlefire/particlefire.cpp @@ -128,7 +128,7 @@ public: zoom = -75.0f; rotation = { -15.0f, 45.0f, 0.0f }; enableTextOverlay = true; - title = "Vulkan Example - Particle system"; + title = "Vulkan Example - CPU particle system"; zoomSpeed *= 1.5f; timerSpeed *= 8.0f; srand(time(NULL)); @@ -168,7 +168,6 @@ public: VkClearValue clearValues[2]; clearValues[0].color = defaultClearColor; - clearValues[0].color = { {0.0f, 0.0f, 0.0f, 0.0f} }; clearValues[1].depthStencil = { 1.0f, 0 }; VkRenderPassBeginInfo renderPassBeginInfo = vks::initializers::renderPassBeginInfo(); @@ -327,13 +326,33 @@ public: void loadAssets() { + // Textures + std::string texFormatSuffix; + VkFormat texFormat; + // Get supported compressed texture format + if (vulkanDevice->features.textureCompressionBC) { + texFormatSuffix = "_bc3_unorm"; + texFormat = VK_FORMAT_BC3_UNORM_BLOCK; + } + else if (vulkanDevice->features.textureCompressionASTC_LDR) { + texFormatSuffix = "_astc_8x8_unorm"; + texFormat = VK_FORMAT_ASTC_8x8_UNORM_BLOCK; + } + else if (vulkanDevice->features.textureCompressionETC2) { + texFormatSuffix = "_etc2_unorm"; + texFormat = VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK; + } + else { + vks::tools::exitFatal("Device does not support any compressed texture format!", "Error"); + } + // Particles - textures.particles.smoke.loadFromFile(getAssetPath() + "textures/particle_smoke.ktx", VK_FORMAT_BC3_UNORM_BLOCK, vulkanDevice, queue); - textures.particles.fire.loadFromFile(getAssetPath() + "textures/particle_fire.ktx", VK_FORMAT_BC3_UNORM_BLOCK, vulkanDevice, queue); + textures.particles.smoke.loadFromFile(getAssetPath() + "textures/particle_smoke.ktx", VK_FORMAT_R8G8B8A8_UNORM, vulkanDevice, queue); + textures.particles.fire.loadFromFile(getAssetPath() + "textures/particle_fire.ktx", VK_FORMAT_R8G8B8A8_UNORM, vulkanDevice, queue); // Floor - textures.floor.colorMap.loadFromFile(getAssetPath() + "textures/fireplace_colormap_bc3.ktx", VK_FORMAT_BC3_UNORM_BLOCK, vulkanDevice, queue); - textures.floor.normalMap.loadFromFile(getAssetPath() + "textures/fireplace_normalmap_bc3.ktx", VK_FORMAT_BC3_UNORM_BLOCK, vulkanDevice, queue); + textures.floor.colorMap.loadFromFile(getAssetPath() + "textures/fireplace_colormap" + texFormatSuffix + ".ktx", texFormat, vulkanDevice, queue); + textures.floor.normalMap.loadFromFile(getAssetPath() + "textures/fireplace_normalmap" + texFormatSuffix + ".ktx", texFormat, vulkanDevice, queue); // Create a custom sampler to be used with the particle textures // Create sampler