Added ETC2 and ASTC texture variants (Refs #174)

This commit is contained in:
saschawillems 2017-03-17 21:34:32 +01:00
parent 4e1e509e8f
commit 0389db86da
10 changed files with 73 additions and 36 deletions

View file

@ -15,6 +15,7 @@
android:label="Particle Fire" android:label="Particle Fire"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:launchMode="singleTask" android:launchMode="singleTask"
android:screenOrientation="landscape"
android:configChanges="orientation|screenSize|keyboardHidden"> android:configChanges="orientation|screenSize|keyboardHidden">
<meta-data android:name="android.app.lib_name" android:value="vulkanParticlefire" /> <meta-data android:name="android.app.lib_name" android:value="vulkanParticlefire" />
<intent-filter> <intent-filter>

View file

@ -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..
)

View file

@ -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!")

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -128,7 +128,7 @@ public:
zoom = -75.0f; zoom = -75.0f;
rotation = { -15.0f, 45.0f, 0.0f }; rotation = { -15.0f, 45.0f, 0.0f };
enableTextOverlay = true; enableTextOverlay = true;
title = "Vulkan Example - Particle system"; title = "Vulkan Example - CPU particle system";
zoomSpeed *= 1.5f; zoomSpeed *= 1.5f;
timerSpeed *= 8.0f; timerSpeed *= 8.0f;
srand(time(NULL)); srand(time(NULL));
@ -168,7 +168,6 @@ public:
VkClearValue clearValues[2]; VkClearValue clearValues[2];
clearValues[0].color = defaultClearColor; clearValues[0].color = defaultClearColor;
clearValues[0].color = { {0.0f, 0.0f, 0.0f, 0.0f} };
clearValues[1].depthStencil = { 1.0f, 0 }; clearValues[1].depthStencil = { 1.0f, 0 };
VkRenderPassBeginInfo renderPassBeginInfo = vks::initializers::renderPassBeginInfo(); VkRenderPassBeginInfo renderPassBeginInfo = vks::initializers::renderPassBeginInfo();
@ -327,13 +326,33 @@ public:
void loadAssets() 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 // Particles
textures.particles.smoke.loadFromFile(getAssetPath() + "textures/particle_smoke.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_BC3_UNORM_BLOCK, vulkanDevice, queue); textures.particles.fire.loadFromFile(getAssetPath() + "textures/particle_fire.ktx", VK_FORMAT_R8G8B8A8_UNORM, vulkanDevice, queue);
// Floor // Floor
textures.floor.colorMap.loadFromFile(getAssetPath() + "textures/fireplace_colormap_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_bc3.ktx", VK_FORMAT_BC3_UNORM_BLOCK, 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 a custom sampler to be used with the particle textures
// Create sampler // Create sampler