mirror of
https://github.com/bailwillharr/engine.git
synced 2024-09-21 04:51:18 +00:00
Get Dear ImGui working again and make the scene dark and forboding
This commit is contained in:
parent
389c979f2f
commit
81ed78de51
@ -44,7 +44,12 @@ void main() {
|
|||||||
|
|
||||||
const float roughness_2 = roughness * roughness;
|
const float roughness_2 = roughness * roughness;
|
||||||
|
|
||||||
const vec3 light_colour = vec3(1.0, 1.0, 1.0) * 2.4;
|
vec3 light_colour = vec3(1.0, 1.0, 1.0) * 2.4;
|
||||||
|
float light_distance = length(fragLightPosTangentSpace - fragPosTangentSpace);
|
||||||
|
float attenuation = 1.0 / (1.0 + 0.09 * light_distance +
|
||||||
|
0.032 * (light_distance * light_distance));
|
||||||
|
light_colour *= 5.0 * attenuation;
|
||||||
|
|
||||||
const vec3 emission = vec3(0.0, 0.0, 0.0);
|
const vec3 emission = vec3(0.0, 0.0, 0.0);
|
||||||
|
|
||||||
const vec3 albedo = vec3(texture(materialSetAlbedoSampler, fragUV));
|
const vec3 albedo = vec3(texture(materialSetAlbedoSampler, fragUV));
|
||||||
@ -90,7 +95,7 @@ void main() {
|
|||||||
lighting *= shadow;
|
lighting *= shadow;
|
||||||
|
|
||||||
vec3 ambient_light = vec3(0.09082, 0.13281, 0.18164);
|
vec3 ambient_light = vec3(0.09082, 0.13281, 0.18164);
|
||||||
lighting += mix(ambient_light, texture(globalSetSkybox, R).rgb, metallic) * ao * diffuse_brdf; // this is NOT physically-based, it just looks cool
|
//lighting += mix(ambient_light, texture(globalSetSkybox, R).rgb, metallic) * ao * diffuse_brdf; // this is NOT physically-based, it just looks cool
|
||||||
|
|
||||||
outColor = vec4(min(emission + lighting, 1.0), 1.0);
|
outColor = vec4(min(emission + lighting, 1.0), 1.0);
|
||||||
//outColor = vec4(vec3(shadow), 1.0);
|
//outColor = vec4(vec3(shadow), 1.0);
|
||||||
|
@ -224,9 +224,9 @@ void Application::GameLoop()
|
|||||||
debug_menu_state.show_info_window = !debug_menu_state.show_info_window;
|
debug_menu_state.show_info_window = !debug_menu_state.show_info_window;
|
||||||
}
|
}
|
||||||
|
|
||||||
//ImGui_ImplVulkan_NewFrame();
|
ImGui_ImplVulkan_NewFrame();
|
||||||
//ImGui_ImplSDL2_NewFrame();
|
ImGui_ImplSDL2_NewFrame();
|
||||||
//ImGui::NewFrame();
|
ImGui::NewFrame();
|
||||||
|
|
||||||
if (debug_menu_state.menu_active) {
|
if (debug_menu_state.menu_active) {
|
||||||
if (ImGui::Begin("debugMenu", 0)) {
|
if (ImGui::Begin("debugMenu", 0)) {
|
||||||
@ -269,7 +269,7 @@ void Application::GameLoop()
|
|||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
//ImGui::Render();
|
ImGui::Render();
|
||||||
|
|
||||||
const RenderList* static_list = nullptr;
|
const RenderList* static_list = nullptr;
|
||||||
const RenderList* dynamic_list = nullptr;
|
const RenderList* dynamic_list = nullptr;
|
||||||
|
@ -577,74 +577,46 @@ void GFXDevice::GetViewportSize(uint32_t* w, uint32_t* h)
|
|||||||
|
|
||||||
void GFXDevice::SetupImguiBackend()
|
void GFXDevice::SetupImguiBackend()
|
||||||
{
|
{
|
||||||
// disable imgui for now
|
auto loaderFunc = [](const char* function_name, void* user_data) -> PFN_vkVoidFunction {
|
||||||
#if 0
|
return vkGetInstanceProcAddr(*reinterpret_cast<VkInstance*>(user_data), function_name);
|
||||||
|
};
|
||||||
|
if (ImGui_ImplVulkan_LoadFunctions(loaderFunc, &pimpl->instance.instance) == false) throw std::runtime_error("Failed to load vulkan functions for imgui");
|
||||||
|
|
||||||
|
VkPipelineRenderingCreateInfo renderingInfo{};
|
||||||
|
renderingInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO;
|
||||||
|
renderingInfo.colorAttachmentCount = 1;
|
||||||
|
renderingInfo.pColorAttachmentFormats = &pimpl->swapchain.surfaceFormat.format;
|
||||||
|
renderingInfo.depthAttachmentFormat = pimpl->swapchain.depthStencilFormat;
|
||||||
|
|
||||||
ImGui_ImplVulkan_InitInfo initInfo{};
|
ImGui_ImplVulkan_InitInfo initInfo{};
|
||||||
initInfo.Instance = pimpl->instance.instance;
|
initInfo.Instance = pimpl->instance.instance;
|
||||||
initInfo.PhysicalDevice = pimpl->device.physicalDevice;
|
initInfo.PhysicalDevice = pimpl->device.physicalDevice;
|
||||||
initInfo.Device = pimpl->device.device;
|
initInfo.Device = pimpl->device.device;
|
||||||
initInfo.QueueFamily = pimpl->device.queues.presentAndDrawQueueFamily;
|
initInfo.QueueFamily = pimpl->device.queues.presentAndDrawQueueFamily;
|
||||||
initInfo.Queue = pimpl->device.queues.drawQueues.back(); // hopefully this isn't used by anything else?
|
initInfo.Queue = pimpl->device.queues.drawQueues.back(); // hopefully this isn't used by anything else?
|
||||||
initInfo.PipelineCache = VK_NULL_HANDLE;
|
|
||||||
initInfo.DescriptorPool = pimpl->descriptorPool;
|
initInfo.DescriptorPool = pimpl->descriptorPool;
|
||||||
initInfo.Subpass = 0;
|
initInfo.RenderPass = VK_NULL_HANDLE;
|
||||||
initInfo.MinImageCount = 3;
|
initInfo.MinImageCount = 3;
|
||||||
initInfo.ImageCount = 3;
|
initInfo.ImageCount = 3;
|
||||||
initInfo.MSAASamples = VK_SAMPLE_COUNT_1_BIT;
|
initInfo.MSAASamples = VK_SAMPLE_COUNT_1_BIT;
|
||||||
initInfo.Allocator = nullptr;
|
|
||||||
initInfo.CheckVkResultFn = check_vk_result;
|
initInfo.CheckVkResultFn = check_vk_result;
|
||||||
bool success = ImGui_ImplVulkan_Init(&initInfo, pimpl->swapchain.renderpass);
|
initInfo.UseDynamicRendering = true;
|
||||||
|
initInfo.PipelineRenderingCreateInfo = renderingInfo;
|
||||||
|
bool success = ImGui_ImplVulkan_Init(&initInfo);
|
||||||
if (!success) throw std::runtime_error("ImGui_ImplVulkan_Init failed!");
|
if (!success) throw std::runtime_error("ImGui_ImplVulkan_Init failed!");
|
||||||
|
|
||||||
/* begin command buffer */
|
ImGui_ImplVulkan_CreateFontsTexture();
|
||||||
VkCommandBufferAllocateInfo allocInfo{};
|
|
||||||
allocInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
|
|
||||||
allocInfo.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
|
|
||||||
allocInfo.commandPool = pimpl->graphicsCommandPool;
|
|
||||||
allocInfo.commandBufferCount = 1;
|
|
||||||
|
|
||||||
VkCommandBuffer commandBuffer;
|
|
||||||
VKCHECK(vkAllocateCommandBuffers(pimpl->device.device, &allocInfo, &commandBuffer));
|
|
||||||
|
|
||||||
VkCommandBufferBeginInfo beginInfo{};
|
|
||||||
beginInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
|
|
||||||
beginInfo.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
|
|
||||||
VKCHECK(vkBeginCommandBuffer(commandBuffer, &beginInfo));
|
|
||||||
|
|
||||||
ImGui_ImplVulkan_CreateFontsTexture(commandBuffer);
|
|
||||||
|
|
||||||
VKCHECK(vkEndCommandBuffer(commandBuffer));
|
|
||||||
|
|
||||||
// submit
|
|
||||||
VkSubmitInfo submitInfo{};
|
|
||||||
submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
|
|
||||||
submitInfo.commandBufferCount = 1;
|
|
||||||
submitInfo.pCommandBuffers = &commandBuffer;
|
|
||||||
|
|
||||||
VKCHECK(vkQueueSubmit(pimpl->device.queues.drawQueues[0], 1, &submitInfo, VK_NULL_HANDLE));
|
|
||||||
|
|
||||||
VKCHECK(vkQueueWaitIdle(pimpl->device.queues.drawQueues[0]));
|
|
||||||
|
|
||||||
vkFreeCommandBuffers(pimpl->device.device, pimpl->graphicsCommandPool, 1, &commandBuffer);
|
|
||||||
|
|
||||||
ImGui_ImplVulkan_DestroyFontUploadObjects();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GFXDevice::ShutdownImguiBackend()
|
void GFXDevice::ShutdownImguiBackend()
|
||||||
{
|
{
|
||||||
// disable imgui for now
|
ImGui_ImplVulkan_DestroyFontsTexture();
|
||||||
#if 0
|
|
||||||
ImGui_ImplVulkan_Shutdown();
|
ImGui_ImplVulkan_Shutdown();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GFXDevice::CmdRenderImguiDrawData(gfx::DrawBuffer* draw_buffer, ImDrawData* draw_data)
|
void GFXDevice::CmdRenderImguiDrawData(gfx::DrawBuffer* draw_buffer, ImDrawData* draw_data)
|
||||||
{
|
{
|
||||||
// disable imgui rendering for now
|
|
||||||
#if 0
|
|
||||||
ImGui_ImplVulkan_RenderDrawData(draw_data, draw_buffer->frameData.drawBuf);
|
ImGui_ImplVulkan_RenderDrawData(draw_data, draw_buffer->frameData.drawBuf);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::DrawBuffer* GFXDevice::BeginRender()
|
gfx::DrawBuffer* GFXDevice::BeginRender()
|
||||||
@ -826,9 +798,9 @@ gfx::DrawBuffer* GFXDevice::BeginRender()
|
|||||||
|
|
||||||
std::array<VkClearValue, 2> clearValues{}; // Using same value for all components enables
|
std::array<VkClearValue, 2> clearValues{}; // Using same value for all components enables
|
||||||
// compression according to NVIDIA Best Practices
|
// compression according to NVIDIA Best Practices
|
||||||
clearValues[0].color.float32[0] = 1.0f;
|
clearValues[0].color.float32[0] = 0.0f;
|
||||||
clearValues[0].color.float32[1] = 1.0f;
|
clearValues[0].color.float32[1] = 0.0f;
|
||||||
clearValues[0].color.float32[2] = 1.0f;
|
clearValues[0].color.float32[2] = 0.0f;
|
||||||
clearValues[0].color.float32[3] = 1.0f;
|
clearValues[0].color.float32[3] = 1.0f;
|
||||||
clearValues[1].depthStencil.depth = 1.0f;
|
clearValues[1].depthStencil.depth = 1.0f;
|
||||||
|
|
||||||
@ -1139,7 +1111,7 @@ gfx::DrawBuffer* GFXDevice::BeginShadowmapRender(gfx::Image* image)
|
|||||||
|
|
||||||
VkRect2D scissor{};
|
VkRect2D scissor{};
|
||||||
scissor.offset = {0, 0};
|
scissor.offset = {0, 0};
|
||||||
scissor.extent = { kShadowmapSize, kShadowmapSize };
|
scissor.extent = {kShadowmapSize, kShadowmapSize};
|
||||||
vkCmdSetScissor(pimpl->frameData[0].drawBuf, 0, 1, &scissor);
|
vkCmdSetScissor(pimpl->frameData[0].drawBuf, 0, 1, &scissor);
|
||||||
|
|
||||||
// Depth bias (and slope) are used to avoid shadowing artifacts
|
// Depth bias (and slope) are used to avoid shadowing artifacts
|
||||||
@ -1149,12 +1121,7 @@ gfx::DrawBuffer* GFXDevice::BeginShadowmapRender(gfx::Image* image)
|
|||||||
constexpr float depthBiasSlope = 1.75f;
|
constexpr float depthBiasSlope = 1.75f;
|
||||||
// Set depth bias (aka "Polygon offset")
|
// Set depth bias (aka "Polygon offset")
|
||||||
// Required to avoid shadow mapping artifacts
|
// Required to avoid shadow mapping artifacts
|
||||||
vkCmdSetDepthBias(
|
vkCmdSetDepthBias(pimpl->frameData[0].drawBuf, depthBiasConstant, 0.0f, depthBiasSlope);
|
||||||
pimpl->frameData[0].drawBuf,
|
|
||||||
depthBiasConstant,
|
|
||||||
0.0f,
|
|
||||||
depthBiasSlope);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// hand command buffer over to caller
|
// hand command buffer over to caller
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -2,18 +2,23 @@
|
|||||||
// This needs to be used along with a Platform Backend (e.g. GLFW, SDL, Win32, custom..)
|
// This needs to be used along with a Platform Backend (e.g. GLFW, SDL, Win32, custom..)
|
||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices.
|
// [!] Renderer: User texture binding. Use 'VkDescriptorSet' as ImTextureID. Read the FAQ about ImTextureID! See https://github.com/ocornut/imgui/pull/914 for discussions.
|
||||||
// Missing features:
|
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
|
||||||
// [ ] Renderer: User texture binding. Changes of ImTextureID aren't supported by this backend! See https://github.com/ocornut/imgui/pull/914
|
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// Important: on 32-bit systems, user texture binding is only supported if your imconfig file has '#define ImTextureID ImU64'.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// See imgui_impl_vulkan.cpp file for details.
|
||||||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
|
||||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
|
||||||
|
|
||||||
// The aim of imgui_impl_vulkan.h/.cpp is to be usable in your engine without any modification.
|
// The aim of imgui_impl_vulkan.h/.cpp is to be usable in your engine without any modification.
|
||||||
// IF YOU FEEL YOU NEED TO MAKE ANY CHANGE TO THIS CODE, please share them and your feedback at https://github.com/ocornut/imgui/
|
// IF YOU FEEL YOU NEED TO MAKE ANY CHANGE TO THIS CODE, please share them and your feedback at https://github.com/ocornut/imgui/
|
||||||
|
|
||||||
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
|
// Learn about Dear ImGui:
|
||||||
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
// Important note to the reader who wish to integrate imgui_impl_vulkan.cpp/.h in their own engine/app.
|
// Important note to the reader who wish to integrate imgui_impl_vulkan.cpp/.h in their own engine/app.
|
||||||
// - Common ImGui_ImplVulkan_XXX functions and structures are used to interface with imgui_impl_vulkan.cpp/.h.
|
// - Common ImGui_ImplVulkan_XXX functions and structures are used to interface with imgui_impl_vulkan.cpp/.h.
|
||||||
// You will use those if you want to use this rendering backend in your engine/app.
|
// You will use those if you want to use this rendering backend in your engine/app.
|
||||||
@ -22,6 +27,7 @@
|
|||||||
// Read comments in imgui_impl_vulkan.h.
|
// Read comments in imgui_impl_vulkan.h.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
#include "imgui.h" // IMGUI_IMPL_API
|
#include "imgui.h" // IMGUI_IMPL_API
|
||||||
|
|
||||||
// [Configuration] in order to use a custom Vulkan function loader:
|
// [Configuration] in order to use a custom Vulkan function loader:
|
||||||
@ -34,15 +40,26 @@
|
|||||||
// - Do not simply add it in a .cpp file!
|
// - Do not simply add it in a .cpp file!
|
||||||
// (2) Call ImGui_ImplVulkan_LoadFunctions() before ImGui_ImplVulkan_Init() with your custom function.
|
// (2) Call ImGui_ImplVulkan_LoadFunctions() before ImGui_ImplVulkan_Init() with your custom function.
|
||||||
// If you have no idea what this is, leave it alone!
|
// If you have no idea what this is, leave it alone!
|
||||||
//#define IMGUI_IMPL_VULKAN_NO_PROTOTYPES
|
#define IMGUI_IMPL_VULKAN_NO_PROTOTYPES
|
||||||
|
|
||||||
// Vulkan includes
|
// Vulkan includes
|
||||||
#if defined(IMGUI_IMPL_VULKAN_NO_PROTOTYPES) && !defined(VK_NO_PROTOTYPES)
|
#if defined(IMGUI_IMPL_VULKAN_NO_PROTOTYPES) && !defined(VK_NO_PROTOTYPES)
|
||||||
#define VK_NO_PROTOTYPES
|
#define VK_NO_PROTOTYPES
|
||||||
#endif
|
#endif
|
||||||
#include "volk.h"
|
#if defined(VK_USE_PLATFORM_WIN32_KHR) && !defined(NOMINMAX)
|
||||||
|
#define NOMINMAX
|
||||||
|
#include <vulkan/vulkan.h>
|
||||||
|
#else
|
||||||
|
#include <vulkan/vulkan.h>
|
||||||
|
#endif
|
||||||
|
#if defined(VK_VERSION_1_3) || defined(VK_KHR_dynamic_rendering)
|
||||||
|
#define IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
|
||||||
|
#endif
|
||||||
|
|
||||||
// Initialization data, for ImGui_ImplVulkan_Init()
|
// Initialization data, for ImGui_ImplVulkan_Init()
|
||||||
|
// - VkDescriptorPool should be created with VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT,
|
||||||
|
// and must contain a pool size large enough to hold an ImGui VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER descriptor.
|
||||||
|
// - When using dynamic rendering, set UseDynamicRendering=true and fill PipelineRenderingCreateInfo structure.
|
||||||
// [Please zero-clear before use!]
|
// [Please zero-clear before use!]
|
||||||
struct ImGui_ImplVulkan_InitInfo
|
struct ImGui_ImplVulkan_InitInfo
|
||||||
{
|
{
|
||||||
@ -51,28 +68,47 @@ struct ImGui_ImplVulkan_InitInfo
|
|||||||
VkDevice Device;
|
VkDevice Device;
|
||||||
uint32_t QueueFamily;
|
uint32_t QueueFamily;
|
||||||
VkQueue Queue;
|
VkQueue Queue;
|
||||||
VkPipelineCache PipelineCache;
|
VkDescriptorPool DescriptorPool; // See requirements in note above
|
||||||
VkDescriptorPool DescriptorPool;
|
VkRenderPass RenderPass; // Ignored if using dynamic rendering
|
||||||
uint32_t Subpass;
|
|
||||||
uint32_t MinImageCount; // >= 2
|
uint32_t MinImageCount; // >= 2
|
||||||
uint32_t ImageCount; // >= MinImageCount
|
uint32_t ImageCount; // >= MinImageCount
|
||||||
VkSampleCountFlagBits MSAASamples; // >= VK_SAMPLE_COUNT_1_BIT
|
VkSampleCountFlagBits MSAASamples; // 0 defaults to VK_SAMPLE_COUNT_1_BIT
|
||||||
|
|
||||||
|
// (Optional)
|
||||||
|
VkPipelineCache PipelineCache;
|
||||||
|
uint32_t Subpass;
|
||||||
|
|
||||||
|
// (Optional) Dynamic Rendering
|
||||||
|
// Need to explicitly enable VK_KHR_dynamic_rendering extension to use this, even for Vulkan 1.3.
|
||||||
|
bool UseDynamicRendering;
|
||||||
|
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
|
||||||
|
VkPipelineRenderingCreateInfoKHR PipelineRenderingCreateInfo;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// (Optional) Allocation, Debugging
|
||||||
const VkAllocationCallbacks* Allocator;
|
const VkAllocationCallbacks* Allocator;
|
||||||
void (*CheckVkResultFn)(VkResult err);
|
void (*CheckVkResultFn)(VkResult err);
|
||||||
|
VkDeviceSize MinAllocationSize; // Minimum allocation size. Set to 1024*1024 to satisfy zealous best practices validation layer and waste a little memory.
|
||||||
};
|
};
|
||||||
|
|
||||||
// Called by user code
|
// Called by user code
|
||||||
IMGUI_IMPL_API bool ImGui_ImplVulkan_Init(ImGui_ImplVulkan_InitInfo* info, VkRenderPass render_pass);
|
IMGUI_IMPL_API bool ImGui_ImplVulkan_Init(ImGui_ImplVulkan_InitInfo* info);
|
||||||
IMGUI_IMPL_API void ImGui_ImplVulkan_Shutdown();
|
IMGUI_IMPL_API void ImGui_ImplVulkan_Shutdown();
|
||||||
IMGUI_IMPL_API void ImGui_ImplVulkan_NewFrame();
|
IMGUI_IMPL_API void ImGui_ImplVulkan_NewFrame();
|
||||||
IMGUI_IMPL_API void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer command_buffer, VkPipeline pipeline = VK_NULL_HANDLE);
|
IMGUI_IMPL_API void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer command_buffer, VkPipeline pipeline = VK_NULL_HANDLE);
|
||||||
IMGUI_IMPL_API bool ImGui_ImplVulkan_CreateFontsTexture(VkCommandBuffer command_buffer);
|
IMGUI_IMPL_API bool ImGui_ImplVulkan_CreateFontsTexture();
|
||||||
IMGUI_IMPL_API void ImGui_ImplVulkan_DestroyFontUploadObjects();
|
IMGUI_IMPL_API void ImGui_ImplVulkan_DestroyFontsTexture();
|
||||||
IMGUI_IMPL_API void ImGui_ImplVulkan_SetMinImageCount(uint32_t min_image_count); // To override MinImageCount after initialization (e.g. if swap chain is recreated)
|
IMGUI_IMPL_API void ImGui_ImplVulkan_SetMinImageCount(uint32_t min_image_count); // To override MinImageCount after initialization (e.g. if swap chain is recreated)
|
||||||
|
|
||||||
|
// Register a texture (VkDescriptorSet == ImTextureID)
|
||||||
|
// FIXME: This is experimental in the sense that we are unsure how to best design/tackle this problem
|
||||||
|
// Please post to https://github.com/ocornut/imgui/pull/914 if you have suggestions.
|
||||||
|
IMGUI_IMPL_API VkDescriptorSet ImGui_ImplVulkan_AddTexture(VkSampler sampler, VkImageView image_view, VkImageLayout image_layout);
|
||||||
|
IMGUI_IMPL_API void ImGui_ImplVulkan_RemoveTexture(VkDescriptorSet descriptor_set);
|
||||||
|
|
||||||
// Optional: load Vulkan functions with a custom function loader
|
// Optional: load Vulkan functions with a custom function loader
|
||||||
// This is only useful with IMGUI_IMPL_VULKAN_NO_PROTOTYPES / VK_NO_PROTOTYPES
|
// This is only useful with IMGUI_IMPL_VULKAN_NO_PROTOTYPES / VK_NO_PROTOTYPES
|
||||||
IMGUI_IMPL_API bool ImGui_ImplVulkan_LoadFunctions(PFN_vkVoidFunction(*loader_func)(const char* function_name, void* user_data), void* user_data = NULL);
|
IMGUI_IMPL_API bool ImGui_ImplVulkan_LoadFunctions(PFN_vkVoidFunction(*loader_func)(const char* function_name, void* user_data), void* user_data = nullptr);
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
// Internal / Miscellaneous Vulkan Helpers
|
// Internal / Miscellaneous Vulkan Helpers
|
||||||
@ -81,8 +117,8 @@ IMGUI_IMPL_API bool ImGui_ImplVulkan_LoadFunctions(PFN_vkVoidFunction(*loade
|
|||||||
// You probably do NOT need to use or care about those functions.
|
// You probably do NOT need to use or care about those functions.
|
||||||
// Those functions only exist because:
|
// Those functions only exist because:
|
||||||
// 1) they facilitate the readability and maintenance of the multiple main.cpp examples files.
|
// 1) they facilitate the readability and maintenance of the multiple main.cpp examples files.
|
||||||
// 2) the upcoming multi-viewport feature will need them internally.
|
// 2) the multi-viewport / platform window implementation needs them internally.
|
||||||
// Generally we avoid exposing any kind of superfluous high-level helpers in the backends,
|
// Generally we avoid exposing any kind of superfluous high-level helpers in the bindings,
|
||||||
// but it is too much code to duplicate everywhere so we exceptionally expose them.
|
// but it is too much code to duplicate everywhere so we exceptionally expose them.
|
||||||
//
|
//
|
||||||
// Your engine/app will likely _already_ have code to setup all that stuff (swap chain, render pass, frame buffers, etc.).
|
// Your engine/app will likely _already_ have code to setup all that stuff (swap chain, render pass, frame buffers, etc.).
|
||||||
@ -131,18 +167,22 @@ struct ImGui_ImplVulkanH_Window
|
|||||||
VkPresentModeKHR PresentMode;
|
VkPresentModeKHR PresentMode;
|
||||||
VkRenderPass RenderPass;
|
VkRenderPass RenderPass;
|
||||||
VkPipeline Pipeline; // The window pipeline may uses a different VkRenderPass than the one passed in ImGui_ImplVulkan_InitInfo
|
VkPipeline Pipeline; // The window pipeline may uses a different VkRenderPass than the one passed in ImGui_ImplVulkan_InitInfo
|
||||||
|
bool UseDynamicRendering;
|
||||||
bool ClearEnable;
|
bool ClearEnable;
|
||||||
VkClearValue ClearValue;
|
VkClearValue ClearValue;
|
||||||
uint32_t FrameIndex; // Current frame being rendered to (0 <= FrameIndex < FrameInFlightCount)
|
uint32_t FrameIndex; // Current frame being rendered to (0 <= FrameIndex < FrameInFlightCount)
|
||||||
uint32_t ImageCount; // Number of simultaneous in-flight frames (returned by vkGetSwapchainImagesKHR, usually derived from min_image_count)
|
uint32_t ImageCount; // Number of simultaneous in-flight frames (returned by vkGetSwapchainImagesKHR, usually derived from min_image_count)
|
||||||
|
uint32_t SemaphoreCount; // Number of simultaneous in-flight frames + 1, to be able to use it in vkAcquireNextImageKHR
|
||||||
uint32_t SemaphoreIndex; // Current set of swapchain wait semaphores we're using (needs to be distinct from per frame data)
|
uint32_t SemaphoreIndex; // Current set of swapchain wait semaphores we're using (needs to be distinct from per frame data)
|
||||||
ImGui_ImplVulkanH_Frame* Frames;
|
ImGui_ImplVulkanH_Frame* Frames;
|
||||||
ImGui_ImplVulkanH_FrameSemaphores* FrameSemaphores;
|
ImGui_ImplVulkanH_FrameSemaphores* FrameSemaphores;
|
||||||
|
|
||||||
ImGui_ImplVulkanH_Window()
|
ImGui_ImplVulkanH_Window()
|
||||||
{
|
{
|
||||||
memset(this, 0, sizeof(*this));
|
memset((void*)this, 0, sizeof(*this));
|
||||||
PresentMode = VK_PRESENT_MODE_MAX_ENUM_KHR;
|
PresentMode = (VkPresentModeKHR)~0; // Ensure we get an error if user doesn't set this.
|
||||||
ClearEnable = true;
|
ClearEnable = true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif // #ifndef IMGUI_DISABLE
|
@ -37,7 +37,7 @@ Renderer::Renderer(Application& app, gfx::GraphicsSettings settings) : Applicati
|
|||||||
//const glm::mat4 light_proj = glm::orthoRH_ZO(-10.0f, 10.0f, -10.0f, 10.0f, 1.0f, 50.0f);
|
//const glm::mat4 light_proj = glm::orthoRH_ZO(-10.0f, 10.0f, -10.0f, 10.0f, 1.0f, 50.0f);
|
||||||
const glm::mat4 light_proj = glm::perspectiveFovRH_ZO(glm::radians(90.0f), 1.0f, 1.0f, 5.0f, 50.0f);
|
const glm::mat4 light_proj = glm::perspectiveFovRH_ZO(glm::radians(90.0f), 1.0f, 1.0f, 5.0f, 50.0f);
|
||||||
const glm::mat4 light_view = glm::lookAtRH(light_location, glm::vec3{0.0f, 0.0f, 0.0f}, glm::vec3{0.0f, 0.0f, 1.0f});
|
const glm::mat4 light_view = glm::lookAtRH(light_location, glm::vec3{0.0f, 0.0f, 0.0f}, glm::vec3{0.0f, 0.0f, 1.0f});
|
||||||
global_uniform.uniform_buffer_data.data.proj = light_proj;
|
global_uniform.uniform_buffer_data.data.proj = glm::mat4{ 1.0f };
|
||||||
global_uniform.uniform_buffer_data.data.lightSpaceMatrix = light_proj * light_view;
|
global_uniform.uniform_buffer_data.data.lightSpaceMatrix = light_proj * light_view;
|
||||||
global_uniform.uniform_buffer = device_->CreateUniformBuffer(sizeof(global_uniform.uniform_buffer_data), &global_uniform.uniform_buffer_data);
|
global_uniform.uniform_buffer = device_->CreateUniformBuffer(sizeof(global_uniform.uniform_buffer_data), &global_uniform.uniform_buffer_data);
|
||||||
device_->UpdateDescriptorUniformBuffer(global_uniform.set, 0, global_uniform.uniform_buffer, 0, sizeof(global_uniform.uniform_buffer_data));
|
device_->UpdateDescriptorUniformBuffer(global_uniform.set, 0, global_uniform.uniform_buffer, 0, sizeof(global_uniform.uniform_buffer_data));
|
||||||
@ -210,9 +210,10 @@ Renderer::~Renderer()
|
|||||||
{
|
{
|
||||||
device_->DestroyPipeline(shadow_pipeline);
|
device_->DestroyPipeline(shadow_pipeline);
|
||||||
|
|
||||||
|
if (rendering_started) {
|
||||||
device_->DestroySampler(shadow_map_sampler);
|
device_->DestroySampler(shadow_map_sampler);
|
||||||
device_->DestroyImage(shadow_map);
|
device_->DestroyImage(shadow_map);
|
||||||
|
}
|
||||||
device_->DestroyBuffer(skybox_buffer);
|
device_->DestroyBuffer(skybox_buffer);
|
||||||
device_->DestroyPipeline(skybox_pipeline);
|
device_->DestroyPipeline(skybox_pipeline);
|
||||||
device_->DestroySampler(skybox_sampler);
|
device_->DestroySampler(skybox_sampler);
|
||||||
@ -320,7 +321,7 @@ void Renderer::Render(const RenderList* static_list, const RenderList* dynamic_l
|
|||||||
};
|
};
|
||||||
|
|
||||||
// draw skybox
|
// draw skybox
|
||||||
{
|
if (0) {
|
||||||
device_->CmdBindPipeline(draw_buffer, skybox_pipeline);
|
device_->CmdBindPipeline(draw_buffer, skybox_pipeline);
|
||||||
device_->CmdBindDescriptorSet(draw_buffer, skybox_pipeline, global_uniform.set, 0);
|
device_->CmdBindDescriptorSet(draw_buffer, skybox_pipeline, global_uniform.set, 0);
|
||||||
device_->CmdBindDescriptorSet(draw_buffer, skybox_pipeline, frame_uniform.set, 1);
|
device_->CmdBindDescriptorSet(draw_buffer, skybox_pipeline, frame_uniform.set, 1);
|
||||||
|
@ -63,7 +63,7 @@ void CameraControllerSystem::OnUpdate(float ts)
|
|||||||
|
|
||||||
// jumping
|
// jumping
|
||||||
if (scene_->app()->input_manager()->GetButtonPress("jump") && c->grounded) {
|
if (scene_->app()->input_manager()->GetButtonPress("jump") && c->grounded) {
|
||||||
c->vel.z += 4.4f; // m/s
|
c->vel.z += CameraControllerComponent::kJumpHeight; // m/s
|
||||||
}
|
}
|
||||||
|
|
||||||
// update position with velocity:
|
// update position with velocity:
|
||||||
|
@ -17,6 +17,7 @@ struct CameraControllerComponent {
|
|||||||
static constexpr float kSpeedForwardBack = 4.0f;
|
static constexpr float kSpeedForwardBack = 4.0f;
|
||||||
static constexpr float kSpeedStrafe = 4.0f;
|
static constexpr float kSpeedStrafe = 4.0f;
|
||||||
static constexpr float kSprintMultiplier = 2.0f;
|
static constexpr float kSprintMultiplier = 2.0f;
|
||||||
|
static constexpr float kJumpHeight = /*4.4f*/ 8.8f;
|
||||||
|
|
||||||
// collision
|
// collision
|
||||||
static constexpr float kPlayerHeight = 2.0f; // 71.0f * 25.4f / 1000.0f;
|
static constexpr float kPlayerHeight = 2.0f; // 71.0f * 25.4f / 1000.0f;
|
||||||
|
Loading…
Reference in New Issue
Block a user