Broke everything for some reason

This commit is contained in:
2025-08-23 18:09:01 +02:00
parent 757b75aaf3
commit ef9cb9c812
11 changed files with 52 additions and 36 deletions
+1 -1
+3 -3
View File
@@ -27,7 +27,7 @@ ParameterBlock<LightCullingData> pLightCullingData;
static const float4x4 biasMat = float4x4(
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, 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));
lightSpacePos = mul(biasMat, lightSpacePos);
float4 shadowCoord = lightSpacePos / lightSpacePos.w;
//lightSpacePos = mul(biasMat, lightSpacePos);
float4 shadowCoord = clipToScreen(lightSpacePos);
int3 texDim;
pShadowMapping.shadowMaps[cascadeIndex].GetDimensions(texDim.x, texDim.y, texDim.z);
float scale = 1.5f;
+2 -4
View File
@@ -12,11 +12,9 @@
#endif
#include "Graphics/StaticMeshVertexData.h"
#include "Graphics/Vulkan/Graphics.h"
#include "Window/InspectorView.h"
#include "Window/PlayView.h"
#include "Window/WindowManager.h"
#include <fmt/core.h>
#include <random>
using namespace Seele;
using namespace Seele::Editor;
@@ -26,8 +24,8 @@ static Gfx::OGraphics graphics;
int main() {
std::string gameName = "MeshShadingDemo";
std::filesystem::path outputPath = fmt::format("../../../../{0}Game/", gameName);
std::filesystem::path sourcePath = fmt::format("../../../../{0}/", gameName);
std::filesystem::path outputPath = fmt::format("/home/dynamitos/{0}Game/", gameName);
std::filesystem::path sourcePath = fmt::format("/home/dynamitos/{0}/", gameName);
#ifdef WIN32
std::string libraryEnding = "dll";
#elif __APPLE__
+1 -1
View File
@@ -7,7 +7,7 @@ namespace Seele {
namespace Component {
struct Camera {
float nearPlane = 0.1f;
float farPlane = 1000.0f;
float farPlane = 10000.0f;
bool mainCamera = false;
};
} // namespace Component
+11 -5
View File
@@ -368,10 +368,6 @@ void BasePass::render() {
{
.cullMode = Gfx::SE_CULL_MODE_BACK_BIT,
},
.depthStencilState =
{
.depthCompareOp = Gfx::SE_COMPARE_OP_GREATER_OR_EQUAL,
},
.colorBlend =
{
.attachmentCount = 1,
@@ -631,7 +627,17 @@ void BasePass::createRenderPass() {
});
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.fogColor = skybox.fogColor;
+25 -16
View File
@@ -46,6 +46,7 @@ ShadowPass::~ShadowPass() {}
void ShadowPass::beginFrame(const Component::Camera& camera, const Component::Transform& transform) {
float cascadeSplits[NUM_CASCADES];
float splitDepths[NUM_CASCADES];
float nearClip = camera.nearPlane;
float farClip = camera.farPlane;
@@ -63,49 +64,57 @@ void ShadowPass::beginFrame(const Component::Camera& camera, const Component::Tr
float uniform = minZ + range * p;
float d = cascadeSplitLambda * (log - uniform) + uniform;
cascadeSplits[i] = (d - nearClip) / clipRange;
splitDepths[i] = (camera.nearPlane + cascadeSplits[i] * clipRange) * -1.0f;
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
updateViewParameters(camera, transform);
Array<Vector> frustumCorners = {
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;
}
Matrix4 invCam = viewParams.inverseViewProjectionMatrix;
for (uint32 s = 0; s < scene->getLightEnvironment()->getNumDirectionalLights(); ++s) {
float lastSplitDist = 0.0;
for (uint32 i = 0; i < NUM_CASCADES; ++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++) {
Vector dist = frustumCorners[j + 4] - frustumCorners[j];
cascadeCorners[j + 4] = frustumCorners[j] + (dist * splitDist);
cascadeCorners[j] = frustumCorners[j] + (dist * lastSplitDist);
frustumCorners[j + 4] = frustumCorners[j] + (dist * splitDist);
frustumCorners[j] = frustumCorners[j] + (dist * lastSplitDist);
}
Vector frustumCenter = Vector(0);
for (uint32 j = 0; j < 8; j++) {
frustumCenter += cascadeCorners[j];
frustumCenter += frustumCorners[j];
}
frustumCenter /= 8.0f;
float radius = 0.0f;
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 = std::ceil(radius * 16.0f) / 16.0f;
Vector maxExtents = Vector(radius);
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;
Matrix4 viewMatrix = glm::lookAt(cameraPos, frustumCenter, Vector(0, 1, 0));
Matrix4 projectionMatrix =
-1
View File
@@ -568,7 +568,6 @@ void VertexData::updateBuffers() {
.size = verticesAllocated * sizeof(Vector),
.data = (uint8*)positions.data(),
},
.usage = Gfx::SE_BUFFER_USAGE_ACCELERATION_STRUCTURE_BUILD_INPUT_READ_ONLY_BIT_KHR,
.name = "Positions",
});
}
+3 -1
View File
@@ -483,7 +483,9 @@ IndexBuffer::IndexBuffer(PGraphics graphics, const IndexBufferCreateInfo& create
: Gfx::IndexBuffer(graphics->getFamilyMapping(), createInfo),
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_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) {
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,
+1 -1
View File
@@ -819,7 +819,7 @@ void Graphics::pickPhysicalDevice() {
shaderFloatControls = true;
}
}
rayTracingEnabled = rayTracingPipelineSupport && accelerationStructureSupport && hostOperationsSupport && deviceAddressSupport &&
rayTracingEnabled = false && rayTracingPipelineSupport && accelerationStructureSupport && hostOperationsSupport && deviceAddressSupport &&
descriptorIndexingSupport && spirv14Support && shaderFloatControls;
}
+3 -3
View File
@@ -26,7 +26,7 @@ static Matrix4 perspectiveProjection(float fov, float aspect, float nearPlane, f
{
0.0f,
0.0f,
0.5f * (farPlane + nearPlane) / (nearPlane - farPlane),
nearPlane / (nearPlane - farPlane),
-1.0f,
},
{
@@ -54,13 +54,13 @@ static Matrix4 orthographicProjection(float left, float right, float bottom, flo
{
0.0f,
0.0f,
-2.0f / (farPlane - nearPlane),
-2.0f / (nearPlane - farPlane),
0.0f,
},
{
-(right + left) / (right - left),
-(top + bottom) / (top - bottom),
-(farPlane + nearPlane) / (farPlane - nearPlane),
-(nearPlane + farPlane) / (nearPlane - farPlane),
1.0f,
},
};
+2
View File
@@ -1,4 +1,6 @@
#pragma once
#define GLM_FORCE_DEPTH_ZERO_TO_ONE
#define GLM_FORCE_LEFT_HANDED
#ifdef WIN32
#pragma warning(push)
#pragma warning(disable : 4201)