Added resources and android build for scene rendering example

This commit is contained in:
saschawillems 2016-06-12 17:42:35 +02:00
parent 14e327c353
commit b1b828b45f
19 changed files with 1126 additions and 1 deletions

View file

@ -29,4 +29,5 @@ call _build raytracing %1
call _build multisampling %1
call _build multithreading %1
call _build textoverlay %1
call _build debugmarker %1
call _build debugmarker %1
call _build scenerendering %1

10
android/scenerendering/.gitignore vendored Normal file
View file

@ -0,0 +1,10 @@
/assets/
/res/
/bin/
/libs/
/obj/
/build.xml
/local.properties
/project.properties
/proguard-project.txt
*.apk

View 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.vulkanScenerendering"
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="vulkanScenerendering" android:icon="@drawable/icon" android:hasCode="false">
<activity android:name="android.app.NativeActivity"
android:label="Scene rendering"
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="vulkanScenerendering" />
<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>

View file

@ -0,0 +1,23 @@
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\scenerendering"
xcopy "..\..\data\shaders\scenerendering\*.*" "assets\shaders\scenerendering" /Y
mkdir "assets\models\sibenik"
xcopy "..\..\data\models\sibenik\*.*" "assets\models\sibenik" /Y
mkdir "res\drawable"
xcopy "..\..\android\images\icon.png" "res\drawable" /Y
call ant debug -Dout.final.file=vulkanScenerendering.apk
) ELSE (
echo error : ndk-build failed with errors!
cd..
)

View file

@ -0,0 +1,48 @@
LOCAL_PATH := $(call my-dir)/../../scenerendering
# 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 := vulkanScenerendering
PROJECT_FILES := $(wildcard $(LOCAL_PATH)/../../scenerendering/*.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)

View 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

View file

@ -37,6 +37,7 @@ adb uninstall de.saschawillems.vulkanMultisampling
adb uninstall de.saschawillems.vulkanMultithreading
adb uninstall de.saschawillems.vulkanTextoverlay
adb uninstall de.saschawillems.vulkanDebugmarker
adb uninstall de.saschawillems.vulkanScenerendering
goto finish
:exit

Binary file not shown.

View file

@ -0,0 +1,9 @@
Sibenik by Marko Dabrovic, with holes corrected by Kenzie Lamar at
Vicarious Visions and high-resolution texture and bump maps painted by
Morgan McGuire.
Downloaded from http://igad.nhtv.nl/~bikker/
Originally from http://hdri.cgtechniques.com/~sibenik2/download/
"The Sibenik cathedral is a project by Marko Dabrovic form www.RNA.HR .
It's very rich modeled but isn't completly finished yet... there are some holes in the mesh which only hurts if you look at them."

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,2 @@
glslangvalidator -V scene.vert -o scene.vert.spv
glslangvalidator -V scene.frag -o scene.frag.spv

View file

@ -0,0 +1,34 @@
#version 450
#extension GL_ARB_separate_shader_objects : enable
#extension GL_ARB_shading_language_420pack : enable
layout (set = 1, binding = 0) uniform sampler2D samplerColorMap;
layout (location = 0) in vec3 inNormal;
layout (location = 1) in vec3 inColor;
layout (location = 2) in vec2 inUV;
layout (location = 3) in vec3 inViewVec;
layout (location = 4) in vec3 inLightVec;
layout(push_constant) uniform Material
{
vec4 ambient;
vec4 diffuse;
vec4 specular;
float opacity;
} material;
layout (location = 0) out vec4 outFragColor;
void main()
{
vec4 color = texture(samplerColorMap, inUV) * vec4(inColor, 1.0);
vec3 N = normalize(inNormal);
vec3 L = normalize(inLightVec);
vec3 V = normalize(inViewVec);
vec3 R = reflect(-L, N);
vec3 diffuse = max(dot(N, L), 0.0) * material.diffuse.rgb;
vec3 specular = pow(max(dot(R, V), 0.0), 16.0) * material.specular.rgb;
outFragColor = vec4((material.ambient.rgb + diffuse) * color.rgb + specular, 1.0-material.opacity);
}

Binary file not shown.

View file

@ -0,0 +1,40 @@
#version 450
#extension GL_ARB_separate_shader_objects : enable
#extension GL_ARB_shading_language_420pack : enable
layout (location = 0) in vec3 inPos;
layout (location = 1) in vec3 inNormal;
layout (location = 2) in vec2 inUV;
layout (location = 3) in vec3 inColor;
layout (set = 0, binding = 0) uniform UBO
{
mat4 projection;
mat4 view;
mat4 model;
vec4 lightPos;
} ubo;
layout (location = 0) out vec3 outNormal;
layout (location = 1) out vec3 outColor;
layout (location = 2) out vec2 outUV;
layout (location = 3) out vec3 outViewVec;
layout (location = 4) out vec3 outLightVec;
void main()
{
outNormal = inNormal;
outColor = inColor;
outUV = inUV;
mat4 modelView = ubo.view * ubo.model;
gl_Position = ubo.projection * modelView * vec4(inPos.xyz, 1.0);
vec4 pos = modelView * vec4(inPos, 0.0);
outNormal = mat3(ubo.model) * inNormal;
vec3 lPos = mat3(ubo.model) * ubo.lightPos.xyz;
outLightVec = lPos - (ubo.model * vec4(inPos, 0.0)).xyz;
outViewVec = -(ubo.model * vec4(inPos, 0.0)).xyz;
}

Binary file not shown.

View file

@ -67,6 +67,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "textoverlay", "textoverlay\
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "debugmarker", "debugmarker\debugmarker.vcxproj", "{146FD6F8-5CB4-478E-A823-7350A0ACCF1D}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "scenerendering", "scenerendering\scenerendering.vcxproj", "{D928DFBB-DB07-411E-A650-6D3CE697D7D0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
@ -201,6 +203,10 @@ Global
{146FD6F8-5CB4-478E-A823-7350A0ACCF1D}.Debug|x64.Build.0 = Debug|x64
{146FD6F8-5CB4-478E-A823-7350A0ACCF1D}.Release|x64.ActiveCfg = Release|x64
{146FD6F8-5CB4-478E-A823-7350A0ACCF1D}.Release|x64.Build.0 = Release|x64
{D928DFBB-DB07-411E-A650-6D3CE697D7D0}.Debug|x64.ActiveCfg = Debug|x64
{D928DFBB-DB07-411E-A650-6D3CE697D7D0}.Debug|x64.Build.0 = Debug|x64
{D928DFBB-DB07-411E-A650-6D3CE697D7D0}.Release|x64.ActiveCfg = Release|x64
{D928DFBB-DB07-411E-A650-6D3CE697D7D0}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE