Commit 299da942 authored by Florian Oetke's avatar Florian Oetke
Browse files

refactoring from easier integration into other projects; fixed small bugs

parent 9daf0090
Pipeline #2259 failed with stage
in 17 minutes and 33 seconds
......@@ -2,58 +2,11 @@ cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
project(mirrage LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# required at top-level
set(ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${ROOT_DIR}/modules")
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftemplate-depth=1024 -fno-strict-aliasing")
option(MIRRAGE_ENABLE_LTO "Enable link-time optimization" OFF)
if(MIRRAGE_ENABLE_LTO)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto")
endif()
endif()
if (UNIX AND NOT APPLE)
execute_process(COMMAND ${CMAKE_C_COMPILER} -fuse-ld=lld -Wl,--version ERROR_QUIET OUTPUT_VARIABLE ld_version)
if ("${ld_version}" MATCHES "LLD")
message("using LLD linker")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=lld -Wl,--threads,--build-id=none")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fuse-ld=lld -Wl,--threads,--build-id=none")
else()
message("OUT ${ld_version}")
execute_process(COMMAND ${CMAKE_C_COMPILER} -fuse-ld=gold -Wl,--version ERROR_QUIET OUTPUT_VARIABLE ld_version)
if ("${ld_version}" MATCHES "GNU gold")
message("using gold linker")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold -Wl,--disable-new-dtags")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fuse-ld=gold -Wl,--disable-new-dtags")
else()
message("using default linker")
endif()
endif()
endif()
option(MIRRAGE_FORCE_LIBCPP "Force usage of libc++ instead of libstdc++ intependent of the used compiler. " OFF)
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" OR MIRRAGE_FORCE_LIBCPP)
option(MIRRAGE_USE_LIBCPP "Uses libc++ instead of libstdc++. " ON)
if(MIRRAGE_USE_LIBCPP OR MIRRAGE_FORCE_LIBCPP)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++ -lc++abi")
endif()
endif()
option(MIRRAGE_BUILD_MESH_CONVERTER "Build the mesh converter (requires assimp)" OFF)
get_directory_property(hasParent PARENT_DIRECTORY)
if(NOT hasParent)
include(globals.cmake)
option(MIRRAGE_BUILD_DEMO "Build the demo application" ON)
# custom target that does nothing but references all files so they show up in QtCreator
......@@ -69,26 +22,6 @@ else()
option(MIRRAGE_BUILD_DEMO "Build the demo application" OFF)
endif()
option(MIRRAGE_ENABLE_COTIRE "Enable cotire" ON)
if(MIRRAGE_ENABLE_COTIRE)
include(cotire OPTIONAL)
if(COMMAND cotire)
add_definitions(-DGLM_FORCE_RADIANS -DGLM_FORCE_DEPTH_ZERO_TO_ON -DGLM_ENABLE_EXPERIMENTAL -DGLM_FORCE_CXX14)
add_compile_options(-pthread)
set_property(GLOBAL PROPERTY COTIRE_PREFIX_HEADER_INCLUDE_PATH "${ROOT_DIR}/dependencies")
set_property(GLOBAL PROPERTY COTIRE_PREFIX_HEADER_IGNORE_PATH "${ROOT_DIR}/dependencies/nuklear;${ROOT_DIR}/src;${ROOT_DIR}/dependencies/moodycamel/concurrentqueue.h")
set_property(GLOBAL PROPERTY COTIRE_ADD_UNITY_BUILD FALSE)
endif()
endif()
option(MIRRAGE_ENABLE_TESTS "Enable unit tests" ON)
if(MIRRAGE_ENABLE_TESTS)
enable_testing()
endif()
add_subdirectory(dependencies)
add_subdirectory(src)
......@@ -15,6 +15,8 @@ layout(location = 2) in vec2 tex_coords;
layout(location = 0) out vec4 depth_out;
layout(location = 1) out vec4 albedo_mat_id_out;
layout(location = 2) out vec4 mat_data_out;
layout(location = 3) out vec4 color_out;
layout(location = 4) out vec4 color_diffuse_out;
layout(set=1, binding = 0) uniform sampler2D albedo_sampler;
layout(set=1, binding = 1) uniform sampler2D mat_data_sampler;
......@@ -36,7 +38,7 @@ void main() {
vec4 mat_data = texture(mat_data_sampler, tex_coords);
vec3 normal = tangent_space_to_world(decode_tangent_normal(mat_data.rg));
vec3 N = tangent_space_to_world(decode_tangent_normal(mat_data.rg));
float roughness = mat_data.b;
float metallic = mat_data.a;
......@@ -45,7 +47,8 @@ void main() {
depth_out = vec4(-view_pos.z / global_uniforms.proj_planes.y, 0,0,1);
albedo_mat_id_out = vec4(albedo.rgb, 0.0);
mat_data_out = vec4(encode_normal(normal), roughness, metallic);
mat_data_out = vec4(encode_normal(N), roughness, metallic);
color_diffuse_out = color_out = vec4(0,0,0,1);
}
vec3 decode_tangent_normal(vec2 tn) {
......
......@@ -13,6 +13,8 @@ layout(location = 2) in vec2 tex_coords;
layout(location = 0) out vec4 depth_out;
layout(location = 1) out vec4 albedo_mat_id_out;
layout(location = 2) out vec4 mat_data_out;
layout(location = 3) out vec4 color_out;
layout(location = 4) out vec4 color_diffuse_out;
layout(set=1, binding = 0) uniform sampler2D albedo_sampler;
layout(set=1, binding = 1) uniform sampler2D mat_data_sampler;
......@@ -47,6 +49,7 @@ void main() {
depth_out = vec4(-view_pos.z / global_uniforms.proj_planes.y, 0,0,1);
albedo_mat_id_out = vec4(albedo.rgb, 0.0);
mat_data_out = vec4(encode_normal(normal), roughness, metallic);
color_diffuse_out = color_out = vec4(0,0,0,1);
}
vec3 decode_tangent_normal(vec2 tn) {
......
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# required at top-level
set(MIRRAGE_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR})
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${MIRRAGE_ROOT_DIR}/modules")
# add_definitions(-DHPC_HISTOGRAM_DEBUG_VIEW)
add_definitions(-DGSL_TERMINATE_ON_CONTRACT_VIOLATION)
# LTO
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftemplate-depth=1024 -fno-strict-aliasing")
option(MIRRAGE_ENABLE_LTO "Enable link-time optimization" OFF)
if(MIRRAGE_ENABLE_LTO)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto")
endif()
endif()
# Sanitizers
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
option(MIRRAGE_SAN "Build with sanitizers" OFF)
if(MIRRAGE_SAN)
MESSAGE("Building with sanitizers")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fsanitize=integer -fsanitize=undefined -fsanitize-address-use-after-scope ")
endif()
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -gline-tables-only") # for stack traces
endif()
endif()
# Default compiler flags
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(MIRRAGE_DEFAULT_COMPILER_ARGS -Wextra -Wall -pedantic -Wextra-semi
-Wzero-as-null-pointer-constant -Wold-style-cast -Werror
-Wno-unused-parameter -Wno-unused-private-field -Wno-missing-braces)
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(MIRRAGE_DEFAULT_COMPILER_ARGS -Wextra -Wall -pedantic
-Wlogical-op -Werror -Wno-unused-parameter
-Wno-missing-braces)
elseif(MSVC)
set(MIRRAGE_DEFAULT_COMPILER_ARGS /Za)
endif()
# Select optimal linker
if (UNIX AND NOT APPLE)
execute_process(COMMAND ${CMAKE_C_COMPILER} -fuse-ld=lld -Wl,--version ERROR_QUIET OUTPUT_VARIABLE ld_version)
if ("${ld_version}" MATCHES "LLD")
message("using LLD linker")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=lld -Wl,--threads,--build-id=none")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fuse-ld=lld -Wl,--threads,--build-id=none")
else()
message("OUT ${ld_version}")
execute_process(COMMAND ${CMAKE_C_COMPILER} -fuse-ld=gold -Wl,--version ERROR_QUIET OUTPUT_VARIABLE ld_version)
if ("${ld_version}" MATCHES "GNU gold")
message("using gold linker")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold -Wl,--disable-new-dtags")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fuse-ld=gold -Wl,--disable-new-dtags")
else()
message("using default linker")
endif()
endif()
endif()
option(MIRRAGE_FORCE_LIBCPP "Force usage of libc++ instead of libstdc++ intependent of the used compiler. " OFF)
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" OR MIRRAGE_FORCE_LIBCPP)
option(MIRRAGE_USE_LIBCPP "Uses libc++ instead of libstdc++. " ON)
if(MIRRAGE_USE_LIBCPP OR MIRRAGE_FORCE_LIBCPP)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++ -lc++abi")
endif()
endif()
option(MIRRAGE_ENABLE_COTIRE "Enable cotire" ON)
if(MIRRAGE_ENABLE_COTIRE)
include(cotire OPTIONAL)
if(COMMAND cotire)
add_definitions(-DGLM_FORCE_RADIANS -DGLM_FORCE_DEPTH_ZERO_TO_ON -DGLM_ENABLE_EXPERIMENTAL -DGLM_FORCE_CXX14)
add_compile_options(-pthread)
set_property(GLOBAL PROPERTY COTIRE_PREFIX_HEADER_INCLUDE_PATH "${MIRRAGE_ROOT_DIR}/dependencies")
set_property(GLOBAL PROPERTY COTIRE_PREFIX_HEADER_IGNORE_PATH "${MIRRAGE_ROOT_DIR}/dependencies/nuklear;${MIRRAGE_ROOT_DIR}/src;${MIRRAGE_ROOT_DIR}/dependencies/moodycamel/concurrentqueue.h")
set_property(GLOBAL PROPERTY COTIRE_ADD_UNITY_BUILD FALSE)
endif()
endif()
option(MIRRAGE_ENABLE_TESTS "Enable unit tests" ON)
if(MIRRAGE_ENABLE_TESTS)
enable_testing()
endif()
option(MIRRAGE_ENABLE_CLANG_FORMAT "Includes a clangformat target, that automatically formats the source files." OFF)
if(MIRRAGE_ENABLE_CLANG_FORMAT)
include(clang-format.cmake)
endif()
cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
option(MIRRAGE_SAN "Build with sanitizers" OFF)
if(MIRRAGE_SAN)
MESSAGE("Building with sanitizers")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fsanitize=integer -fsanitize=undefined -fsanitize-address-use-after-scope ")
endif()
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -gline-tables-only") # for stack traces
endif()
endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(MIRRAGE_DEFAULT_COMPILER_ARGS -Wextra -Wall -pedantic -Wextra-semi
-Wzero-as-null-pointer-constant -Wold-style-cast -Werror
-Wno-unused-parameter -Wno-unused-private-field -Wno-missing-braces)
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(MIRRAGE_DEFAULT_COMPILER_ARGS -Wextra -Wall -pedantic
-Wlogical-op -Werror -Wno-unused-parameter
-Wno-missing-braces)
# TODO: removed (for now) because of false-positives: -Wzero-as-null-pointer-constant
elseif(MSVC)
set(MIRRAGE_DEFAULT_COMPILER_ARGS /Za)
endif()
# add_definitions(-DHPC_HISTOGRAM_DEBUG_VIEW)
add_definitions(-DGSL_TERMINATE_ON_CONTRACT_VIOLATION)
#add_definitions(-DHPC_HISTOGRAM_DEBUG_VIEW)
if(MIRRAGE_BUILD_DEMO)
add_subdirectory(demo)
endif()
......@@ -44,7 +10,3 @@ endif()
add_subdirectory(mirrage)
option(MIRRAGE_ENABLE_CLANG_FORMAT "Includes a clangformat target, that automatically formats the source files." OFF)
if(MIRRAGE_ENABLE_CLANG_FORMAT)
include(clang-format.cmake)
endif()
......@@ -30,15 +30,9 @@ target_link_libraries(demo
doctest
)
option(MIRRAGE_COMPILE_SHADERS "Compile demo shaders" OFF)
if(MIRRAGE_COMPILE_SHADERS)
include(shaders.cmake)
add_dependencies(demo demo_shaders)
endif()
option(MIRRAGE_EXPORT_EXECUTABLE "Export executable" OFF)
if(MIRRAGE_EXPORT_EXECUTABLE)
install(DIRECTORY ${ROOT_DIR}/assets/ DESTINATION bin)
install(DIRECTORY ${MIRRAGE_ROOT_DIR}/assets/ DESTINATION bin)
install(TARGETS demo RUNTIME DESTINATION bin)
endif()
......
......@@ -138,10 +138,19 @@ namespace {
void init_physicsfs(const std::string& exe_name)
{
if(!PHYSFS_isInit() && !PHYSFS_init(exe_name.empty() ? nullptr : exe_name.c_str())) {
if(PHYSFS_isInit())
return;
if(!PHYSFS_init(exe_name.empty() ? nullptr : exe_name.c_str())) {
throw std::system_error(static_cast<mirrage::asset::Asset_error>(PHYSFS_getLastErrorCode()),
"Unable to initalize PhysicsFS.");
}
if(!PHYSFS_mount(PHYSFS_getBaseDir(), nullptr, 1)
|| !PHYSFS_mount(append_file(PHYSFS_getBaseDir(), "..").c_str(), nullptr, 1)
|| !PHYSFS_mount(mirrage::asset::pwd().c_str(), nullptr, 1))
throw std::system_error(static_cast<mirrage::asset::Asset_error>(PHYSFS_getLastErrorCode()),
"Unable to setup default search path.");
}
constexpr auto default_source = {std::make_tuple("assets", false), std::make_tuple("assets.zip", true)};
......@@ -170,7 +179,7 @@ namespace mirrage::asset {
init_physicsfs(exe_name);
if(exists_dir("write_dir")) {
return "write_dir";
return std::string(PHYSFS_getRealDir("write_dir")) + "/write_dir";
}
return PHYSFS_getPrefDir(org_name.c_str(), app_name.c_str());
......@@ -184,15 +193,7 @@ namespace mirrage::asset {
init_physicsfs(exe_name);
auto write_dir = ::mirrage::asset::write_dir(exe_name, org_name, app_name);
if(!PHYSFS_mount(PHYSFS_getBaseDir(), nullptr, 1)
|| !PHYSFS_mount(append_file(PHYSFS_getBaseDir(), "..").c_str(), nullptr, 1)
|| !PHYSFS_mount(pwd().c_str(), nullptr, 1))
throw std::system_error(static_cast<Asset_error>(PHYSFS_getLastErrorCode()),
"Unable to setup default search path.");
create_dir(write_dir);
LOG(plog::debug) << "Write dir: " << write_dir;
if(!PHYSFS_mount(write_dir.c_str(), nullptr, 0))
......@@ -205,6 +206,7 @@ namespace mirrage::asset {
auto add_source = [](const char* path) {
LOG(plog::info) << "Added FS directory: " << path;
if(!PHYSFS_mount(path, nullptr, 1))
throw std::system_error(static_cast<Asset_error>(PHYSFS_getLastErrorCode()),
"Error adding custom archive: "s + path);
......@@ -240,7 +242,6 @@ namespace mirrage::asset {
for(auto&& l : in.lines()) {
if(l.find_last_of('*') != std::string::npos) {
for(auto& file : list_wildcard_files(l)) {
LOG(plog::info) << "Added FS directory: " << file;
add_source(file.c_str());
}
continue;
......
......@@ -43,6 +43,11 @@ add_library(mirrage::renderer ALIAS mirrage_renderer)
set(MIRRAGE_DEFAULT_COMPILER_ARGS ${MIRRAGE_DEFAULT_COMPILER_ARGS})
target_compile_options(mirrage_renderer PRIVATE ${MIRRAGE_DEFAULT_COMPILER_ARGS})
option(MIRRAGE_COMPILE_SHADERS "Compile demo shaders" OFF)
if(MIRRAGE_COMPILE_SHADERS)
include(shaders.cmake)
add_dependencies(mirrage_renderer demo_shaders)
endif()
target_include_directories(mirrage_renderer PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
......
......@@ -51,7 +51,7 @@ namespace mirrage::renderer {
bool ssao = true;
bool bloom = true;
float background_intensity = 0.f;
float background_intensity = 1.f;
bool shadows = true;
bool dynamic_lighting = true;
......
# build shaders
file(GLOB_RECURSE GLSL_SOURCE_FILES
"${ROOT_DIR}/assets/core_assets/shader/*.frag"
"${ROOT_DIR}/assets/core_assets/shader/*.vert"
"${ROOT_DIR}/assets/core_assets/shader/*.comp"
"${MIRRAGE_ROOT_DIR}/assets/core_assets/shader/*.frag"
"${MIRRAGE_ROOT_DIR}/assets/core_assets/shader/*.vert"
"${MIRRAGE_ROOT_DIR}/assets/core_assets/shader/*.comp"
)
set(GLSL_COMPILER "glslc")
foreach(GLSL ${GLSL_SOURCE_FILES})
get_filename_component(FILE_NAME ${GLSL} NAME)
set(SPIRV "${ROOT_DIR}/assets/core_assets/shader/bin/${FILE_NAME}.spv")
set(SPIRV "${MIRRAGE_ROOT_DIR}/assets/core_assets/shader/bin/${FILE_NAME}.spv")
add_custom_command(
OUTPUT ${SPIRV}
COMMAND ${CMAKE_COMMAND} -E make_directory "${ROOT_DIR}/assets/core_assets/shader/bin/"
COMMAND ${CMAKE_COMMAND} -E make_directory "${MIRRAGE_ROOT_DIR}/assets/core_assets/shader/bin/"
COMMAND ${GLSL_COMPILER} ${GLSL} -o ${SPIRV}
DEPENDS ${GLSL})
list(APPEND SPIRV_BINARY_FILES ${SPIRV})
......
......@@ -177,7 +177,7 @@ namespace mirrage::renderer {
for(auto& geo : frame.geometry_queue) {
if(!geo.model->rigged())
break;
continue;
auto offset = gsl::narrow<std::uint32_t>(required_size);
......
......@@ -196,7 +196,7 @@ namespace mirrage::renderer {
if(!_renderer.settings().bloom)
return;
auto blur_mip_levels = 3;
auto blur_mip_levels = 2;
auto start_mip_level = std::min(3, _src.mip_levels() - blur_mip_levels);
......
......@@ -34,21 +34,15 @@ namespace mirrage::renderer {
{
pass.stage("default"_strid)
.shader("frag_shader:model"_aid, graphic::Shader_stage::fragment)
.shader("vert_shader:model"_aid, graphic::Shader_stage::vertex)
.color_mask(3, vk::ColorComponentFlags{})
.color_mask(4, vk::ColorComponentFlags{});
.shader("vert_shader:model"_aid, graphic::Shader_stage::vertex);
pass.stage("emissive"_strid)
.shader("frag_shader:model_emissive"_aid, graphic::Shader_stage::fragment)
.shader("vert_shader:model"_aid, graphic::Shader_stage::vertex)
.color_mask(3, graphic::all_color_components)
.color_mask(4, graphic::all_color_components);
.shader("vert_shader:model"_aid, graphic::Shader_stage::vertex);
pass.stage("alphatest"_strid)
.shader("frag_shader:model_alphatest"_aid, graphic::Shader_stage::fragment)
.shader("vert_shader:model"_aid, graphic::Shader_stage::vertex)
.color_mask(3, vk::ColorComponentFlags{})
.color_mask(4, vk::ColorComponentFlags{});
.shader("vert_shader:model"_aid, graphic::Shader_stage::vertex);
}
void Deferred_geometry_subpass::configure_animation_pipeline(Deferred_renderer& renderer,
......@@ -74,48 +68,30 @@ namespace mirrage::renderer {
void Deferred_geometry_subpass::configure_animation_subpass(Deferred_renderer& renderer,
graphic::Subpass_builder& pass)
{
// TODO: technically UB if !independentBlend, because the shaders never write the attachments
// but seems to work fine on GTX 1060 and would only affect Intel<=Ivy Bridge and Android
auto gpu_features = renderer.device().physical_device().getFeatures();
auto ignore_mask =
gpu_features.independentBlend ? vk::ColorComponentFlags{} : graphic::all_color_components;
pass.stage("default"_strid)
.shader("frag_shader:model"_aid, graphic::Shader_stage::fragment)
.shader("vert_shader:model_animated"_aid, graphic::Shader_stage::vertex)
.color_mask(3, ignore_mask)
.color_mask(4, ignore_mask);
.shader("vert_shader:model_animated"_aid, graphic::Shader_stage::vertex);
pass.stage("emissive"_strid)
.shader("frag_shader:model_emissive"_aid, graphic::Shader_stage::fragment)
.shader("vert_shader:model_animated"_aid, graphic::Shader_stage::vertex)
.color_mask(3, graphic::all_color_components)
.color_mask(4, graphic::all_color_components);
.shader("vert_shader:model_animated"_aid, graphic::Shader_stage::vertex);
pass.stage("alphatest"_strid)
.shader("frag_shader:model_alphatest"_aid, graphic::Shader_stage::fragment)
.shader("vert_shader:model_animated"_aid, graphic::Shader_stage::vertex)
.color_mask(3, ignore_mask)
.color_mask(4, ignore_mask);
.shader("vert_shader:model_animated"_aid, graphic::Shader_stage::vertex);
pass.stage("dq_default"_strid)
.shader("frag_shader:model"_aid, graphic::Shader_stage::fragment)
.shader("vert_shader:model_animated_dqs"_aid, graphic::Shader_stage::vertex)
.color_mask(3, ignore_mask)
.color_mask(4, ignore_mask);
.shader("vert_shader:model_animated_dqs"_aid, graphic::Shader_stage::vertex);
pass.stage("dq_emissive"_strid)
.shader("frag_shader:model_emissive"_aid, graphic::Shader_stage::fragment)
.shader("vert_shader:model_animated_dqs"_aid, graphic::Shader_stage::vertex)
.color_mask(3, graphic::all_color_components)
.color_mask(4, graphic::all_color_components);
.shader("vert_shader:model_animated_dqs"_aid, graphic::Shader_stage::vertex);
pass.stage("dq_alphatest"_strid)
.shader("frag_shader:model_alphatest"_aid, graphic::Shader_stage::fragment)
.shader("vert_shader:model_animated_dqs"_aid, graphic::Shader_stage::vertex)
.color_mask(3, ignore_mask)
.color_mask(4, ignore_mask);
.shader("vert_shader:model_animated_dqs"_aid, graphic::Shader_stage::vertex);
}
void Deferred_geometry_subpass::update(util::Time) {}
......@@ -192,6 +168,9 @@ namespace mirrage::renderer {
last_model = static_cast<const Model*>(nullptr);
for(auto& geo : _rigged_geometry_range) {
if(geo.animation_uniform_offset.is_nothing())
continue;
auto& sub_mesh = geo.model->sub_meshes().at(geo.sub_mesh);
prepare_draw(geo);
......
......@@ -178,10 +178,10 @@ namespace mirrage::renderer {
auto attachments = std::array<Framebuffer_attachment_desc, 6>{
{{depth_buffer.view(0), 1.f},
{gbuffer.depth.view(0), util::Rgba(1.f)},
{gbuffer.albedo_mat_id.view(0), sky_color},
{gbuffer.albedo_mat_id.view(0), util::Rgba{0, 0, 0, 0}},
{gbuffer.mat_data.view(0), util::Rgba{0, 0, 1, 0}},
{color_target.view(0), util::Rgba{0, 0, 0, 0}},
{color_target_diff.view(0), util::Rgba{0, 0, 0, 0}}}};
{color_target.view(0), sky_color},
{color_target_diff.view(0), sky_color}}};
out_framebuffer =
builder.build_framebuffer(attachments, color_target.width(), color_target.height());
......@@ -273,7 +273,5 @@ namespace mirrage::renderer {
util::maybe<std::uint32_t>,
graphic::Device_create_info& ci)
{
// enable independent blend if available for faster geometry pass
ci.features.setIndependentBlend(pd.getFeatures().independentBlend);
}
} // namespace mirrage::renderer
......@@ -100,6 +100,7 @@
#include <cassert>
#include <cstddef>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <initializer_list>
#include <iterator>
......
......@@ -65,7 +65,7 @@ namespace mirrage::util {
return arr;
}
constexpr auto pow_38_table = gen_pow_38_table<str_id_max_length>();
constexpr auto pow_38_table = gen_pow_38_table<str_id_max_length + 1>();
} // namespace detail
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment