Added Android build files and seettings for SSAO example
This commit is contained in:
parent
06369fc72e
commit
54ddca7c08
10 changed files with 142 additions and 13 deletions
|
|
@ -95,6 +95,7 @@ set(EXAMPLES
|
||||||
shadowmappingomni
|
shadowmappingomni
|
||||||
skeletalanimation
|
skeletalanimation
|
||||||
sphericalenvmapping
|
sphericalenvmapping
|
||||||
|
ssao
|
||||||
terraintessellation
|
terraintessellation
|
||||||
tessellation
|
tessellation
|
||||||
textoverlay
|
textoverlay
|
||||||
|
|
|
||||||
10
android/ssao/.gitignore
vendored
Normal file
10
android/ssao/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
/assets/
|
||||||
|
/res/
|
||||||
|
/bin/
|
||||||
|
/libs/
|
||||||
|
/obj/
|
||||||
|
/build.xml
|
||||||
|
/local.properties
|
||||||
|
/project.properties
|
||||||
|
/proguard-project.txt
|
||||||
|
*.apk
|
||||||
27
android/ssao/AndroidManifest.xml
Normal file
27
android/ssao/AndroidManifest.xml
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
package="de.saschawillems.vulkanSSAO"
|
||||||
|
android:versionCode="1"
|
||||||
|
android:versionName="1.0">
|
||||||
|
|
||||||
|
<uses-sdk android:minSdkVersion="19" />
|
||||||
|
|
||||||
|
<uses-feature android:name="android.hardware.touchscreen" android:required="false"/>
|
||||||
|
<uses-feature android:name="android.hardware.gamepad" android:required="false"/>
|
||||||
|
<uses-feature android:name="android.software.leanback" android:required="false"/>
|
||||||
|
|
||||||
|
<application android:label="vulkanSSAO" android:icon="@drawable/icon" android:hasCode="false">
|
||||||
|
<activity android:name="android.app.NativeActivity"
|
||||||
|
android:label="SSAO"
|
||||||
|
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
|
||||||
|
android:launchMode="singleTask"
|
||||||
|
android:configChanges="orientation|screenSize|keyboardHidden">
|
||||||
|
<meta-data android:name="android.app.lib_name" android:value="vulkanSSAO" />
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
<category android:name="android.intent.category.LEANBACK_LAUNCHER"/>
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
</application>
|
||||||
|
</manifest>
|
||||||
22
android/ssao/build.bat
Normal file
22
android/ssao/build.bat
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
cd jni
|
||||||
|
call ndk-build
|
||||||
|
if %ERRORLEVEL% EQU 0 (
|
||||||
|
cd..
|
||||||
|
|
||||||
|
mkdir "assets\shaders\base"
|
||||||
|
xcopy "..\..\data\shaders\base\*.spv" "assets\shaders\base" /Y
|
||||||
|
|
||||||
|
mkdir "assets\shaders\ssao"
|
||||||
|
xcopy "..\..\data\shaders\ssao\*.spv" "assets\shaders\ssao" /Y
|
||||||
|
|
||||||
|
mkdir "assets\models\sibenik"
|
||||||
|
xcopy "..\..\data\models\sibenik\sibenik.dae" "assets\models\sibenik" /Y
|
||||||
|
|
||||||
|
mkdir "res\drawable"
|
||||||
|
xcopy "..\..\android\images\icon.png" "res\drawable" /Y
|
||||||
|
|
||||||
|
call ant debug -Dout.final.file=vulkanSSAO.apk
|
||||||
|
) ELSE (
|
||||||
|
echo error : ndk-build failed with errors!
|
||||||
|
cd..
|
||||||
|
)
|
||||||
48
android/ssao/jni/Android.mk
Normal file
48
android/ssao/jni/Android.mk
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
LOCAL_PATH := $(call my-dir)/../../ssao
|
||||||
|
|
||||||
|
# assimp
|
||||||
|
|
||||||
|
include $(CLEAR_VARS)
|
||||||
|
|
||||||
|
LOCAL_MODULE := assimp
|
||||||
|
LOCAL_SRC_FILES := $(LOCAL_PATH)/../../libs/assimp/$(TARGET_ARCH_ABI)/libassimp.a
|
||||||
|
include $(PREBUILT_STATIC_LIBRARY)
|
||||||
|
|
||||||
|
# vulkan example
|
||||||
|
|
||||||
|
DATADIR := $(LOCAL_PATH)/../../data
|
||||||
|
|
||||||
|
include $(CLEAR_VARS)
|
||||||
|
|
||||||
|
LOCAL_MODULE := vulkanSSAO
|
||||||
|
|
||||||
|
PROJECT_FILES := $(wildcard $(LOCAL_PATH)/../../ssao/*.cpp)
|
||||||
|
PROJECT_FILES += $(wildcard $(LOCAL_PATH)/../../base/*.cpp)
|
||||||
|
|
||||||
|
LOCAL_CPPFLAGS := -std=c++11
|
||||||
|
LOCAL_CPPFLAGS += -D__STDC_LIMIT_MACROS
|
||||||
|
LOCAL_CPPFLAGS += -DVK_NO_PROTOTYPES
|
||||||
|
LOCAL_CPPFLAGS += -DVK_USE_PLATFORM_ANDROID_KHR
|
||||||
|
|
||||||
|
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../external/
|
||||||
|
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../external/glm
|
||||||
|
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../external/gli
|
||||||
|
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../external/assimp
|
||||||
|
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../base/
|
||||||
|
#LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../base/android
|
||||||
|
|
||||||
|
LOCAL_SRC_FILES := $(PROJECT_FILES)
|
||||||
|
|
||||||
|
LOCAL_LDLIBS := -landroid -llog -lz
|
||||||
|
|
||||||
|
LOCAL_DISABLE_FORMAT_STRING_CHECKS := true
|
||||||
|
LOCAL_DISABLE_FATAL_LINKER_WARNINGS := true
|
||||||
|
|
||||||
|
LOCAL_STATIC_LIBRARIES += android_native_app_glue
|
||||||
|
LOCAL_STATIC_LIBRARIES += cpufeatures
|
||||||
|
LOCAL_STATIC_LIBRARIES += libassimp
|
||||||
|
|
||||||
|
include $(BUILD_SHARED_LIBRARY)
|
||||||
|
|
||||||
|
$(call import-module, android/native_app_glue)
|
||||||
|
$(call import-module, android/cpufeatures)
|
||||||
5
android/ssao/jni/Application.mk
Normal file
5
android/ssao/jni/Application.mk
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
APP_PLATFORM := android-19
|
||||||
|
APP_ABI := armeabi-v7a
|
||||||
|
APP_STL := c++_static
|
||||||
|
APP_CPPFLAGS := -std=c++11
|
||||||
|
NDK_TOOLCHAIN_VERSION := clang
|
||||||
|
|
@ -35,6 +35,8 @@
|
||||||
#define KEY_F2 0x2
|
#define KEY_F2 0x2
|
||||||
#define KEY_F2 0x11
|
#define KEY_F2 0x11
|
||||||
#define KEY_F2 0x12
|
#define KEY_F2 0x12
|
||||||
|
#define KEY_F3 0x13
|
||||||
|
#define KEY_F4 0x14
|
||||||
#define KEY_W 0x3
|
#define KEY_W 0x3
|
||||||
#define KEY_A 0x4
|
#define KEY_A 0x4
|
||||||
#define KEY_S 0x5
|
#define KEY_S 0x5
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ layout (location = 0) in vec2 inUV;
|
||||||
layout (location = 0) out float outFragColor;
|
layout (location = 0) out float outFragColor;
|
||||||
|
|
||||||
// todo: specialization const
|
// todo: specialization const
|
||||||
const int kernelSize = 64;
|
const int kernelSize = 32;
|
||||||
const float radius = 0.5;
|
const float radius = 0.5;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -24,8 +24,13 @@
|
||||||
#define VERTEX_BUFFER_BIND_ID 0
|
#define VERTEX_BUFFER_BIND_ID 0
|
||||||
#define ENABLE_VALIDATION false
|
#define ENABLE_VALIDATION false
|
||||||
|
|
||||||
#define SSAO_KERNEL_SIZE 64
|
#define SSAO_KERNEL_SIZE 32
|
||||||
|
|
||||||
|
#if defined(__ANDROID__)
|
||||||
|
#define SSAO_NOISE_DIM 8
|
||||||
|
#else
|
||||||
#define SSAO_NOISE_DIM 4
|
#define SSAO_NOISE_DIM 4
|
||||||
|
#endif
|
||||||
|
|
||||||
// Vertex layout for this example
|
// Vertex layout for this example
|
||||||
std::vector<vkMeshLoader::VertexLayout> vertexLayout =
|
std::vector<vkMeshLoader::VertexLayout> vertexLayout =
|
||||||
|
|
@ -215,7 +220,8 @@ public:
|
||||||
VkFormat format,
|
VkFormat format,
|
||||||
VkImageUsageFlagBits usage,
|
VkImageUsageFlagBits usage,
|
||||||
FrameBufferAttachment *attachment,
|
FrameBufferAttachment *attachment,
|
||||||
VkCommandBuffer layoutCmd)
|
uint32_t width,
|
||||||
|
uint32_t height)
|
||||||
{
|
{
|
||||||
VkImageAspectFlags aspectMask = 0;
|
VkImageAspectFlags aspectMask = 0;
|
||||||
VkImageLayout imageLayout;
|
VkImageLayout imageLayout;
|
||||||
|
|
@ -275,8 +281,16 @@ public:
|
||||||
// Attachments
|
// Attachments
|
||||||
VkCommandBuffer layoutCmd = VulkanExampleBase::createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
VkCommandBuffer layoutCmd = VulkanExampleBase::createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||||
|
|
||||||
|
#if defined(__ANDROID__)
|
||||||
|
const uint32_t ssaoWidth = width / 2;
|
||||||
|
const uint32_t ssaoHeight = height / 2;
|
||||||
|
#else
|
||||||
|
const uint32_t ssaoWidth = width;
|
||||||
|
const uint32_t ssaoHeight = height;
|
||||||
|
#endif
|
||||||
|
|
||||||
frameBuffers.offscreen.setSize(width, height);
|
frameBuffers.offscreen.setSize(width, height);
|
||||||
frameBuffers.ssao.setSize(width, height);
|
frameBuffers.ssao.setSize(ssaoWidth, ssaoHeight);
|
||||||
frameBuffers.ssaoBlur.setSize(width, height);
|
frameBuffers.ssaoBlur.setSize(width, height);
|
||||||
|
|
||||||
// Find a suitable depth format
|
// Find a suitable depth format
|
||||||
|
|
@ -285,16 +299,16 @@ public:
|
||||||
assert(validDepthFormat);
|
assert(validDepthFormat);
|
||||||
|
|
||||||
// G-Buffer
|
// G-Buffer
|
||||||
createAttachment(VK_FORMAT_R32G32B32A32_SFLOAT, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, &frameBuffers.offscreen.position, layoutCmd); // Position + Depth
|
createAttachment(VK_FORMAT_R32G32B32A32_SFLOAT, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, &frameBuffers.offscreen.position, width, height); // Position + Depth
|
||||||
createAttachment(VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, &frameBuffers.offscreen.normal, layoutCmd); // Normals
|
createAttachment(VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, &frameBuffers.offscreen.normal, width, height); // Normals
|
||||||
createAttachment(VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, &frameBuffers.offscreen.albedo, layoutCmd); // Albedo (color)
|
createAttachment(VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, &frameBuffers.offscreen.albedo, width, height); // Albedo (color)
|
||||||
createAttachment(attDepthFormat, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, &frameBuffers.offscreen.depth, layoutCmd); // Depth
|
createAttachment(attDepthFormat, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, &frameBuffers.offscreen.depth, width, height); // Depth
|
||||||
|
|
||||||
// SSAO
|
// SSAO
|
||||||
createAttachment(VK_FORMAT_R8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, &frameBuffers.ssao.color, layoutCmd); // Color
|
createAttachment(VK_FORMAT_R8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, &frameBuffers.ssao.color, ssaoWidth, ssaoHeight); // Color
|
||||||
|
|
||||||
// SSAO blur
|
// SSAO blur
|
||||||
createAttachment(VK_FORMAT_R8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, &frameBuffers.ssaoBlur.color, layoutCmd); // Color
|
createAttachment(VK_FORMAT_R8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, &frameBuffers.ssaoBlur.color, width, height); // Color
|
||||||
|
|
||||||
VulkanExampleBase::flushCommandBuffer(layoutCmd, queue, true);
|
VulkanExampleBase::flushCommandBuffer(layoutCmd, queue, true);
|
||||||
|
|
||||||
|
|
@ -1120,7 +1134,7 @@ public:
|
||||||
toggleSSAO();
|
toggleSSAO();
|
||||||
break;
|
break;
|
||||||
case KEY_F3:
|
case KEY_F3:
|
||||||
case GAMEPAD_BUTTON_B:
|
case GAMEPAD_BUTTON_X:
|
||||||
toggleSSAOBlur();
|
toggleSSAOBlur();
|
||||||
break;
|
break;
|
||||||
case KEY_F4:
|
case KEY_F4:
|
||||||
|
|
@ -1134,7 +1148,7 @@ public:
|
||||||
{
|
{
|
||||||
#if defined(__ANDROID__)
|
#if defined(__ANDROID__)
|
||||||
textOverlay->addText("\"Button A\" to toggle SSAO", 5.0f, 85.0f, VulkanTextOverlay::alignLeft);
|
textOverlay->addText("\"Button A\" to toggle SSAO", 5.0f, 85.0f, VulkanTextOverlay::alignLeft);
|
||||||
textOverlay->addText("\"Button B\" to toggle SSAO blur", 5.0f, 100.0f, VulkanTextOverlay::alignLeft);
|
textOverlay->addText("\"Button X\" to toggle SSAO blur", 5.0f, 100.0f, VulkanTextOverlay::alignLeft);
|
||||||
textOverlay->addText("\"Button Y\" to toggle SSAO display", 5.0f, 115.0f, VulkanTextOverlay::alignLeft);
|
textOverlay->addText("\"Button Y\" to toggle SSAO display", 5.0f, 115.0f, VulkanTextOverlay::alignLeft);
|
||||||
#else
|
#else
|
||||||
textOverlay->addText("\"F2\" to toggle SSAO", 5.0f, 85.0f, VulkanTextOverlay::alignLeft);
|
textOverlay->addText("\"F2\" to toggle SSAO", 5.0f, 85.0f, VulkanTextOverlay::alignLeft);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue