Removing more debugging code

This commit is contained in:
Dynamitos
2024-10-21 22:12:50 +02:00
parent f1316eb213
commit bbb774d9df
4 changed files with 55 additions and 5 deletions
+2
View File
@@ -11,6 +11,8 @@ struct ViewParameter
float4x4 inverseViewMatrix;
float4x4 projectionMatrix;
float4x4 inverseProjection;
float4x4 viewProjectionMatrix;
float4x4 inverseViewProjectionMatrix;
float4 cameraPosition_WS;
float4 cameraForward_WS;
float2 screenDimensions;
+1 -1
View File
@@ -62,7 +62,7 @@ int ClassifyBisector(in BisectorGeometry tri, uint depth)
return FRUSTUM_CULLED;
// Project the points on screen
float4x4 viewProjectionMatrix = mul(pViewParams.projectionMatrix, pViewParams.viewMatrix);
float4x4 viewProjectionMatrix = pViewParams.viewProjectionMatrix;
float4 p0P = mul(viewProjectionMatrix, float4(tri.p[0], 1.0));
p0P.xy = p0P.xy / p0P.w;
p0P.xy = (p0P.xy * 0.5 + 0.5);
+37 -4
View File
@@ -24,6 +24,8 @@ RenderPass::~RenderPass() {}
void RenderPass::beginFrame(const Component::Camera& cam) {
auto screenDim = Vector2(static_cast<float>(viewport->getWidth()), static_cast<float>(viewport->getHeight()));
Matrix4 cameraMatrix = cam.getViewMatrix();
Matrix4 projectionMatrix = viewport->getProjectionMatrix();
viewParams = {
.viewFrustum =
{
@@ -47,10 +49,12 @@ void RenderPass::beginFrame(const Component::Camera& cam) {
},
},
},
.viewMatrix = cam.getViewMatrix(),
.inverseViewMatrix = glm::inverse(cam.getViewMatrix()),
.projectionMatrix = viewport->getProjectionMatrix(),
.inverseProjection = glm::inverse(viewport->getProjectionMatrix()),
.viewMatrix = cameraMatrix,
.inverseViewMatrix = glm::inverse(cameraMatrix),
.projectionMatrix = projectionMatrix,
.inverseProjection = glm::inverse(projectionMatrix),
.viewProjectionMatrix = projectionMatrix * cameraMatrix,
.inverseViewProjectionMatrix = glm::inverse(projectionMatrix * cameraMatrix),
.cameraPosition_WS = Vector4(cam.getCameraPosition(), 1),
.cameraForward_WS = Vector4(cam.getCameraForward(), 1),
.screenDimensions = screenDim,
@@ -58,6 +62,35 @@ void RenderPass::beginFrame(const Component::Camera& cam) {
.frameIndex = Gfx::getCurrentFrameIndex(),
.time = static_cast<float>(Gfx::getCurrentFrameTime()),
};
// screen space
StaticArray<Vector4, 4> corners = {
Vector4(0, 0, -1, 1),
Vector4(screenDim.x, 0, -1, 1),
Vector4(screenDim.y, 0, -1, 1),
Vector4(screenDim.x, screenDim.y, -1, 1),
};
for (uint32 i = 0; i < corners.size(); ++i) {
Vector2 texCoord = Vector2(corners[i].x, corners[i].y) / screenDim;
Vector4 clip = Vector4(Vector2(texCoord.x, 1 - texCoord.y) * 2.0f - 1.0f, corners[i].z, corners[i].w);
Vector4 world = viewParams.inverseViewProjectionMatrix * clip;
corners[i] = world / world.w;
}
//viewParams.viewFrustum = {
// .planes =
// {
// computePlane(cam.getCameraPosition(), Vector(corners[2]), Vector(corners[0])),
// computePlane(cam.getCameraPosition(), Vector(corners[1]), Vector(corners[3])),
// computePlane(cam.getCameraPosition(), Vector(corners[0]), Vector(corners[1])),
// computePlane(cam.getCameraPosition(), Vector(corners[3]), Vector(corners[2])),
// },
//};
viewParamsBuffer->rotateBuffer(sizeof(ViewParameter));
viewParamsBuffer->updateContents(0, sizeof(ViewParameter), &viewParams);
viewParamsBuffer->pipelineBarrier(Gfx::SE_ACCESS_TRANSFER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT,
@@ -34,12 +34,27 @@ class RenderPass {
struct Frustum {
Plane planes[4];
};
Plane computePlane(Vector p0, Vector p1, Vector p2) {
Plane plane;
Vector v0 = p1 - p0;
Vector v2 = p2 - p0;
plane.n = normalize(cross(v0, v2));
plane.d = dot(plane.n, p0);
return plane;
}
struct ViewParameter {
Frustum viewFrustum;
Matrix4 viewMatrix;
Matrix4 inverseViewMatrix;
Matrix4 projectionMatrix;
Matrix4 inverseProjection;
Matrix4 viewProjectionMatrix;
Matrix4 inverseViewProjectionMatrix;
Vector4 cameraPosition_WS;
Vector4 cameraForward_WS;
Vector2 screenDimensions;