├── android
├── gltf
│ ├── .gitignore
│ ├── src
│ │ └── main
│ │ │ ├── res
│ │ │ ├── values
│ │ │ │ ├── strings.xml
│ │ │ │ ├── colors.xml
│ │ │ │ └── styles.xml
│ │ │ ├── mipmap-hdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── ic_launcher_round.png
│ │ │ │ └── ic_launcher_foreground.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── ic_launcher_round.png
│ │ │ │ └── ic_launcher_foreground.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── ic_launcher_round.png
│ │ │ │ └── ic_launcher_foreground.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── ic_launcher_round.png
│ │ │ │ └── ic_launcher_foreground.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── ic_launcher_round.png
│ │ │ │ └── ic_launcher_foreground.png
│ │ │ ├── mipmap-anydpi-v26
│ │ │ │ ├── ic_launcher.xml
│ │ │ │ └── ic_launcher_round.xml
│ │ │ └── drawable
│ │ │ │ └── ic_launcher_background.xml
│ │ │ └── AndroidManifest.xml
│ ├── proguard-rules.pro
│ └── build.gradle
├── settings.gradle
├── vulkan_wrapper
│ └── CMakeLists.txt
├── .gitignore
├── CMakeLists.txt
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── common
│ ├── CMakeLists.txt
│ ├── android_common.h
│ └── android_common.cpp
├── build.gradle
├── gradle.properties
├── gradlew.bat
└── gradlew
├── docs
└── .gitignore
├── README.md
├── ci-script
├── .gitignore
├── lavos
├── glsl
│ ├── material
│ │ ├── common.glsl
│ │ ├── common_frag.glsl
│ │ ├── common_camera.glsl
│ │ ├── lighting_phong.glsl
│ │ ├── shadow.vf.shader
│ │ ├── unlit.vf.shader
│ │ ├── common_vert.glsl
│ │ ├── point_cloud.vf.shader
│ │ ├── gouraud.vf.shader
│ │ ├── common_lighting.glsl
│ │ └── phong.vf.shader
│ ├── common_glsl_cpp.h
│ └── lib
│ │ └── msm.glsl
├── cmake
│ ├── generate_resources_src.cmake.in
│ ├── FindShaderc.cmake
│ ├── ResourceGenerator_header.h.in
│ ├── ResourceGenerator_source.cpp.in
│ ├── ShaderResources.cmake
│ └── ResourceGenerator.cmake
├── src
│ ├── scene.cpp
│ ├── sub_renderer.cpp
│ ├── component
│ │ ├── directional_light.cpp
│ │ ├── transform_component.cpp
│ │ ├── fp_controller.cpp
│ │ ├── mesh_component.cpp
│ │ └── spot_light.cpp
│ ├── render_config.cpp
│ ├── buffer.cpp
│ ├── thirdparty_impl.cpp
│ ├── light_collection.cpp
│ ├── log.cpp
│ ├── shader_load.cpp
│ ├── texture.cpp
│ ├── mesh.cpp
│ ├── material
│ │ ├── point_cloud_material.cpp
│ │ ├── material.cpp
│ │ ├── gouraud_material.cpp
│ │ ├── unlit_material.cpp
│ │ └── material_instance.cpp
│ ├── glm_stream.h
│ ├── node.cpp
│ ├── render_target.cpp
│ └── image.cpp
├── include
│ └── lavos
│ │ ├── shader_load.h
│ │ ├── glm_config.h
│ │ ├── component
│ │ ├── component.h
│ │ ├── directional_light.h
│ │ ├── fp_controller.h
│ │ ├── mesh_component.h
│ │ ├── transform_component.h
│ │ ├── spot_light.h
│ │ ├── point_cloud_component.h
│ │ └── camera.h
│ │ ├── log.h
│ │ ├── sub_renderer.h
│ │ ├── light_collection.h
│ │ ├── buffer.h
│ │ ├── scene.h
│ │ ├── render_config.h
│ │ ├── asset_container.h
│ │ ├── texture.h
│ │ ├── mesh.h
│ │ ├── material
│ │ ├── unlit_material.h
│ │ ├── gouraud_material.h
│ │ ├── phong_material.h
│ │ ├── point_cloud_material.h
│ │ ├── material_instance.h
│ │ └── material.h
│ │ ├── renderable.h
│ │ ├── image.h
│ │ ├── point_cloud.h
│ │ ├── spot_light_shadow.h
│ │ ├── swapchain.h
│ │ ├── spot_light_shadow_renderer.h
│ │ ├── vertex.h
│ │ ├── material_pipeline_manager.h
│ │ ├── render_target.h
│ │ ├── node.h
│ │ ├── engine.h
│ │ └── renderer.h
└── CMakeLists.txt
├── shell
├── CMakeLists.txt
├── qt
│ ├── include
│ │ ├── platform.h
│ │ └── lavos_window.h
│ ├── CMakeLists.txt
│ └── src
│ │ ├── platform.cpp
│ │ └── lavos_window.cpp
└── glfw
│ ├── CMakeLists.txt
│ └── include
│ └── window_application.h
├── demos
├── 2d
│ ├── CMakeLists.txt
│ └── 2d.cpp
├── gltf
│ ├── CMakeLists.txt
│ └── gltf.cpp
├── room
│ └── CMakeLists.txt
├── firstperson
│ ├── CMakeLists.txt
│ └── firstperson.cpp
├── qt_shell
│ ├── CMakeLists.txt
│ ├── lavos_renderer.h
│ ├── main.cpp
│ └── lavos_renderer.cpp
├── qt_qvulkanwindow
│ ├── CMakeLists.txt
│ ├── main.cpp
│ ├── mainwindow.cpp
│ └── mainwindow.h
├── point_cloud
│ ├── CMakeLists.txt
│ └── point_cloud.cpp
└── CMakeLists.txt
├── Dockerfile
├── .gitmodules
├── .github
└── workflows
│ └── ci.yml
├── cmake
└── FindVulkanHPP.cmake
└── CMakeLists.txt
/android/gltf/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/android/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = "vulkan-android"
2 | include ':gltf'
--------------------------------------------------------------------------------
/docs/.gitignore:
--------------------------------------------------------------------------------
1 | Makefile
2 | build/
3 | html/
4 | latex/
5 | source/
6 | xml/
7 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Lavos
2 |
3 | This repo has been moved to: https://git.sr.ht/~thestr4ng3r/lavos
4 |
--------------------------------------------------------------------------------
/ci-script:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | set -e
4 | set -x
5 |
6 | mkdir build && cd build
7 | cmake ..
8 | make -j8
9 |
--------------------------------------------------------------------------------
/android/gltf/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Vulkan
3 |
4 |
--------------------------------------------------------------------------------
/android/vulkan_wrapper/CMakeLists.txt:
--------------------------------------------------------------------------------
1 |
2 | add_library(vulkan_wrapper STATIC
3 | vulkan_wrapper.cpp
4 | vulkan_wrapper.h)
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .idea
2 | build
3 | cmake-build-*
4 | *.swp
5 | *.spv
6 | raw/
7 | /thirdparty/vulkansdk*
8 | /thirdparty/shaderc*
9 |
--------------------------------------------------------------------------------
/android/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea
5 | .DS_Store
6 | /build
7 | /captures
8 | .externalNativeBuild
9 |
--------------------------------------------------------------------------------
/android/CMakeLists.txt:
--------------------------------------------------------------------------------
1 |
2 | #add_subdirectory(vulkan_wrapper)
3 | add_subdirectory(common)
4 |
5 | #add_subdirectory("${MODULE_NAME}")
--------------------------------------------------------------------------------
/android/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thestr4ng3r/lavos/HEAD/android/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/lavos/glsl/material/common.glsl:
--------------------------------------------------------------------------------
1 |
2 | #ifndef _MATERIAL_COMMON_GLSL
3 | #define _MATERIAL_COMMON_GLSL
4 |
5 | #include "../common_glsl_cpp.h"
6 |
7 | #endif
--------------------------------------------------------------------------------
/android/gltf/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thestr4ng3r/lavos/HEAD/android/gltf/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/gltf/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thestr4ng3r/lavos/HEAD/android/gltf/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/gltf/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thestr4ng3r/lavos/HEAD/android/gltf/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/gltf/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thestr4ng3r/lavos/HEAD/android/gltf/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/lavos/cmake/generate_resources_src.cmake.in:
--------------------------------------------------------------------------------
1 |
2 | include("@RESOURCE_GENERATOR_INCLUDE@")
3 |
4 | generate_resources(GENERATE_SOURCE @GENERATE_RESOURCES_ARGS@)
5 |
--------------------------------------------------------------------------------
/android/gltf/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thestr4ng3r/lavos/HEAD/android/gltf/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/shell/CMakeLists.txt:
--------------------------------------------------------------------------------
1 |
2 | if(LAVOS_BUILD_SHELL_GLFW)
3 | add_subdirectory(glfw)
4 | endif()
5 |
6 | if(LAVOS_BUILD_SHELL_QT)
7 | add_subdirectory(qt)
8 | endif()
--------------------------------------------------------------------------------
/android/gltf/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thestr4ng3r/lavos/HEAD/android/gltf/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/android/gltf/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thestr4ng3r/lavos/HEAD/android/gltf/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/android/gltf/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thestr4ng3r/lavos/HEAD/android/gltf/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/android/gltf/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thestr4ng3r/lavos/HEAD/android/gltf/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/android/gltf/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thestr4ng3r/lavos/HEAD/android/gltf/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/android/gltf/src/main/res/mipmap-hdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thestr4ng3r/lavos/HEAD/android/gltf/src/main/res/mipmap-hdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/android/gltf/src/main/res/mipmap-mdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thestr4ng3r/lavos/HEAD/android/gltf/src/main/res/mipmap-mdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/android/gltf/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thestr4ng3r/lavos/HEAD/android/gltf/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/android/gltf/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thestr4ng3r/lavos/HEAD/android/gltf/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/android/gltf/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thestr4ng3r/lavos/HEAD/android/gltf/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/lavos/src/scene.cpp:
--------------------------------------------------------------------------------
1 |
2 | #include "lavos/scene.h"
3 |
4 | lavos::Scene::Scene()
5 | {
6 | root_node.is_root = true;
7 | }
8 |
9 | lavos::Scene::~Scene()
10 | {
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/lavos/src/sub_renderer.cpp:
--------------------------------------------------------------------------------
1 |
2 | #include
3 |
4 | #include "lavos/sub_renderer.h"
5 |
6 | lavos::SubRenderer::SubRenderer(lavos::Engine *engine) : engine(engine)
7 | {
8 | }
9 |
--------------------------------------------------------------------------------
/lavos/glsl/material/common_frag.glsl:
--------------------------------------------------------------------------------
1 |
2 | #ifndef _MATERIAL_COMMON_FRAG_GLSL
3 | #define _MATERIAL_COMMON_FRAG_GLSL
4 |
5 | #include "common.glsl"
6 |
7 | layout(location = 0) out vec4 out_color;
8 |
9 | #endif
--------------------------------------------------------------------------------
/demos/2d/CMakeLists.txt:
--------------------------------------------------------------------------------
1 |
2 | set(SOURCE_FILES
3 | 2d.cpp)
4 |
5 | add_executable(2d ${SOURCE_FILES})
6 | target_link_libraries(2d
7 | lavos
8 | lavos_shell_glfw
9 | glfw
10 | ${Vulkan_LIBRARIES})
--------------------------------------------------------------------------------
/demos/gltf/CMakeLists.txt:
--------------------------------------------------------------------------------
1 |
2 | set(SOURCE_FILES
3 | gltf.cpp)
4 |
5 | add_executable(gltf ${SOURCE_FILES})
6 | target_link_libraries(gltf
7 | lavos
8 | lavos_shell_glfw
9 | glfw
10 | ${Vulkan_LIBRARIES})
--------------------------------------------------------------------------------
/demos/room/CMakeLists.txt:
--------------------------------------------------------------------------------
1 |
2 | set(SOURCE_FILES
3 | room.cpp)
4 |
5 | add_executable(room ${SOURCE_FILES})
6 | target_link_libraries(room
7 | lavos
8 | lavos_shell_glfw
9 | glfw
10 | ${Vulkan_LIBRARIES})
--------------------------------------------------------------------------------
/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM archlinux:latest
2 | MAINTAINER thestr4ng3r
3 |
4 | RUN pacman --noconfirm -Syu \
5 | base-devel \
6 | git \
7 | vulkan-headers \
8 | shaderc \
9 | cmake \
10 | vulkan-icd-loader \
11 | glfw-x11
12 |
13 | CMD []
14 |
--------------------------------------------------------------------------------
/demos/firstperson/CMakeLists.txt:
--------------------------------------------------------------------------------
1 |
2 | set(SOURCE_FILES
3 | firstperson.cpp)
4 |
5 | add_executable(firstperson ${SOURCE_FILES})
6 | target_link_libraries(firstperson
7 | lavos
8 | lavos_shell_glfw
9 | glfw
10 | ${Vulkan_LIBRARIES})
--------------------------------------------------------------------------------
/android/gltf/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sat Sep 02 11:00:47 CEST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
7 |
--------------------------------------------------------------------------------
/lavos/include/lavos/shader_load.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef _DEMO_COMMON_SHADER_LOAD_H
3 | #define _DEMO_COMMON_SHADER_LOAD_H
4 |
5 | #include
6 | #include
7 |
8 | namespace lavos
9 | {
10 | const uint32_t *GetSPIRVShader(const std::string shader, size_t *size);
11 | }
12 |
13 | #endif
--------------------------------------------------------------------------------
/lavos/src/component/directional_light.cpp:
--------------------------------------------------------------------------------
1 |
2 | #include "lavos/component/directional_light.h"
3 |
4 | using namespace lavos;
5 |
6 | DirectionalLight::DirectionalLight(glm::vec3 intensity)
7 | : intensity(intensity)
8 | {
9 | }
10 |
11 | DirectionalLight::~DirectionalLight()
12 | {
13 | }
14 |
--------------------------------------------------------------------------------
/lavos/include/lavos/glm_config.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef LAVOS_GLM_CONFIG_H
3 | #define LAVOS_GLM_CONFIG_H
4 |
5 | #define GLM_FORCE_RADIANS
6 | #define GLM_FORCE_DEPTH_ZERO_TO_ONE
7 | #define GLM_FORCE_SWIZZLE
8 |
9 | // TODO: remove when not necessary anymore
10 | #define GLM_ENABLE_EXPERIMENTAL
11 |
12 | #endif //VULKAN_GLM_CONFIG_H
13 |
--------------------------------------------------------------------------------
/lavos/src/component/transform_component.cpp:
--------------------------------------------------------------------------------
1 |
2 | #include "lavos/component/transform_component.h"
3 |
4 | using namespace lavos;
5 |
6 | void TransformComp::SetLookAt(glm::vec3 target, glm::vec3 up)
7 | {
8 | glm::mat4 m = glm::lookAt(translation, target, up);
9 | m = glm::inverse(m);
10 | rotation = glm::toQuat(m);
11 | }
12 |
--------------------------------------------------------------------------------
/android/gltf/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/android/gltf/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/shell/qt/include/platform.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef LAVOS_SHELL_QT_PLATFORM_H
3 | #define LAVOS_SHELL_QT_PLATFORM_H
4 |
5 | #include
6 | #include
7 |
8 | namespace lavos { namespace shell { namespace qt
9 | {
10 |
11 | std::set GetSurfaceExtensionsForPlatform();
12 |
13 | }}}
14 |
15 | #endif //LAVOS_SHELL_QT_PLATFORM_H
16 |
--------------------------------------------------------------------------------
/lavos/glsl/material/common_camera.glsl:
--------------------------------------------------------------------------------
1 |
2 | #ifndef _MATERIAL_COMMON_CAMERA_GLSL
3 | #define _MATERIAL_COMMON_CAMERA_GLSL
4 |
5 | #include "common.glsl"
6 |
7 | layout(set = DESCRIPTOR_SET_INDEX_COMMON, binding = DESCRIPTOR_SET_COMMON_BINDING_CAMERA_BUFFER, std140) uniform CameraBuffer
8 | {
9 | vec3 position;
10 | } camera_uni;
11 |
12 | #endif
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "thirdparty/glm"]
2 | path = thirdparty/glm
3 | url = https://github.com/g-truc/glm.git
4 | [submodule "demos/data"]
5 | path = demos/data
6 | url = https://github.com/thestr4ng3r/lavos-demo-assets.git
7 | [submodule "thirdparty/vma"]
8 | path = thirdparty/vma
9 | url = https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator.git
10 |
--------------------------------------------------------------------------------
/lavos/cmake/FindShaderc.cmake:
--------------------------------------------------------------------------------
1 | # FindShaderc
2 | # -------
3 | #
4 | # This will will define the following variables:
5 | #
6 | # SHADERC_FOUND - true if Shaderc has been found
7 | # SHADERC_GLSLC - the glslc executable
8 |
9 | find_program(Shaderc_GLSLC glslc)
10 |
11 | include(FindPackageHandleStandardArgs)
12 | find_package_handle_standard_args(Shaderc REQUIRED_VARS Shaderc_GLSLC)
--------------------------------------------------------------------------------
/lavos/src/render_config.cpp:
--------------------------------------------------------------------------------
1 |
2 | #include "lavos/render_config.h"
3 |
4 | using namespace lavos;
5 |
6 | RenderConfig RenderConfigBuilder::Build()
7 | {
8 | RenderConfig config;
9 | config.material_render_modes = { Material::DefaultRenderMode::ColorForward };
10 |
11 | if(shadow_enabled)
12 | config.material_render_modes.push_back(Material::DefaultRenderMode::Shadow);
13 |
14 | return config;
15 | }
16 |
--------------------------------------------------------------------------------
/shell/glfw/CMakeLists.txt:
--------------------------------------------------------------------------------
1 |
2 | set(SOURCE_FILES
3 | include/window_application.h
4 | src/window_application.cpp)
5 |
6 | add_library(lavos_shell_glfw ${SOURCE_FILES})
7 | target_include_directories(lavos_shell_glfw PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
8 | target_link_libraries(lavos_shell_glfw PUBLIC lavos)
9 |
10 | find_package(glfw3 3.3 REQUIRED)
11 | target_link_libraries(lavos_shell_glfw PUBLIC glfw)
--------------------------------------------------------------------------------
/demos/qt_shell/CMakeLists.txt:
--------------------------------------------------------------------------------
1 |
2 | set(CMAKE_INCLUDE_CURRENT_DIR ON)
3 | set(CMAKE_AUTOMOC ON)
4 | set(CMAKE_AUTOUIC ON)
5 | set(CMAKE_AUTORCC ON)
6 | find_package(Qt5 5.10 COMPONENTS Core Gui Widgets REQUIRED)
7 |
8 | set(SOURCE_FILES
9 | main.cpp
10 | lavos_renderer.cpp
11 | lavos_renderer.h)
12 |
13 | add_executable(qt_shell ${SOURCE_FILES})
14 | target_link_libraries(qt_shell
15 | Qt5::Core Qt5::Gui Qt5::Widgets
16 | lavos_shell_qt
17 | lavos)
--------------------------------------------------------------------------------
/android/gltf/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/lavos/src/buffer.cpp:
--------------------------------------------------------------------------------
1 |
2 | #include "lavos/buffer.h"
3 | #include "lavos/engine.h"
4 |
5 | lavos::Buffer::~Buffer()
6 | {
7 | UnMap();
8 | engine->DestroyBuffer(buffer, allocation);
9 | }
10 |
11 | void *lavos::Buffer::Map()
12 | {
13 | if(!map)
14 | map = engine->MapMemory(allocation);
15 |
16 | return map;
17 | }
18 |
19 | void lavos::Buffer::UnMap()
20 | {
21 | if(!map)
22 | return;
23 | engine->UnmapMemory(allocation);
24 | map = nullptr;
25 | }
26 |
--------------------------------------------------------------------------------
/demos/qt_qvulkanwindow/CMakeLists.txt:
--------------------------------------------------------------------------------
1 |
2 | set(CMAKE_INCLUDE_CURRENT_DIR ON)
3 | set(CMAKE_AUTOMOC ON)
4 | set(CMAKE_AUTOUIC ON)
5 | set(CMAKE_AUTORCC ON)
6 | find_package(Qt5 5.10 COMPONENTS Core Gui Widgets REQUIRED)
7 |
8 | set(SOURCE_FILES
9 | main.cpp
10 | mainwindow.cpp
11 | mainwindow.h)
12 |
13 | add_executable(qt_qvulkanwindow ${SOURCE_FILES})
14 | target_link_libraries(qt_qvulkanwindow
15 | Qt5::Core Qt5::Gui Qt5::Widgets
16 | lavos_shell_qt
17 | lavos)
--------------------------------------------------------------------------------
/demos/point_cloud/CMakeLists.txt:
--------------------------------------------------------------------------------
1 |
2 | find_package(PCL 1.3 REQUIRED COMPONENTS common io)
3 | include_directories(${PCL_INCLUDE_DIRS})
4 | link_directories(${PCL_LIBRARY_DIRS})
5 | add_definitions(${PCL_DEFINITIONS})
6 |
7 | set(SOURCE_FILES
8 | point_cloud.cpp)
9 |
10 | add_executable(point_cloud ${SOURCE_FILES})
11 | target_link_libraries(point_cloud
12 | ${PCL_COMMON_LIBRARIES}
13 | ${PCL_IO_LIBRARIES}
14 | lavos
15 | lavos_shell_glfw
16 | glfw
17 | ${Vulkan_LIBRARIES})
--------------------------------------------------------------------------------
/lavos/include/lavos/component/component.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef LAVOS_COMPONENT_H
3 | #define LAVOS_COMPONENT_H
4 |
5 | namespace lavos
6 | {
7 |
8 | class Node;
9 |
10 | class Component
11 | {
12 | friend class Node;
13 |
14 | private:
15 | Node *node = nullptr;
16 |
17 | public:
18 | virtual ~Component() {}
19 |
20 | Node *GetNode() const { return node; }
21 |
22 | virtual void Update(float delta_time) {}
23 | };
24 |
25 | }
26 |
27 |
28 | #endif //VULKAN_COMPONENT_H
29 |
--------------------------------------------------------------------------------
/lavos/include/lavos/log.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef LAVOS_LOG_H
3 | #define LAVOS_LOG_H
4 |
5 | namespace lavos
6 | {
7 |
8 | enum class LogLevel { Debug, Info, Warning, Error };
9 |
10 | void LogF(LogLevel level, const char *file, int line, const char *function, const char *fmt, ...);
11 |
12 | }
13 |
14 | #define LAVOS_LOGF(level, fmt, ...) { lavos::LogF((level), __FILE__, __LINE__, __func__, fmt, __VA_ARGS__); }
15 | #define LAVOS_LOG(level, str) { LAVOS_LOGF((level), "%s", str); }
16 |
17 | #endif //LAVOS_LOG_H
18 |
--------------------------------------------------------------------------------
/.github/workflows/ci.yml:
--------------------------------------------------------------------------------
1 | name: CI
2 | on: [push]
3 |
4 | jobs:
5 | build:
6 | name: CI
7 | runs-on: ubuntu-latest
8 | steps:
9 | - uses: actions/checkout@v2
10 | - name: Checkout submodules
11 | run: |
12 | git submodule init
13 | git submodule update
14 | - name: Docker Build
15 | run: docker build -t lavos .
16 | - name: Build Lavos
17 | run: docker run --rm -v "`pwd`:/build" -t lavos /bin/bash -c "cd /build && ./ci-script"
18 |
19 |
--------------------------------------------------------------------------------
/lavos/src/thirdparty_impl.cpp:
--------------------------------------------------------------------------------
1 |
2 | #ifdef LAVOS_IMPLEMENT_STB_IMAGE
3 | # define STB_IMAGE_IMPLEMENTATION
4 | # include "../../thirdparty/stb_image.h"
5 | # undef STB_IMAGE_IMPLEMENTATION
6 | #endif
7 |
8 | #ifdef LAVOS_IMPLEMENT_TINYGLTF
9 | # define TINYGLTF_IMPLEMENTATION
10 | # include "../../thirdparty/tiny_gltf.h"
11 | # undef TINYGLTF_IMPLEMENTATION
12 | #endif
13 |
14 | #ifdef LAVOS_IMPLEMENT_VMA
15 | # define VMA_IMPLEMENTATION
16 | # include "vk_mem_alloc.h"
17 | # undef VMA_IMPLEMENTATION
18 | #endif
19 |
--------------------------------------------------------------------------------
/lavos/src/light_collection.cpp:
--------------------------------------------------------------------------------
1 |
2 | #include "lavos/light_collection.h"
3 | #include "lavos/scene.h"
4 | #include "lavos/component/directional_light.h"
5 | #include "lavos/component/spot_light.h"
6 |
7 | using namespace lavos;
8 |
9 | LightCollection LightCollection::EverythingInScene(Scene *scene)
10 | {
11 | LightCollection ret;
12 | ret.dir_light = scene->GetRootNode()->GetComponentInChildren();
13 | ret.spot_lights = scene->GetRootNode()->GetComponentsInChildren();
14 | return std::move(ret);
15 | }
--------------------------------------------------------------------------------
/lavos/include/lavos/sub_renderer.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef LAVOS_SUB_RENDERER_H
3 | #define LAVOS_SUB_RENDERER_H
4 |
5 | namespace lavos
6 | {
7 |
8 | class Engine;
9 | class Material;
10 |
11 | class SubRenderer
12 | {
13 | protected:
14 | Engine * const engine;
15 |
16 | public:
17 | explicit SubRenderer(Engine *engine);
18 | virtual ~SubRenderer() = default;
19 |
20 | virtual void AddMaterial(Material *material) {}
21 | virtual void RemoveMaterial(Material *material) {}
22 | };
23 |
24 | }
25 |
26 | #endif //LAVOS_SUB_RENDERER_H
27 |
--------------------------------------------------------------------------------
/demos/CMakeLists.txt:
--------------------------------------------------------------------------------
1 |
2 | add_subdirectory(gltf)
3 | add_subdirectory(firstperson)
4 | add_subdirectory(2d)
5 | add_subdirectory(room)
6 |
7 | if(LAVOS_BUILD_POINT_CLOUD_DEMO)
8 | add_subdirectory(point_cloud)
9 | endif()
10 |
11 | if(LAVOS_BUILD_QT_DEMOS)
12 | if(NOT LAVOS_BUILD_SHELL_QT)
13 | message(FATAL_ERROR "Lavos Qt Shell is required for the Qt demos. Either enable it using -DLAVOS_BUILD_SHELL_QT=ON or disable building the Qt demos.")
14 | endif()
15 |
16 | add_subdirectory(qt_qvulkanwindow)
17 | add_subdirectory(qt_shell)
18 | endif()
--------------------------------------------------------------------------------
/lavos/cmake/ResourceGenerator_header.h.in:
--------------------------------------------------------------------------------
1 |
2 | #ifndef _@RESOURCE_GENERATOR_INCLUDE_GUARD@_H
3 | #define _@RESOURCE_GENERATOR_INCLUDE_GUARD@_H
4 |
5 | namespace lavos
6 | {
7 |
8 | const @RESOURCE_GENERATOR_TYPE@ *@RESOURCE_GENERATOR_FUNCTION_PREFIX@_get(const char *filename, size_t *size);
9 | inline const @RESOURCE_GENERATOR_TYPE@ *@RESOURCE_GENERATOR_FUNCTION_PREFIX@_get(const char *filename)
10 | {
11 | return @RESOURCE_GENERATOR_FUNCTION_PREFIX@_get(filename, 0);
12 | }
13 |
14 | }
15 |
16 | #endif // _@RESOURCE_GENERATOR_INCLUDE_GUARD@_H
17 |
--------------------------------------------------------------------------------
/shell/qt/CMakeLists.txt:
--------------------------------------------------------------------------------
1 |
2 | set(CMAKE_INCLUDE_CURRENT_DIR ON)
3 | set(CMAKE_AUTOMOC ON)
4 | set(CMAKE_AUTOUIC OFF)
5 | set(CMAKE_AUTORCC OFF)
6 | find_package(Qt5 5.10 COMPONENTS Core Gui REQUIRED)
7 |
8 | set(SOURCE_FILES
9 | include/lavos_window.h
10 | src/lavos_window.cpp
11 | include/platform.h
12 | src/platform.cpp)
13 |
14 | add_library(lavos_shell_qt ${SOURCE_FILES})
15 | target_include_directories(lavos_shell_qt PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
16 | target_link_libraries(lavos_shell_qt
17 | Qt5::Core Qt5::Gui
18 | lavos)
--------------------------------------------------------------------------------
/android/common/CMakeLists.txt:
--------------------------------------------------------------------------------
1 |
2 |
3 | add_library(demo_android SHARED
4 | android_common.cpp
5 | android_common.h
6 | ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c)
7 |
8 | target_include_directories(demo_android PRIVATE
9 | ${ANDROID_NDK}/sources/android/native_app_glue
10 | ${ANDROID_NDK}/sources/third_party/shaderc/include)
11 |
12 | target_link_libraries(demo_android
13 | android
14 | log
15 | vulkan
16 | ${MODULE_NAME}
17 | demo_common)
18 |
--------------------------------------------------------------------------------
/cmake/FindVulkanHPP.cmake:
--------------------------------------------------------------------------------
1 | # FindVulkanHPP
2 | # ----------
3 | #
4 | # This module defines the following variables:
5 | #
6 | # VulkanHPP_FOUND - True if vulkan.hpp was found
7 | # VulkanHPP_INCLUDE_DIRS - include directories for vulkan.hpp
8 |
9 | find_path(VulkanHPP_INCLUDE_DIRS
10 | NAMES vulkan/vulkan.hpp
11 | PATHS
12 | "$ENV{VULKAN_SDK}/Include"
13 | "${VULKAN_INCLUDE_DIRS}")
14 |
15 | include(FindPackageHandleStandardArgs)
16 | find_package_handle_standard_args(VulkanHPP DEFAULT_MSG VulkanHPP_INCLUDE_DIRS)
17 |
--------------------------------------------------------------------------------
/lavos/glsl/material/lighting_phong.glsl:
--------------------------------------------------------------------------------
1 |
2 | #ifndef _MATERIAL_LIGHTING_PHONG_GLSL
3 | #define _MATERIAL_LIGHTING_PHONG_GLSL
4 |
5 | struct PhongMaterialParameters
6 | {
7 | vec4 base_color;
8 | float specular_exponent;
9 | };
10 |
11 | float LightingPhong(vec3 normal, vec3 light_dir, vec3 cam_dir, float specular_exponent)
12 | {
13 | float lambert = max(0.0, dot(light_dir, normal));
14 |
15 | float specular = max(0.0, dot(reflect(-light_dir, normal), cam_dir));
16 | specular = pow(specular, specular_exponent);
17 |
18 | return lambert + specular;
19 | }
20 |
21 | #endif
--------------------------------------------------------------------------------
/lavos/include/lavos/light_collection.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef LAVOS_LIGHT_COLLECTION_H
3 | #define LAVOS_LIGHT_COLLECTION_H
4 |
5 | #include
6 |
7 | namespace lavos
8 | {
9 |
10 | class DirectionalLight;
11 | class SpotLight;
12 | class Scene;
13 |
14 | /**
15 | * Accumulates all the lights used for rendering,
16 | * could also be local to a cluster for example.
17 | */
18 | struct LightCollection
19 | {
20 | DirectionalLight *dir_light;
21 | std::vector spot_lights;
22 |
23 | static LightCollection EverythingInScene(Scene *scene);
24 | };
25 |
26 | }
27 |
28 | #endif //LAVOS_LIGHT_COLLECTION_H
29 |
--------------------------------------------------------------------------------
/lavos/glsl/common_glsl_cpp.h:
--------------------------------------------------------------------------------
1 | // Common defines for both GLSL and C++
2 | // must compile under both
3 |
4 | #ifndef LAVOS_COMMON_GLSL_CPP_H
5 | #define LAVOS_COMMON_GLSL_CPP_H
6 |
7 | #define DESCRIPTOR_SET_INDEX_COMMON 0
8 | #define DESCRIPTOR_SET_INDEX_MATERIAL 1
9 |
10 | #define MAX_SPOT_LIGHTS_COUNT 16
11 |
12 | #define DESCRIPTOR_SET_COMMON_BINDING_MATRIX_BUFFER 0
13 | #define DESCRIPTOR_SET_COMMON_BINDING_LIGHTING_BUFFER 1
14 | #define DESCRIPTOR_SET_COMMON_BINDING_CAMERA_BUFFER 2
15 | #define DESCRIPTOR_SET_COMMON_BINDING_SPOT_LIGHT_SHADOW_TEX 3
16 |
17 | #define SHADOW_MSM 1
18 |
19 | #endif //LAVOS_COMMON_GLSL_CPP_H
20 |
--------------------------------------------------------------------------------
/lavos/cmake/ResourceGenerator_source.cpp.in:
--------------------------------------------------------------------------------
1 |
2 | #include
3 | #include "@RESOURCE_GENERATOR_HEADER_FILE_RELATIVE@"
4 |
5 | @RESOURCE_GENERATOR_RESOURCES_SOURCE@
6 |
7 | static const unsigned int resources_count = @RESOURCE_GENERATOR_RESOURCES_COUNT@;
8 | static const char *all_resources_names[] = {@RESOURCE_GENERATOR_RESOURCES_ALL_NAMES@};
9 | static const @RESOURCE_GENERATOR_TYPE@ *all_resources[] = {@RESOURCE_GENERATOR_RESOURCES_ALL@};
10 |
11 | const @RESOURCE_GENERATOR_TYPE@ *lavos::@RESOURCE_GENERATOR_FUNCTION_PREFIX@_get(const char *filename, size_t *size)
12 | {
13 | @RESOURCE_GENERATOR_GET_FUNCTION_SOURCE@
14 | return 0;
15 | }
--------------------------------------------------------------------------------
/lavos/include/lavos/component/directional_light.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef LAVOS_DIRECTIONAL_LIGHT_H
3 | #define LAVOS_DIRECTIONAL_LIGHT_H
4 |
5 | #include
6 |
7 | #include "component.h"
8 |
9 | namespace lavos
10 | {
11 |
12 | class DirectionalLight: public Component
13 | {
14 | private:
15 | glm::vec3 intensity;
16 |
17 | public:
18 | DirectionalLight(glm::vec3 intensity = glm::vec3(1.0f, 1.0f, 1.0f));
19 | ~DirectionalLight();
20 |
21 | glm::vec3 GetIntensity() const { return intensity; }
22 | void SetIntensity(const glm::vec3 &intensity) { this->intensity = intensity; }
23 | };
24 |
25 | }
26 |
27 | #endif //VULKAN_DIRECTIONAL_LIGHT_COMPONENT_H
28 |
--------------------------------------------------------------------------------
/lavos/include/lavos/component/fp_controller.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef LAVOS_FP_CAMERA_CONTROLLER_COMPONENT_H
3 | #define LAVOS_FP_CAMERA_CONTROLLER_COMPONENT_H
4 |
5 | #include "component.h"
6 | #include "transform_component.h"
7 |
8 | namespace lavos
9 | {
10 |
11 | class FirstPersonController : public Component
12 | {
13 | private:
14 | glm::vec2 rotation;
15 | glm::vec2 velocity;
16 |
17 | public:
18 | virtual void Update(float delta_time) override;
19 |
20 | void SetRotation(glm::vec2 rotation) { this->rotation = rotation; }
21 | void Rotate(glm::vec2 rot);
22 | void SetVelocity(glm::vec2 velocity);
23 | };
24 |
25 | }
26 |
27 | #endif //VULKAN_FP_CAMERA_CONTROLLER_COMPONENT_H
28 |
--------------------------------------------------------------------------------
/android/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 |
5 | repositories {
6 | google()
7 | jcenter()
8 | }
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:3.0.0-beta6'
11 |
12 |
13 | // NOTE: Do not place your application dependencies here; they belong
14 | // in the individual module build.gradle files
15 | }
16 | }
17 |
18 |
19 | allprojects {
20 | repositories {
21 | google()
22 | jcenter()
23 | }
24 | }
25 |
26 | task clean(type: Delete) {
27 | delete rootProject.buildDir
28 | }
29 |
--------------------------------------------------------------------------------
/lavos/include/lavos/buffer.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef LAVOS_BUFFER_H
3 | #define LAVOS_BUFFER_H
4 |
5 | #include
6 | #include "vk_mem_alloc.h"
7 |
8 | namespace lavos
9 | {
10 |
11 | class Engine;
12 |
13 | class Buffer
14 | {
15 | private:
16 | Engine * const engine;
17 |
18 | vk::Buffer buffer;
19 | VmaAllocation allocation;
20 | void *map = nullptr;
21 |
22 | public:
23 | Buffer(Engine *engine, vk::Buffer buffer, VmaAllocation allocation)
24 | : engine(engine), buffer(buffer), allocation(allocation) {}
25 |
26 | ~Buffer();
27 |
28 | vk::Buffer GetVkBuffer() { return buffer; }
29 |
30 | void *Map();
31 | void UnMap();
32 | };
33 |
34 | }
35 |
36 | #endif //VULKAN_BUFFER_H
37 |
--------------------------------------------------------------------------------
/lavos/src/component/fp_controller.cpp:
--------------------------------------------------------------------------------
1 |
2 | #include "lavos/component/fp_controller.h"
3 |
4 | using namespace lavos;
5 |
6 | void FirstPersonController::Update(float delta_time)
7 | {
8 | TransformComp *transform = GetNode()->GetTransformComp();
9 |
10 | transform->rotation = glm::quat(glm::vec3(-rotation.y, -rotation.x, 0.0f));
11 |
12 | glm::mat4 mat = transform->GetMatrix();
13 | transform->translation += glm::vec3(mat * glm::vec4(velocity.x * delta_time, 0.0f, -velocity.y * delta_time, 0.0f));
14 | }
15 |
16 | void FirstPersonController::Rotate(glm::vec2 rot)
17 | {
18 | rotation += rot;
19 | }
20 |
21 | void FirstPersonController::SetVelocity(glm::vec2 velocity)
22 | {
23 | this->velocity = velocity;
24 | }
25 |
--------------------------------------------------------------------------------
/lavos/src/component/mesh_component.cpp:
--------------------------------------------------------------------------------
1 |
2 | #include "lavos/component/mesh_component.h"
3 |
4 | lavos::MeshComp::MeshComp(lavos::Mesh *mesh)
5 | {
6 | SetMesh(mesh);
7 | }
8 |
9 | void lavos::MeshComp::BindBuffers(vk::CommandBuffer command_buffer)
10 | {
11 | command_buffer.bindVertexBuffers(0, { mesh->vertex_buffer->GetVkBuffer() }, { 0 });
12 | command_buffer.bindIndexBuffer(mesh->index_buffer->GetVkBuffer(), 0, vk::IndexType::eUint16);
13 | }
14 |
15 | unsigned int lavos::MeshComp::GetPrimitivesCount()
16 | {
17 | return static_cast(mesh->primitives.size());
18 | }
19 |
20 | lavos::Renderable::Primitive *lavos::MeshComp::GetPrimitive(unsigned int i)
21 | {
22 | return &mesh->primitives[i];
23 | }
24 |
--------------------------------------------------------------------------------
/lavos/src/component/spot_light.cpp:
--------------------------------------------------------------------------------
1 |
2 | #include "lavos/component/spot_light.h"
3 | #include "lavos/spot_light_shadow.h"
4 | #include "lavos/node.h"
5 | #include "lavos/component/transform_component.h"
6 |
7 | using namespace lavos;
8 |
9 | SpotLight::SpotLight(glm::vec3 intensity, float angle)
10 | : intensity(intensity), angle(angle)
11 | {
12 | }
13 |
14 | SpotLight::~SpotLight()
15 | {
16 | DestroyShadow();
17 | }
18 |
19 | void SpotLight::InitShadow(Engine *engine, SpotLightShadowRenderer *renderer, float near_clip, float far_clip)
20 | {
21 | DestroyShadow();
22 | shadow = new SpotLightShadow(engine, this, renderer, near_clip, far_clip);
23 | }
24 |
25 | void SpotLight::DestroyShadow()
26 | {
27 | delete shadow;
28 | }
29 |
--------------------------------------------------------------------------------
/lavos/include/lavos/scene.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef LAVOS_SCENE_H
3 | #define LAVOS_SCENE_H
4 |
5 | #include "glm_config.h"
6 | #include
7 |
8 | #include "node.h"
9 |
10 | namespace lavos
11 | {
12 |
13 | class Scene
14 | {
15 | private:
16 | Node root_node;
17 |
18 | glm::vec3 ambient_light_intensity;
19 |
20 | public:
21 | Scene();
22 | ~Scene();
23 |
24 | Node *GetRootNode() { return &root_node; }
25 |
26 | glm::vec3 GetAmbientLightIntensity() const { return ambient_light_intensity; }
27 | void SetAmbientLightIntensity(glm::vec3 intensity) { ambient_light_intensity = intensity; }
28 |
29 | void Update(float delta_time) { root_node.Update(delta_time); }
30 | };
31 |
32 |
33 | }
34 |
35 | #endif //VULKAN_SCENE_H
36 |
--------------------------------------------------------------------------------
/android/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/lavos/include/lavos/render_config.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef LAVOS_RENDER_CONFIG_H
3 | #define LAVOS_RENDER_CONFIG_H
4 |
5 | #include "material/material.h"
6 |
7 | namespace lavos
8 | {
9 |
10 | class RenderConfigBuilder;
11 |
12 | class RenderConfig
13 | {
14 | friend class RenderConfigBuilder;
15 |
16 | private:
17 | std::vector material_render_modes;
18 |
19 | public:
20 | const std::vector &GetMaterialRenderModes() const { return material_render_modes; }
21 | };
22 |
23 | class RenderConfigBuilder
24 | {
25 | private:
26 | bool shadow_enabled = false;
27 |
28 | public:
29 | RenderConfigBuilder &SetShadowEnabled(bool enabled) { shadow_enabled = enabled; return *this; }
30 |
31 | RenderConfig Build();
32 | };
33 |
34 | }
35 |
36 | #endif //LAVOS_RENDER_CONFIG_H
37 |
--------------------------------------------------------------------------------
/android/common/android_common.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef ANDROID_COMMON_H
3 | #define ANDROID_COMMON_H
4 |
5 | #include
6 | #include
7 |
8 | #include
9 | #include
10 |
11 | #define LOG_TAG "native-activity"
12 |
13 | #define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__))
14 | #define LOGE(...) ((void)__android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__))
15 |
16 | void AndroidSetApp(android_app *_app);
17 | ANativeWindow *AndroidGetApplicationWindow();
18 | void AndroidGetWindowSize(int32_t *width, int32_t *height);
19 |
20 | std::vector AndroidReadSPIRVShader(const std::string shader);
21 | std::vector AndroidReadAssetBinary(const std::string filename);
22 |
23 | void sample_main();
24 |
25 | #endif //ANDROID_COMMON_H
26 |
--------------------------------------------------------------------------------
/lavos/include/lavos/component/mesh_component.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef LAVOS_MESH_COMPONENT_H
3 | #define LAVOS_MESH_COMPONENT_H
4 |
5 | #include "component.h"
6 | #include "../mesh.h"
7 | #include "../renderable.h"
8 |
9 | namespace lavos
10 | {
11 |
12 | class MeshComp: public Component, public Renderable
13 | {
14 | private:
15 | Mesh *mesh;
16 |
17 | public:
18 | MeshComp(Mesh *mesh = nullptr);
19 |
20 | void SetMesh(Mesh *mesh) { this->mesh = mesh; }
21 | Mesh *GetMesh() const { return mesh; }
22 |
23 | bool GetCurrentlyRenderable() const override { return mesh != nullptr; }
24 |
25 | void BindBuffers(vk::CommandBuffer command_buffer) override;
26 | unsigned int GetPrimitivesCount() override;
27 | Primitive *GetPrimitive(unsigned int i) override;
28 | };
29 |
30 | }
31 |
32 | #endif //VULKAN_MESH_COMPONENT_H
33 |
--------------------------------------------------------------------------------
/shell/qt/src/platform.cpp:
--------------------------------------------------------------------------------
1 |
2 | #include "platform.h"
3 |
4 | #include
5 |
6 | std::set lavos::shell::qt::GetSurfaceExtensionsForPlatform()
7 | {
8 | // Qt already has all this, but it is not publicly exposed :(
9 |
10 | const auto platform = QGuiApplication::platformName();
11 |
12 | if(platform == "xcb")
13 | {
14 | return {
15 | "VK_KHR_surface",
16 | "VK_KHR_xcb_surface"
17 | };
18 | }
19 | else if(platform == "wayland")
20 | {
21 | return {
22 | "VK_KHR_surface",
23 | "VK_KHR_wayland_surface"
24 | };
25 | }
26 | else if(platform == "windows")
27 | {
28 | return {
29 | "VK_KHR_surface",
30 | "VK_KHR_win32_surface"
31 | };
32 | }
33 | else if(platform == "cocoa")
34 | {
35 | return {
36 | "VK_KHR_surface",
37 | "VK_MVK_macos_surface"
38 | };
39 | }
40 | }
--------------------------------------------------------------------------------
/lavos/glsl/material/shadow.vf.shader:
--------------------------------------------------------------------------------
1 | #version 450
2 |
3 | #include "common.glsl"
4 |
5 | #ifdef SHADER_VERT
6 |
7 | #define COMMON_VERT_MATRIX_COMPACT
8 | #include "common_vert.glsl"
9 |
10 | #if SHADOW_MSM
11 | layout(location = 0) out float z_out;
12 | #endif
13 |
14 | out gl_PerVertex
15 | {
16 | vec4 gl_Position;
17 | };
18 |
19 | void main()
20 | {
21 | vec4 pos = CalculateVertexPosition();
22 | #if SHADOW_MSM
23 | z_out = pos.z;
24 | #endif
25 | gl_Position = pos;
26 | }
27 |
28 | // -------------------------------------------------
29 | #elif SHADER_FRAG
30 |
31 | #if SHADOW_MSM
32 | layout(location = 0) in float z_in;
33 | layout(location = 0) out vec4 shadow_out;
34 | #endif
35 |
36 | void main()
37 | {
38 | #if SHADOW_MSM
39 | float z = z_in;
40 | shadow_out = vec4(z, z*z, z*z*z, z*z*z*z);
41 | #endif
42 | }
43 |
44 | #endif
--------------------------------------------------------------------------------
/lavos/glsl/material/unlit.vf.shader:
--------------------------------------------------------------------------------
1 | #version 450
2 |
3 | #if SHADER_VERT
4 |
5 | #include "common_vert.glsl"
6 |
7 | out gl_PerVertex
8 | {
9 | vec4 gl_Position;
10 | };
11 |
12 | layout(location = 1) out vec2 uv_out;
13 |
14 | void main()
15 | {
16 | gl_Position = CalculateVertexPosition();
17 |
18 | uv_out = uv_in;
19 | }
20 |
21 | #elif SHADER_FRAG
22 |
23 | #include "common_frag.glsl"
24 |
25 | layout(set = DESCRIPTOR_SET_INDEX_MATERIAL, binding = 0, std140) uniform MaterialBuffer
26 | {
27 | vec3 color_factor;
28 | } material_uni;
29 |
30 | layout(set = DESCRIPTOR_SET_INDEX_MATERIAL, binding = 1) uniform sampler2D tex_uni;
31 |
32 | layout(location = 1) in vec2 uv_in;
33 |
34 | void main()
35 | {
36 | vec4 tex_color = texture(tex_uni, uv_in);
37 | out_color = vec4(tex_color.rgb * material_uni.color_factor, tex_color.a);
38 | }
39 |
40 | #endif
--------------------------------------------------------------------------------
/demos/qt_shell/lavos_renderer.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef LAVOS_LAVOS_RENDERER_H
3 | #define LAVOS_LAVOS_RENDERER_H
4 |
5 | #include
6 |
7 | class LavosWindowRenderer : public lavos::shell::qt::LavosWindow::Renderer
8 | {
9 | private:
10 | lavos::Engine *engine = nullptr;
11 |
12 | lavos::RenderConfig render_config;
13 |
14 | lavos::PhongMaterial *material = nullptr;
15 | lavos::Scene *scene = nullptr;
16 | lavos::Camera *camera = nullptr;
17 |
18 | lavos::Renderer *renderer = nullptr;
19 |
20 | lavos::AssetContainer *asset_container = nullptr;
21 |
22 | public:
23 | LavosWindowRenderer(lavos::Engine *engine);
24 | ~LavosWindowRenderer();
25 |
26 | void InitializeSwapchainResources(lavos::shell::qt::LavosWindow *window) override;
27 | void ReleaseSwapchainResources() override;
28 |
29 | void Render(lavos::shell::qt::LavosWindow *window);
30 | };
31 |
32 | #endif //LAVOS_LAVOS_RENDERER_H
33 |
--------------------------------------------------------------------------------
/lavos/include/lavos/asset_container.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef LAVOS_ASSET_CONTAINER_H
3 | #define LAVOS_ASSET_CONTAINER_H
4 |
5 | #include
6 | #include