Broke everything for some reason
This commit is contained in:
Vendored
+1
-1
Submodule external/vcpkg updated: 0bf1354d67...f9a99aa79c
@@ -27,7 +27,7 @@ ParameterBlock<LightCullingData> pLightCullingData;
|
|||||||
|
|
||||||
static const float4x4 biasMat = float4x4(
|
static const float4x4 biasMat = float4x4(
|
||||||
0.5, 0.0, 0.0, 0.5,
|
0.5, 0.0, 0.0, 0.5,
|
||||||
0.0, -0.5, 0.0, 0.5,
|
0.0, 0.5, 0.0, 0.5,
|
||||||
0.0, 0.0, 1.0, 0.0,
|
0.0, 0.0, 1.0, 0.0,
|
||||||
0.0, 0.0, 0.0, 1.0);
|
0.0, 0.0, 0.0, 1.0);
|
||||||
|
|
||||||
@@ -51,8 +51,8 @@ float4 fragmentMain(in FragmentParameter params) : SV_Target
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
float4 lightSpacePos = mul(pShadowMapping.lightSpaceMatrices[cascadeIndex][i], float4(params.position_WS, 1));
|
float4 lightSpacePos = mul(pShadowMapping.lightSpaceMatrices[cascadeIndex][i], float4(params.position_WS, 1));
|
||||||
lightSpacePos = mul(biasMat, lightSpacePos);
|
//lightSpacePos = mul(biasMat, lightSpacePos);
|
||||||
float4 shadowCoord = lightSpacePos / lightSpacePos.w;
|
float4 shadowCoord = clipToScreen(lightSpacePos);
|
||||||
int3 texDim;
|
int3 texDim;
|
||||||
pShadowMapping.shadowMaps[cascadeIndex].GetDimensions(texDim.x, texDim.y, texDim.z);
|
pShadowMapping.shadowMaps[cascadeIndex].GetDimensions(texDim.x, texDim.y, texDim.z);
|
||||||
float scale = 1.5f;
|
float scale = 1.5f;
|
||||||
|
|||||||
+2
-4
@@ -12,11 +12,9 @@
|
|||||||
#endif
|
#endif
|
||||||
#include "Graphics/StaticMeshVertexData.h"
|
#include "Graphics/StaticMeshVertexData.h"
|
||||||
#include "Graphics/Vulkan/Graphics.h"
|
#include "Graphics/Vulkan/Graphics.h"
|
||||||
#include "Window/InspectorView.h"
|
|
||||||
#include "Window/PlayView.h"
|
#include "Window/PlayView.h"
|
||||||
#include "Window/WindowManager.h"
|
#include "Window/WindowManager.h"
|
||||||
#include <fmt/core.h>
|
#include <fmt/core.h>
|
||||||
#include <random>
|
|
||||||
|
|
||||||
using namespace Seele;
|
using namespace Seele;
|
||||||
using namespace Seele::Editor;
|
using namespace Seele::Editor;
|
||||||
@@ -26,8 +24,8 @@ static Gfx::OGraphics graphics;
|
|||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
std::string gameName = "MeshShadingDemo";
|
std::string gameName = "MeshShadingDemo";
|
||||||
std::filesystem::path outputPath = fmt::format("../../../../{0}Game/", gameName);
|
std::filesystem::path outputPath = fmt::format("/home/dynamitos/{0}Game/", gameName);
|
||||||
std::filesystem::path sourcePath = fmt::format("../../../../{0}/", gameName);
|
std::filesystem::path sourcePath = fmt::format("/home/dynamitos/{0}/", gameName);
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
std::string libraryEnding = "dll";
|
std::string libraryEnding = "dll";
|
||||||
#elif __APPLE__
|
#elif __APPLE__
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ namespace Seele {
|
|||||||
namespace Component {
|
namespace Component {
|
||||||
struct Camera {
|
struct Camera {
|
||||||
float nearPlane = 0.1f;
|
float nearPlane = 0.1f;
|
||||||
float farPlane = 1000.0f;
|
float farPlane = 10000.0f;
|
||||||
bool mainCamera = false;
|
bool mainCamera = false;
|
||||||
};
|
};
|
||||||
} // namespace Component
|
} // namespace Component
|
||||||
|
|||||||
@@ -368,10 +368,6 @@ void BasePass::render() {
|
|||||||
{
|
{
|
||||||
.cullMode = Gfx::SE_CULL_MODE_BACK_BIT,
|
.cullMode = Gfx::SE_CULL_MODE_BACK_BIT,
|
||||||
},
|
},
|
||||||
.depthStencilState =
|
|
||||||
{
|
|
||||||
.depthCompareOp = Gfx::SE_COMPARE_OP_GREATER_OR_EQUAL,
|
|
||||||
},
|
|
||||||
.colorBlend =
|
.colorBlend =
|
||||||
{
|
{
|
||||||
.attachmentCount = 1,
|
.attachmentCount = 1,
|
||||||
@@ -631,7 +627,17 @@ void BasePass::createRenderPass() {
|
|||||||
});
|
});
|
||||||
textureLayout->create();
|
textureLayout->create();
|
||||||
|
|
||||||
skyboxSampler = graphics->createSampler({});
|
skyboxSampler = graphics->createSampler({
|
||||||
|
.magFilter = Gfx::SE_FILTER_LINEAR,
|
||||||
|
.minFilter = Gfx::SE_FILTER_LINEAR,
|
||||||
|
.mipmapMode = Gfx::SE_SAMPLER_MIPMAP_MODE_LINEAR,
|
||||||
|
.addressModeU = Gfx::SE_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
|
||||||
|
.addressModeV = Gfx::SE_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
|
||||||
|
.addressModeW = Gfx::SE_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
|
||||||
|
.maxAnisotropy = 1.0f,
|
||||||
|
.minLod = 0,
|
||||||
|
.maxLod = std::numeric_limits<float>::max(),
|
||||||
|
});
|
||||||
|
|
||||||
skyboxData.transformMatrix = Matrix4(1);
|
skyboxData.transformMatrix = Matrix4(1);
|
||||||
skyboxData.fogColor = skybox.fogColor;
|
skyboxData.fogColor = skybox.fogColor;
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ ShadowPass::~ShadowPass() {}
|
|||||||
|
|
||||||
void ShadowPass::beginFrame(const Component::Camera& camera, const Component::Transform& transform) {
|
void ShadowPass::beginFrame(const Component::Camera& camera, const Component::Transform& transform) {
|
||||||
float cascadeSplits[NUM_CASCADES];
|
float cascadeSplits[NUM_CASCADES];
|
||||||
|
float splitDepths[NUM_CASCADES];
|
||||||
|
|
||||||
float nearClip = camera.nearPlane;
|
float nearClip = camera.nearPlane;
|
||||||
float farClip = camera.farPlane;
|
float farClip = camera.farPlane;
|
||||||
@@ -63,49 +64,57 @@ void ShadowPass::beginFrame(const Component::Camera& camera, const Component::Tr
|
|||||||
float uniform = minZ + range * p;
|
float uniform = minZ + range * p;
|
||||||
float d = cascadeSplitLambda * (log - uniform) + uniform;
|
float d = cascadeSplitLambda * (log - uniform) + uniform;
|
||||||
cascadeSplits[i] = (d - nearClip) / clipRange;
|
cascadeSplits[i] = (d - nearClip) / clipRange;
|
||||||
|
splitDepths[i] = (camera.nearPlane + cascadeSplits[i] * clipRange) * -1.0f;
|
||||||
cascades[i].viewParams.clear();
|
cascades[i].viewParams.clear();
|
||||||
}
|
}
|
||||||
cascadeSplitsBuffer->updateContents(0, sizeof(float) * NUM_CASCADES, cascadeSplits);
|
cascadeSplitsBuffer->updateContents(0, sizeof(float) * NUM_CASCADES, splitDepths);
|
||||||
|
|
||||||
// call this to update view params member, ignore descriptor set
|
// call this to update view params member, ignore descriptor set
|
||||||
updateViewParameters(camera, transform);
|
updateViewParameters(camera, transform);
|
||||||
Array<Vector> frustumCorners = {
|
Matrix4 invCam = viewParams.inverseViewProjectionMatrix;
|
||||||
Vector(-1.0f, 1.0f, 0.0f), Vector(1.0f, 1.0f, 0.0f), Vector(1.0f, -1.0f, 0.0f), Vector(-1.0f, -1.0f, 0.0f),
|
|
||||||
Vector(-1.0f, 1.0f, 1.0f), Vector(1.0f, 1.0f, 1.0f), Vector(1.0f, -1.0f, 1.0f), Vector(-1.0f, -1.0f, 1.0f),
|
|
||||||
};
|
|
||||||
|
|
||||||
for (auto& c : frustumCorners) {
|
|
||||||
Vector4 invCorner = viewParams.inverseViewProjectionMatrix * Vector4(c, 1);
|
|
||||||
c = invCorner / invCorner.w;
|
|
||||||
}
|
|
||||||
for (uint32 s = 0; s < scene->getLightEnvironment()->getNumDirectionalLights(); ++s) {
|
for (uint32 s = 0; s < scene->getLightEnvironment()->getNumDirectionalLights(); ++s) {
|
||||||
float lastSplitDist = 0.0;
|
float lastSplitDist = 0.0;
|
||||||
for (uint32 i = 0; i < NUM_CASCADES; ++i) {
|
for (uint32 i = 0; i < NUM_CASCADES; ++i) {
|
||||||
float splitDist = cascadeSplits[i];
|
float splitDist = cascadeSplits[i];
|
||||||
|
|
||||||
Array<Vector> cascadeCorners(8);
|
Array<Vector> frustumCorners = {
|
||||||
|
Vector(-1.0f, 1.0f, 1.0f),
|
||||||
|
Vector(1.0f, 1.0f, 1.0f),
|
||||||
|
Vector(1.0f, -1.0f, 1.0f),
|
||||||
|
Vector(-1.0f, -1.0f, 1.0f),
|
||||||
|
Vector(-1.0f, 1.0f, 0.0f),
|
||||||
|
Vector(1.0f, 1.0f, 0.0f),
|
||||||
|
Vector(1.0f, -1.0f, 0.0f),
|
||||||
|
Vector(-1.0f, -1.0f, 0.0f),
|
||||||
|
};
|
||||||
|
|
||||||
|
for (auto& c : frustumCorners) {
|
||||||
|
Vector4 invCorner = invCam * Vector4(c, 1);
|
||||||
|
c = invCorner / invCorner.w;
|
||||||
|
}
|
||||||
for (uint32 j = 0; j < 4; j++) {
|
for (uint32 j = 0; j < 4; j++) {
|
||||||
Vector dist = frustumCorners[j + 4] - frustumCorners[j];
|
Vector dist = frustumCorners[j + 4] - frustumCorners[j];
|
||||||
cascadeCorners[j + 4] = frustumCorners[j] + (dist * splitDist);
|
frustumCorners[j + 4] = frustumCorners[j] + (dist * splitDist);
|
||||||
cascadeCorners[j] = frustumCorners[j] + (dist * lastSplitDist);
|
frustumCorners[j] = frustumCorners[j] + (dist * lastSplitDist);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector frustumCenter = Vector(0);
|
Vector frustumCenter = Vector(0);
|
||||||
for (uint32 j = 0; j < 8; j++) {
|
for (uint32 j = 0; j < 8; j++) {
|
||||||
frustumCenter += cascadeCorners[j];
|
frustumCenter += frustumCorners[j];
|
||||||
}
|
}
|
||||||
frustumCenter /= 8.0f;
|
frustumCenter /= 8.0f;
|
||||||
|
|
||||||
float radius = 0.0f;
|
float radius = 0.0f;
|
||||||
for (uint j = 0; j < 8; j++) {
|
for (uint j = 0; j < 8; j++) {
|
||||||
float distance = glm::length(cascadeCorners[j] - frustumCenter);
|
float distance = glm::length(frustumCorners[j] - frustumCenter);
|
||||||
radius = glm::max(radius, distance);
|
radius = glm::max(radius, distance);
|
||||||
}
|
}
|
||||||
radius = std::ceil(radius * 16.0f) / 16.0f;
|
radius = std::ceil(radius * 16.0f) / 16.0f;
|
||||||
|
|
||||||
Vector maxExtents = Vector(radius);
|
Vector maxExtents = Vector(radius);
|
||||||
Vector minExtents = -maxExtents;
|
Vector minExtents = -maxExtents;
|
||||||
Vector lightDir = glm::normalize(scene->getLightEnvironment()->getDirectionalLight(s).direction);
|
|
||||||
|
Vector lightDir = glm::normalize(-scene->getLightEnvironment()->getDirectionalLight(s).direction);
|
||||||
Vector cameraPos = frustumCenter - lightDir * -minExtents.z;
|
Vector cameraPos = frustumCenter - lightDir * -minExtents.z;
|
||||||
Matrix4 viewMatrix = glm::lookAt(cameraPos, frustumCenter, Vector(0, 1, 0));
|
Matrix4 viewMatrix = glm::lookAt(cameraPos, frustumCenter, Vector(0, 1, 0));
|
||||||
Matrix4 projectionMatrix =
|
Matrix4 projectionMatrix =
|
||||||
|
|||||||
@@ -568,7 +568,6 @@ void VertexData::updateBuffers() {
|
|||||||
.size = verticesAllocated * sizeof(Vector),
|
.size = verticesAllocated * sizeof(Vector),
|
||||||
.data = (uint8*)positions.data(),
|
.data = (uint8*)positions.data(),
|
||||||
},
|
},
|
||||||
.usage = Gfx::SE_BUFFER_USAGE_ACCELERATION_STRUCTURE_BUILD_INPUT_READ_ONLY_BIT_KHR,
|
|
||||||
.name = "Positions",
|
.name = "Positions",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -483,7 +483,9 @@ IndexBuffer::IndexBuffer(PGraphics graphics, const IndexBufferCreateInfo& create
|
|||||||
: Gfx::IndexBuffer(graphics->getFamilyMapping(), createInfo),
|
: Gfx::IndexBuffer(graphics->getFamilyMapping(), createInfo),
|
||||||
Vulkan::Buffer(graphics, createInfo.sourceData.size,
|
Vulkan::Buffer(graphics, createInfo.sourceData.size,
|
||||||
VK_BUFFER_USAGE_INDEX_BUFFER_BIT | VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT |
|
VK_BUFFER_USAGE_INDEX_BUFFER_BIT | VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT |
|
||||||
VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_ACCELERATION_STRUCTURE_BUILD_INPUT_READ_ONLY_BIT_KHR,
|
VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | (graphics->supportRayTracing()
|
||||||
|
? VK_BUFFER_USAGE_ACCELERATION_STRUCTURE_BUILD_INPUT_READ_ONLY_BIT_KHR
|
||||||
|
: 0),
|
||||||
createInfo.sourceData.owner, false, createInfo.name) {
|
createInfo.sourceData.owner, false, createInfo.name) {
|
||||||
getAlloc()->updateContents(createInfo.sourceData.offset, createInfo.sourceData.size, createInfo.sourceData.data);
|
getAlloc()->updateContents(createInfo.sourceData.offset, createInfo.sourceData.size, createInfo.sourceData.data);
|
||||||
// getAlloc()->pipelineBarrier(VK_ACCESS_TRANSFER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT, Gfx::SE_ACCESS_INDEX_READ_BIT,
|
// getAlloc()->pipelineBarrier(VK_ACCESS_TRANSFER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT, Gfx::SE_ACCESS_INDEX_READ_BIT,
|
||||||
|
|||||||
@@ -819,7 +819,7 @@ void Graphics::pickPhysicalDevice() {
|
|||||||
shaderFloatControls = true;
|
shaderFloatControls = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rayTracingEnabled = rayTracingPipelineSupport && accelerationStructureSupport && hostOperationsSupport && deviceAddressSupport &&
|
rayTracingEnabled = false && rayTracingPipelineSupport && accelerationStructureSupport && hostOperationsSupport && deviceAddressSupport &&
|
||||||
descriptorIndexingSupport && spirv14Support && shaderFloatControls;
|
descriptorIndexingSupport && spirv14Support && shaderFloatControls;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ static Matrix4 perspectiveProjection(float fov, float aspect, float nearPlane, f
|
|||||||
{
|
{
|
||||||
0.0f,
|
0.0f,
|
||||||
0.0f,
|
0.0f,
|
||||||
0.5f * (farPlane + nearPlane) / (nearPlane - farPlane),
|
nearPlane / (nearPlane - farPlane),
|
||||||
-1.0f,
|
-1.0f,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -54,13 +54,13 @@ static Matrix4 orthographicProjection(float left, float right, float bottom, flo
|
|||||||
{
|
{
|
||||||
0.0f,
|
0.0f,
|
||||||
0.0f,
|
0.0f,
|
||||||
-2.0f / (farPlane - nearPlane),
|
-2.0f / (nearPlane - farPlane),
|
||||||
0.0f,
|
0.0f,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
-(right + left) / (right - left),
|
-(right + left) / (right - left),
|
||||||
-(top + bottom) / (top - bottom),
|
-(top + bottom) / (top - bottom),
|
||||||
-(farPlane + nearPlane) / (farPlane - nearPlane),
|
-(nearPlane + farPlane) / (nearPlane - farPlane),
|
||||||
1.0f,
|
1.0f,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
#define GLM_FORCE_DEPTH_ZERO_TO_ONE
|
||||||
|
#define GLM_FORCE_LEFT_HANDED
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#pragma warning(push)
|
#pragma warning(push)
|
||||||
#pragma warning(disable : 4201)
|
#pragma warning(disable : 4201)
|
||||||
|
|||||||
Reference in New Issue
Block a user