text
stringlengths
1
24.5M
#include "physics.h" static inline btVector3 Vec3ToBulletVec3( const vec3& v ) { return btVector3( v.x, v.y, v.z ); } void Physics::addBox( const glm::vec3& halfSize, const btQuaternion& orientation, const vec3& position, float mass) { boxTransform.push_back(glm::mat4(1.0f)); btCollisionShape* collisionShape = ne...
#pragma once #include <cstdlib> #include <memory> #include <vector> #include <glm/glm.hpp> #include <glm/ext.hpp> using glm::mat4; using glm::vec3; using glm::vec4; #if defined(_MSC_VER) # pragma warning( push ) # pragma warning( disable:4305 ) #endif #include "btBulletDynamicsCommon.h" #include "btBulletCollisionC...
// layout(std140, binding = 0) uniform PerFrameData { uniform mat4 model; uniform mat4 MVP; uniform vec4 cameraPos; }; struct Vertex { float p[3]; float n[3]; float tc[2]; }; layout(std430, binding = 1) restrict readonly buffer Vertices { Vertex in_Vertices[]; };
// layout(std140, binding = 0) uniform PerFrameData { mat4 view; mat4 proj; vec4 cameraPos; }; struct Vertex { float p[3]; float n[3]; float tc[2]; }; layout(std430, binding = 1) restrict readonly buffer Vertices { Vertex in_Vertices[]; }; layout(std430, binding = 2) restrict readonly buffer Matrices { m...
float log10(float x) { return log(x) / log(10.0); } float satf(float x) { return clamp(x, 0.0, 1.0); } vec2 satv(vec2 x) { return clamp(x, vec2(0.0), vec2(1.0)); } float max2(vec2 v) { return max(v.x, v.y); } vec4 gridColor(vec2 uv, vec2 camPos) { vec2 dudv = vec2( length(vec2(dFdx(uv.x), dFdy(uv.x))), ...
// extents of grid in world coordinates float gridSize = 100.0; // size of one cell float gridCellSize = 0.025; // color of thin lines vec4 gridColorThin = vec4(0.5, 0.5, 0.5, 1.0); // color of thick lines (every tenth line) vec4 gridColorThick = vec4(0.0, 0.0, 0.0, 1.0); // minimum number of pixels between cell...
void runAlphaTest(float alpha, float alphaThreshold) { if (alphaThreshold > 0.0) { // http://alex-charlton.com/posts/Dithering_on_the_GPU/ // https://forums.khronos.org/showthread.php/5091-screen-door-transparency mat4 thresholdMatrix = mat4( 1.0 / 17.0, 9.0 / 17.0, 3.0 / 17.0, 11.0 / 17.0, 13.0 / 1...
// struct MaterialData { vec4 emissiveColor_; vec4 albedoColor_; vec4 roughness_; float transparencyFactor_; float alphaTest_; float metallicFactor_; uint flags_; uint64_t ambientOcclusionMap_; uint64_t emissiveMap_; uint64_t albedoMap_; uint64_t metallicRoughnessMap_; uint64_t normalMap_; uint64_t op...
// #extension GL_EXT_shader_explicit_arithmetic_types_int64: enable struct ImDrawVert { float x, y, z; float u, v; float nx, ny, nz; }; struct DrawData { uint mesh; uint material; uint lod; uint indexOffset; uint vertexOffset; uint transformIndex; }; #include <data/shaders/chapter07/MaterialData.h>
layout(binding = 0) uniform UniformBuffer { mat4 proj; mat4 view; vec4 cameraPos; } ubo; layout(binding = 1) readonly buffer SBO { ImDrawVert data[]; } sbo; layout(binding = 2) readonly buffer IBO { uint data[]; } ibo; layout(binding = 3) readonly buffer DrawBO { DrawData data[]; } drawDataBuffer; layout(bindi...
// struct Vertex { float p[3]; float n[3]; float tc[2]; }; layout(std430, binding = 1) restrict readonly buffer Vertices { Vertex in_Vertices[]; }; layout(std430, binding = 2) restrict readonly buffer Matrices { mat4 in_ModelMatrices[]; };
/**/ layout(location = 0) in vec2 texCoord; layout(location = 0) out vec4 outColor; layout(binding = 0) uniform sampler2D texSSAO; const vec4 gaussFilter[11] = vec4[]( vec4(-5.0, 0.0, 0.0, 3.0/133.0), vec4(-4.0, 0.0, 0.0, 6.0/133.0), vec4(-3.0, 0.0, 0.0, 10.0/133.0), vec4(-2.0, 0.0, 0.0, 15.0/133.0), vec4(-1...
// layout(std140, binding = 0) uniform PerFrameData { mat4 view; mat4 proj; mat4 light; vec4 cameraPos; vec4 frustumPlanes[6]; vec4 frustumCorners[8]; uint numShapesToCull; };
/* */ /* File: vk_platform.h */ /* */ /* ** Copyright (c) 2014-2017 The Khronos Group Inc. ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** ** http://www.apache.org/licenses/LICENSE...
/** * Loader generated by glad 2.0.0-beta on Wed Nov 13 10:54:33 2019 * * Generator: C/C++ * Specification: gl * Extensions: 1 * * APIs: * - gl:core=4.6 * * Options: * - MX_GLOBAL = False * - ON_DEMAND = False * - LOADER = False * - ALIAS = False * - HEADER_ONLY = False * - DEBUG = False * - MX...
/** * Loader generated by glad 2.0.0-beta on Wed Nov 13 10:54:34 2019 * * Generator: C/C++ * Specification: vk * Extensions: 0 * * APIs: * - vulkan=1.1 * * Options: * - MX_GLOBAL = False * - ON_DEMAND = False * - LOADER = False * - ALIAS = False * - HEADER_ONLY = False * - DEBUG = False * - MX ...
/** * Loader generated by glad 2.0.0-beta on Wed Nov 13 10:54:33 2019 * * Generator: C/C++ * Specification: wgl * Extensions: 2 * * APIs: * - wgl=1.0 * * Options: * - MX_GLOBAL = False * - ON_DEMAND = False * - LOADER = False * - ALIAS = False * - HEADER_ONLY = False * - DEBUG = False * - MX = ...
#ifndef __khrplatform_h_ #define __khrplatform_h_ /* ** Copyright (c) 2008-2018 The Khronos Group Inc. ** ** Permission is hereby granted, free of charge, to any person obtaining a ** copy of this software and/or associated documentation files (the ** "Materials"), to deal in the Materials without restriction, includi...
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <glad/gl.h> #ifndef GLAD_IMPL_UTIL_C_ #define GLAD_IMPL_UTIL_C_ #ifdef _MSC_VER #define GLAD_IMPL_UTIL_SSCANF sscanf_s #else #define GLAD_IMPL_UTIL_SSCANF sscanf #endif #endif /* GLAD_IMPL_UTIL_C_ */ int GLAD_GL_VERSION_1_0 = 0; int GLAD_GL_VERSIO...
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <glad/vulkan.h> #ifndef GLAD_IMPL_UTIL_C_ #define GLAD_IMPL_UTIL_C_ #ifdef _MSC_VER #define GLAD_IMPL_UTIL_SSCANF sscanf_s #else #define GLAD_IMPL_UTIL_SSCANF sscanf #endif #endif /* GLAD_IMPL_UTIL_C_ */ int GLAD_VK_VERSION_1_0 = 0; int GLAD_VK_VE...
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <glad/wgl.h> #ifndef GLAD_IMPL_UTIL_C_ #define GLAD_IMPL_UTIL_C_ #ifdef _MSC_VER #define GLAD_IMPL_UTIL_SSCANF sscanf_s #else #define GLAD_IMPL_UTIL_SSCANF sscanf #endif #endif /* GLAD_IMPL_UTIL_C_ */ int GLAD_WGL_VERSION_1_0 = 0; int GLAD_WGL_ARB...
#pragma once #include <string.h> #include <vector> #include <glm/glm.hpp> enum eBitmapType { eBitmapType_2D, eBitmapType_Cube }; enum eBitmapFormat { eBitmapFormat_UnsignedByte, eBitmapFormat_Float, }; /// R/RG/RGB/RGBA bitmaps struct Bitmap { Bitmap() = default; Bitmap(int w, int h, int comp, eBitmapForm...
#pragma once #include <assert.h> #include <algorithm> #include "shared/UtilsMath.h" #include "shared/Trackball.h" #include "glm/gtx/euler_angles.hpp" class CameraPositionerInterface { public: virtual ~CameraPositionerInterface() = default; virtual glm::mat4 getViewMatrix() const = 0; virtual glm::vec3 getPositio...
#pragma once #include <iostream> void message_callback( GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, GLchar const* message, void const* user_param ) { auto const src_str = [source]() { switch ( source ) { case GL_DEBUG_SOURCE_API: return "API"; case GL_DEBUG_SOURCE_WINDOW_SYSTEM...
#pragma once #if BUILD_WITH_EASY_PROFILER && BUILD_WITH_OPTICK # error Cannot enable both profilers at once. Just pick one. #endif // BUILD_WITH_EASY_PROFILER && BUILD_WITH_OPTICK #if !BUILD_WITH_EASY_PROFILER && !BUILD_WITH_OPTICK # define EASY_FUNCTION(...) # define EASY_BLOCK(...) # define EASY_END_BLOCK # define ...
#pragma once #include <deque> #include <limits> #include "shared/EasyProfilerWrapper.h" #include "shared/vkRenderers/VulkanCanvas.h" class LinearGraph { public: explicit LinearGraph(size_t maxGraphPoints = 256) : maxPoints_(maxGraphPoints) {} void addPoint(float value) { graph_.push_back(value); if (gr...
#if defined(_MSC_VER) # pragma warning(push) # pragma warning(disable:4099) // type name first seen using 'class' now seen using 'struct' # pragma warning(disable:4244) // 'argument': conversion from 'float' to 'int', possible loss of data # pragma warning(disable:4267) // conversion from 'size_t' to 'int', possible...
/* * Copyright (C) 2013-2015 Sergey Kosarevsky (sk@linderdaum.com) * Copyright (C) 2013-2015 Viktor Latypov (vl@linderdaum.com) * Based on Linderdaum Engine http://www.linderdaum.com * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provid...
#if !defined(_CRT_SECURE_NO_WARNINGS) # define _CRT_SECURE_NO_WARNINGS 1 #endif // _CRT_SECURE_NO_WARNINGS #include <malloc.h> #include <string.h> #include <string> #include "Utils.h" void printShaderSource(const char* text) { int line = 1; printf("\n(%3i) ", line); while (text && *text++) { if (*text == ...
#pragma once #if !defined(_CRT_SECURE_NO_WARNINGS) # define _CRT_SECURE_NO_WARNINGS 1 #endif // _CRT_SECURE_NO_WARNINGS #include <malloc.h> #include <string.h> #include <algorithm> #include <string> #include <vector> bool endsWith(const char* s, const char* part); std::string readShaderFile(const char* fileName)...
#include "UtilsMath.h" #include "UtilsCubemap.h" #include <cstdio> #include <glm/glm.hpp> #include <glm/ext.hpp> #define STB_IMAGE_RESIZE_IMPLEMENTATION #include "stb_image_resize2.h" using glm::vec2; using glm::vec3; using glm::vec4; using glm::ivec2; /// From Henry J. Warren's "Hacker's Delight" float radicalI...
#pragma once #include <glm/glm.hpp> #include "shared/Bitmap.h" Bitmap convertEquirectangularMapToVerticalCross(const Bitmap& b); Bitmap convertVerticalCrossToCubeMapFaces(const Bitmap& b); inline Bitmap convertEquirectangularMapToCubeMapFaces(const Bitmap& b) { return convertVerticalCrossToCubeMapFaces(convertE...
#pragma once #include <assert.h> #include <stdio.h> class FramesPerSecondCounter { public: explicit FramesPerSecondCounter(float avgInterval = 0.5f) :avgInterval_(avgInterval) { assert(avgInterval > 0.0f); } bool tick(float deltaSeconds, bool frameRendered = true) { if (frameRendered) numFrames_++; ...
#pragma once #define _USE_MATH_DEFINES #include <cmath> #include <glm/glm.hpp> #include <glm/ext.hpp> #include <vector> using glm::vec3; using glm::vec4; namespace Math { static constexpr float PI = 3.14159265359f; static constexpr float TWOPI = 6.28318530718f; } struct BoundingBox { vec3 min_; vec3 max_; ...
#include "shared/Utils.h" #include "shared/UtilsVulkan.h" #include "shared/Bitmap.h" #include "shared/UtilsCubemap.h" #include "shared/EasyProfilerWrapper.h" #include "Include/ResourceLimits.h" #define VK_NO_PROTOTYPES #define GLFW_INCLUDE_VULKAN #include <GLFW/glfw3.h> #define STB_IMAGE_IMPLEMENTATION #include "stb...
#pragma once #include <array> #include <functional> #include <vector> #define VK_NO_PROTOTYPES #include <volk/volk.h> #include "glslang_c_interface.h" #include "Public/resource_limits_c.h" #define VK_CHECK(value) CHECK(value == VK_SUCCESS, __FILE__, __LINE__); #define VK_CHECK_RET(value) if ( value != VK_SUCCESS ) ...
#pragma once #include <glad/gl.h> #include <memory> class GLFramebuffer { public: GLFramebuffer(int width, int height, GLenum formatColor, GLenum formatDepth); ~GLFramebuffer(); GLFramebuffer(const GLFramebuffer&) = delete; GLFramebuffer(GLFramebuffer&&) = default; GLuint getHandle() const { return handle_; }...
#pragma once #include <glad/gl.h> #include <GLFW/glfw3.h> #include <glm/glm.hpp> #include <glm/ext.hpp> #include "shared/debug.h" using glm::mat4; using glm::vec2; using glm::vec3; using glm::vec4; class GLApp { public: GLApp() { glfwSetErrorCallback( [](int error, const char* description) { fprint...
#include "GLSceneData.h" static uint64_t getTextureHandleBindless(uint64_t idx, const std::vector<GLTexture>& textures) { if (idx == INVALID_TEXTURE) return 0; return textures[idx].getHandleBindless(); } GLSceneData::GLSceneData( const char* meshFile, const char* sceneFile, const char* materialFile) { heade...
#pragma once #include "shared/scene/Scene.h" #include "shared/scene/Material.h" #include "shared/scene/VtxData.h" #include "shared/glFramework/GLShader.h" #include "shared/glFramework/GLTexture.h" class GLSceneData { public: GLSceneData( const char* meshFile, const char* sceneFile, const char* materialFile)...
#include <memory> #include "GLSceneDataLazy.h" #include <stb/stb_image.h> static uint64_t getTextureHandleBindless(uint64_t idx, const std::vector<std::shared_ptr<GLTexture>>& textures) { if (idx == INVALID_TEXTURE) return 0; return textures[idx]->getHandleBindless(); } GLSceneDataLazy::GLSceneDataLazy( const...
#pragma once #include <mutex> #include "shared/scene/Scene.h" #include "shared/scene/Material.h" #include "shared/scene/VtxData.h" #include "shared/glFramework/GLShader.h" #include "shared/glFramework/GLTexture.h" #include <taskflow/taskflow.hpp> class GLSceneDataLazy { public: GLSceneDataLazy( const char* mes...
#include "GLShader.h" #include "shared/Utils.h" #include <glad/gl.h> #include <assert.h> #include <stdio.h> #include <string> GLShader::GLShader(const char* fileName) : GLShader(GLShaderTypeFromFileName(fileName), readShaderFile(fileName).c_str(), fileName) {} GLShader::GLShader(GLenum type, const char* text, con...
#pragma once #include <glad/gl.h> class GLShader { public: explicit GLShader(const char* fileName); GLShader(GLenum type, const char* text, const char* debugFileName = ""); ~GLShader(); GLenum getType() const { return type_; } GLuint getHandle() const { return handle_; } private: GLenum type_; GLuint handl...
#include "shared/glFramework/GLTexture.h" #include "shared/Bitmap.h" #include "shared/UtilsCubemap.h" #include <glad/gl.h> #include <assert.h> #include <stdio.h> #include <string> #include <stb/stb_image.h> #include <gli/gli.hpp> #include <gli/texture2d.hpp> #include <gli/load_ktx.hpp> int getNumMipMapLevels2D(in...
#pragma once #include <glad/gl.h> class GLTexture { public: GLTexture(GLenum type, const char* fileName); GLTexture(GLenum type, const char* fileName, GLenum clamp); GLTexture(GLenum type, int width, int height, GLenum internalFormat); GLTexture(int w, int h, const void* img); ~GLTexture(); GLTexture(const G...
#pragma once #include <array> #include "shared/glFramework/GLShader.h" #include "shared/glFramework/GLTexture.h" #include "shared/scene/VtxData.h" #include <assimp/scene.h> #include <assimp/postprocess.h> #include <assimp/cimport.h> #include <assimp/version.h> #define STB_IMAGE_IMPLEMENTATION #include <stb/stb_imag...
#pragma once #include "shared/glFramework/GLShader.h" #include <imgui/imgui.h> #include <imgui/imgui_internal.h> #include <glm/glm.hpp> #include <glm/ext.hpp> const GLchar* shaderCodeImGuiVertex = R"( #version 460 core layout (location = 0) in vec2 Position; layout (location = 1) in vec2 UV; layout (location ...
#pragma once #include "shared/scene/vec4.h" // Common definitions for Lights and Cameras struct PACKED_STRUCT CameraProperties { gpumat4 projection_ = gpumat4(glm::mat4(1.f)); gpumat4 view_ = gpumat4(glm::mat4(1.f)); gpumat4 model_ = gpumat4(glm::mat4(1.f)); gpuvec4 position_ = gpuvec4(glm::vec4(0.0f...
#include "shared/scene/Material.h" #include <unordered_map> #include "shared/Utils.h" void saveStringList(FILE* f, const std::vector<std::string>& lines) { uint32_t sz = (uint32_t)lines.size(); fwrite(&sz, sizeof(uint32_t), 1, f); for (const auto& s: lines) { sz = (uint32_t)s.length(); fwrite(&sz, sizeof(u...
#pragma once #include <cstdint> #include "shared/scene/vec4.h" #include <string> #include <vector> enum MaterialFlags { sMaterialFlags_CastShadow = 0x1, sMaterialFlags_ReceiveShadow = 0x2, sMaterialFlags_Transparent = 0x4, }; constexpr const uint64_t INVALID_TEXTURE = 0xFFFFFFFF; struct PACKED_STRUCT Materia...
#include "shared/scene/Material.h" #include "shared/scene/MergeUtil.h" #include <map> static uint32_t shiftMeshIndices(MeshData& meshData, const std::vector<uint32_t>& meshesToMerge) { auto minVtxOffset = std::numeric_limits<uint32_t>::max(); for (auto i: meshesToMerge) minVtxOffset = std::min(meshData.meshes_[i]...
#pragma once #include "shared/scene/Scene.h" #include "shared/scene/VtxData.h" void mergeScene(Scene& scene, MeshData& meshData, const std::string& materialName);
#include "shared/scene/Scene.h" #include "shared/Utils.h" #include <algorithm> #include <numeric> void saveStringList(FILE* f, const std::vector<std::string>& lines); void loadStringList(FILE* f, std::vector<std::string>& lines); int addNode(Scene& scene, int parent, int level) { int node = (int)scene.hierarchy_...
#pragma once #include <string> #include <unordered_map> #include <vector> #include <glm/glm.hpp> #include <glm/ext.hpp> using glm::mat4; // we do not define std::vector<Node*> Children - this is already present in the aiNode from assimp constexpr const int MAX_NODE_LEVEL = 16; struct Hierarchy { // parent for...
#pragma once #include <glm/glm.hpp> #include <glm/ext.hpp> #include <string.h> #ifdef __GNUC__ #define PACKED_STRUCT __attribute__((packed,aligned(1))) #else #define PACKED_STRUCT #endif using glm::vec2; using glm::vec4; struct PACKED_STRUCT gpuvec4 { float x, y, z, w; gpuvec4() = default; explicit gpuvec4(floa...
#include "shared/scene/VtxData.h" #include <algorithm> #include <assert.h> #include <stdio.h> MeshFileHeader loadMeshData(const char* meshFile, MeshData& out) { MeshFileHeader header; FILE* f = fopen(meshFile, "rb"); assert(f); // Did you forget to run "Ch5_Tool05_MeshConvert"? if (!f) { printf("Cannot open...
#pragma once #include <assert.h> #include <stdint.h> #include <glm/glm.hpp> #include "shared/Utils.h" #include "shared/UtilsMath.h" constexpr const uint32_t kMaxLODs = 8; constexpr const uint32_t kMaxStreams = 8; // All offsets are relative to the beginning of the data block (excluding headers with Mesh list) stru...
#pragma once #include "shared/vkFramework/Renderer.h" /** VkAccessFlags srcAccess, VkAccessFlags dstAccess, VkImageLayout oldLayout VkImageLayout newLayout // Before next stage (convert from ) ImageBarrier(ctx_, VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, VK_ACCESS_SHADER_READ_BIT, VK_IMAGE_LAYOUT_ATTACHMENT_OPTIMAL, VK_I...
#pragma once #include "shared/vkFramework/VulkanApp.h" /// A collection of renderers acting as one renderer (for Screen-Space effects in Chapter8) struct CompositeRenderer: public Renderer { CompositeRenderer(VulkanRenderContext& c): Renderer(c) {} void fillCommandBuffer(VkCommandBuffer cmdBuffer, size_t currentIm...
#include "shared/vkFramework/CubeRenderer.h" void CubemapRenderer::fillCommandBuffer(VkCommandBuffer commandBuffer, size_t currentImage, VkFramebuffer fb, VkRenderPass rp) { beginRenderPass((rp != VK_NULL_HANDLE) ? rp : renderPass_.handle, (fb != VK_NULL_HANDLE) ? fb : framebuffer_, commandBuffer, currentImage); vk...
#pragma once #include "shared/vkFramework/Renderer.h" struct CubemapRenderer: public Renderer { CubemapRenderer(VulkanRenderContext& ctx, VulkanTexture texture, const std::vector<VulkanTexture>& outputs = std::vector<VulkanTexture> {}, RenderPass screenRenderPass = RenderPass()); void fillCommandBuffer(VkCom...
#include "shared/vkFramework/GuiRenderer.h" #include "shared/scene/Scene.h" static constexpr uint32_t ImGuiVtxBufferSize = 512 * 1024 * sizeof(ImDrawVert); static constexpr uint32_t ImGuiIdxBufferSize = 512 * 1024 * sizeof(uint32_t); static void addImGuiItem(uint32_t width, uint32_t height, VkCommandBuffer commandBuf...
#pragma once #include "shared/vkFramework/Renderer.h" struct Scene; struct GuiRenderer: public Renderer { GuiRenderer(VulkanRenderContext& ctx, const std::vector<VulkanTexture>& textures = std::vector<VulkanTexture> {}, RenderPass renderPass = RenderPass()); virtual ~GuiRenderer(); void fillCommandBuffer(VkComma...
#include "shared/vkFramework/InfinitePlaneRenderer.h" void InfinitePlaneRenderer::fillCommandBuffer(VkCommandBuffer commandBuffer, size_t currentImage, VkFramebuffer fb, VkRenderPass rp) { beginRenderPass((rp != VK_NULL_HANDLE) ? rp : renderPass_.handle, (fb != VK_NULL_HANDLE) ? fb : framebuffer_, commandBuffer, curr...
#pragma once #include "shared/vkFramework/Renderer.h" // A port of GL infinite plane struct InfinitePlaneRenderer: public Renderer { InfinitePlaneRenderer(VulkanRenderContext& ctx, const std::vector<VulkanTexture>& outputs = std::vector<VulkanTexture> {}, RenderPass screenRenderPass = RenderPass()); void fillC...
#include "shared/vkFramework/LineCanvas.h" LineCanvas::LineCanvas(VulkanRenderContext& ctx, bool useDepth, const std::vector<VulkanTexture>& outputs, VkFramebuffer framebuffer, RenderPass screenRenderPass): Renderer(ctx) { framebuffer_ = framebuffer; const PipelineInfo pInfo = initRenderPass( ...
#pragma once #include "shared/vkFramework/Renderer.h" struct LineCanvas: public Renderer { explicit LineCanvas(VulkanRenderContext& ctx, bool useDepth = true, const std::vector<VulkanTexture>& outputs = std::vector<VulkanTexture> {}, VkFramebuffer framebuffer = VK_NULL_HANDLE, RenderPass screen...
#include "shared/vkFramework/MultiRenderer.h" #include <stb/stb_image.h> uint8_t* genDefaultCheckerboardImage(int* width, int* height); VKSceneData::VKSceneData(VulkanRenderContext& ctx, const char* meshFile, const char* sceneFile, const char* materialFile, VulkanTexture envMap, VulkanTexture irradianceMap, bo...
#pragma once #include "shared/vkFramework/Renderer.h" #include "shared/scene/Scene.h" #include "shared/scene/Material.h" #include "shared/scene/VtxData.h" #include <taskflow/taskflow.hpp> // Container of mesh data, material data and scene nodes with transformations struct VKSceneData { VKSceneData(VulkanRenderConte...
#include "shared/vkFramework/QuadRenderer.h" static constexpr int MAX_QUADS = 256; void QuadRenderer::quad(float x1, float y1, float x2, float y2, int texIdx) { VertexData v1 { { x1, y1, 0 }, { 0, 0 }, texIdx }; VertexData v2 { { x2, y1, 0 }, { 1, 0 }, texIdx }; VertexData v3 { { x2, y2, 0 }, { 1, 1 }, texIdx }; ...
#pragma once #include "shared/vkFramework/Renderer.h" // A companion for LineCanvas to render texture quadrangles struct QuadRenderer: public Renderer { QuadRenderer(VulkanRenderContext& ctx, const std::vector<VulkanTexture>& textures, const std::vector<VulkanTexture>& outputs = {}, RenderPass screenRenderPass =...
#pragma once #include "VulkanApp.h" struct Renderer { Renderer(VulkanRenderContext& c) : processingWidth(c.vkDev.framebufferWidth) , processingHeight(c.vkDev.framebufferHeight) , ctx_(c) {} virtual void fillCommandBuffer(VkCommandBuffer cmdBuffer, size_t currentImage, VkFramebuffer fb = VK_NULL_HANDLE, VkRende...
#include "VulkanApp.h" #include "shared/vkFramework/Renderer.h" Resolution detectResolution(int width, int height) { GLFWmonitor* monitor = glfwGetPrimaryMonitor(); const int code = glfwGetError(nullptr); if (code != 0) { printf("Monitor: %p; error = %x / %d\n", monitor, code, code); exit(255); } const GL...
#pragma once #define VK_NO_PROTOTYPES #define GLFW_INCLUDE_VULKAN #include <GLFW/glfw3.h> #include <cstdio> #include <cstdlib> #include <cstring> #include <chrono> #include <deque> #include <functional> #include <memory> #include <limits> #include <imgui/imgui.h> #include "shared/Camera.h" #include "shared/Utils.h" ...
#include "shared/vkFramework/VulkanResources.h" #include <assimp/scene.h> #include <assimp/postprocess.h> #include <assimp/cimport.h> #include <assimp/version.h> #include <imgui/imgui.h> #include <gli/gli.hpp> #include <gli/texture2d.hpp> #include <gli/load_ktx.hpp> #include <algorithm> glslang_stage_t glslangShad...
#pragma once #include "shared/UtilsVulkan.h" #include <volk/volk.h> #include <cstring> #include <memory> #include <map> #include <utility> #include <string> /** For more or less abstract descriptor set setup we need to describe individual items ("bindings"). These are buffers, textures (samplers, but we call them "...
#include "shared/vkFramework/VulkanShaderProcessor.h" #include "shared/vkFramework/VulkanResources.h" VulkanShaderProcessor::VulkanShaderProcessor(VulkanRenderContext& ctx, const PipelineInfo& pInfo, const DescriptorSetInfo& dsInfo, const std::vector<const char*>& shaders, const std::vector<VulkanTexture>& outputs...
#pragma once #include "shared/vkFramework/Renderer.h" /* @brief Shader (post)processor for fullscreen effects Multiple input textures, single output [color + depth]. Possibly, can be extented to multiple outputs (allocate appropriate framebuffer) */ struct VulkanShaderProcessor: public Renderer { VulkanShade...
#pragma once #include "shared/vkFramework/effects/LuminanceCalculator.h" #include "shared/vkFramework/Barriers.h" struct HDRUniformBuffer { float exposure; float maxWhite; float bloomStrength; float adaptationSpeed; }; /** Apply bloom to input buffer */ struct HDRProcessor: public CompositeRenderer { HDRProcess...
#pragma once #include "shared/vkFramework/CompositeRenderer.h" #include "shared/vkFramework/VulkanShaderProcessor.h" #include "shared/vkFramework/Barriers.h" const VkFormat LuminosityFormat = VK_FORMAT_R16G16B16A16_SFLOAT; const int LuminosityWidth = 64; const int LuminosityHeight = 64; struct LuminanceCalculator: ...
#pragma once #include "shared/vkFramework/CompositeRenderer.h" #include "shared/vkFramework/VulkanShaderProcessor.h" #include "shared/vkFramework/Barriers.h" const int SSAOWidth = 0; // smaller SSAO buffer can be used 512 const int SSAOHeight = 0; // 512; struct SSAOProcessor: public CompositeRenderer { SSAOProcess...
#include "shared/vkRenderers/VulkanCanvas.h" #include "shared/EasyProfilerWrapper.h" VulkanCanvas::VulkanCanvas(VulkanRenderDevice& vkDev, VulkanImage depth) : RendererBase(vkDev, depth) { const size_t imgCount = vkDev.swapchainImages.size(); storageBuffer_.resize(imgCount); storageBufferMemory_.resize(imgCount); ...
#pragma once #include "shared/vkRenderers/VulkanRendererBase.h" #include <glm/glm.hpp> #include <glm/ext.hpp> using glm::mat4; using glm::vec3; using glm::vec4; class VulkanCanvas: public RendererBase { public: explicit VulkanCanvas(VulkanRenderDevice& vkDev, VulkanImage depth); virtual ~VulkanCanvas(); virtual ...
#include "shared/Utils.h" #include "shared/UtilsMath.h" #include "shared/vkRenderers/VulkanClear.h" #include "shared/EasyProfilerWrapper.h" VulkanClear::VulkanClear(VulkanRenderDevice& vkDev, VulkanImage depthTexture) : RendererBase(vkDev, depthTexture) , shouldClearDepth(depthTexture.image != VK_NULL_HANDLE) { if (!...
#pragma once #include "shared/vkRenderers/VulkanRendererBase.h" class VulkanClear: public RendererBase { public: VulkanClear(VulkanRenderDevice& vkDev, VulkanImage depthTexture); virtual void fillCommandBuffer(VkCommandBuffer commandBuffer, size_t currentImage) override; private: bool shouldClearDepth; };
#include "shared/vkRenderers/VulkanComputeBase.h" ComputeBase::ComputeBase(VulkanRenderDevice& vkDev, const char* shaderName, uint32_t inputSize, uint32_t outputSize): vkDev(vkDev) { createSharedBuffer(vkDev, inputSize, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_...
#pragma once #include "shared/Utils.h" #include "shared/UtilsVulkan.h" struct ComputeBase { ComputeBase(VulkanRenderDevice& vkDev, const char* shaderName, uint32_t inputSize, uint32_t outputSize); virtual ~ComputeBase(); inline void uploadInput(uint32_t offset, void* inData, uint32_t byteCount) { uploadBufferD...
#include "shared/vkRenderers/VulkanComputedImage.h" ComputedImage::ComputedImage(VulkanRenderDevice& vkDev, const char* shaderName, uint32_t textureWidth, uint32_t textureHeight, bool supportDownload) : ComputedItem(vkDev, sizeof(uint32_t)) , computedWidth(textureWidth) , computedHeight(textureHeight) , canDownloa...
#pragma once #include "shared/Utils.h" #include "shared/vkRenderers/VulkanComputedItem.h" struct ComputedImage: public ComputedItem { ComputedImage(VulkanRenderDevice& vkDev, const char* shaderName, uint32_t textureWidth, uint32_t textureHeight, bool supportDownload = false); virtual ~ComputedImage() {} void down...
#include "shared/vkRenderers/VulkanComputedItem.h" ComputedItem::ComputedItem(VulkanRenderDevice& vkDev, uint32_t uniformBufferSize) : vkDev(vkDev) { uniformBuffer.size = uniformBufferSize; VkFenceCreateInfo fenceCreateInfo = { .sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO, .pNext = nullptr, .flags = VK_FENCE...
#pragma once #include "shared/Utils.h" #include "shared/UtilsVulkan.h" struct ComputedItem { ComputedItem(VulkanRenderDevice& vkDev, uint32_t uniformBufferSize); virtual ~ComputedItem(); void fillComputeCommandBuffer(void* pushConstant = nullptr, uint32_t pushConstantSize = 0, uint32_t xsize = 1, uint32_t ysize =...
#include "shared/vkRenderers/VulkanComputedVB.h" ComputedVertexBuffer::ComputedVertexBuffer(VulkanRenderDevice& vkDev, const char* shaderName, uint32_t indexBufferSize, uint32_t uniformBufferSize, uint32_t vertexSize, uint32_t vertexCount, bool supportDownload) : ComputedItem(vkDev, uniformBufferSize) , compute...
#pragma once #include "shared/Utils.h" #include "shared/vkRenderers/VulkanComputedItem.h" struct ComputedVertexBuffer: public ComputedItem { ComputedVertexBuffer(VulkanRenderDevice& vkDev, const char* shaderName, uint32_t indexBufferSize, uint32_t uniformBufferSize, uint32_t vertexSize, uint32_t vertexCount,...
#include "shared/Utils.h" #include "shared/UtilsMath.h" #include "shared/UtilsVulkan.h" #include "shared/vkRenderers/VulkanCube.h" #include "shared/EasyProfilerWrapper.h" bool CubeRenderer::createDescriptorSet(VulkanRenderDevice& vkDev) { const std::array<VkDescriptorSetLayoutBinding, 2> bindings = { descriptorSetL...
#pragma once #include "shared/vkRenderers/VulkanRendererBase.h" #include <glm/glm.hpp> #include <glm/ext.hpp> using glm::mat4; class CubeRenderer: public RendererBase { public: CubeRenderer(VulkanRenderDevice& vkDev, VulkanImage inDepthTexture, const char* textureFile); virtual ~CubeRenderer(); virtual void fill...
#include "shared/Utils.h" #include "shared/UtilsMath.h" #include "shared/vkRenderers/VulkanFinish.h" #include "shared/EasyProfilerWrapper.h" VulkanFinish::VulkanFinish(VulkanRenderDevice& vkDev, VulkanImage depthTexture) : RendererBase(vkDev, depthTexture) { if (!createColorAndDepthRenderPass( vkDev, (depthTexture....
#pragma once #include "shared/vkRenderers/VulkanRendererBase.h" class VulkanFinish: public RendererBase { public: VulkanFinish(VulkanRenderDevice& vkDev, VulkanImage depthTexture); virtual void fillCommandBuffer(VkCommandBuffer commandBuffer, size_t currentImage) override; };
#include <imgui/imgui.h> #include "shared/vkRenderers/VulkanImGui.h" #include "shared/EasyProfilerWrapper.h" #include <glm/glm.hpp> #include <glm/ext.hpp> using glm::mat4; using glm::vec2; using glm::vec3; using glm::vec4; constexpr uint32_t ImGuiVtxBufferSize = 512 * 1024 * sizeof(ImDrawVert); constexpr uint32_t Im...
#pragma once #include "shared/vkRenderers/VulkanRendererBase.h" class ImGuiRenderer: public RendererBase { public: explicit ImGuiRenderer(VulkanRenderDevice& vkDev); explicit ImGuiRenderer(VulkanRenderDevice& vkDev, const std::vector<VulkanTexture>& textures); virtual ~ImGuiRenderer(); virtual void fillCommandBu...