mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-08-28 17:36:36 +00:00
Add API to control the display camera's near and far planes
* This is separate from the near/far used to unproject rasterizer output vertex data.
This commit is contained in:
@@ -1731,6 +1731,15 @@ struct ICamera
|
||||
DOCUMENT("Closes the camera handle.");
|
||||
virtual void Shutdown() = 0;
|
||||
|
||||
DOCUMENT(R"(Sets the near and far plane for the camera's display.
|
||||
|
||||
The default value is ``0.1 - 100000.0`` if these are not set explicitly.
|
||||
|
||||
:param float n: The near plane.
|
||||
:param float f: The far plane.
|
||||
)");
|
||||
virtual void SetNearFar(float n, float f) = 0;
|
||||
|
||||
DOCUMENT(R"(Sets the position for the camera, either arcball or FPS.
|
||||
|
||||
For arcball cameras, this sets the lookat position at the centre of the arcball.
|
||||
|
||||
@@ -60,7 +60,11 @@ void D3D11Replay::RenderMesh(uint32_t eventId, const rdcarray<MeshFormat> &secon
|
||||
|
||||
D3D11RenderStateTracker tracker(m_pImmediateContext);
|
||||
|
||||
Matrix4f projMat = Matrix4f::Perspective(90.0f, 0.1f, 100000.0f, m_OutputWidth / m_OutputHeight);
|
||||
float nearPlane = cfg.cam ? ((Camera *)cfg.cam)->GetNear() : 0.1f;
|
||||
float farPlane = cfg.cam ? ((Camera *)cfg.cam)->GetFar() : 100000.0f;
|
||||
|
||||
Matrix4f projMat =
|
||||
Matrix4f::Perspective(90.0f, nearPlane, farPlane, m_OutputWidth / m_OutputHeight);
|
||||
|
||||
Matrix4f camMat = cfg.cam ? ((Camera *)cfg.cam)->GetMatrix() : Matrix4f::Identity();
|
||||
|
||||
|
||||
@@ -3066,7 +3066,10 @@ uint32_t D3D11Replay::PickVertex(uint32_t eventId, int32_t width, int32_t height
|
||||
cbuf.PickFlipY = cfg.position.flipY;
|
||||
cbuf.PickOrtho = cfg.ortho;
|
||||
|
||||
Matrix4f projMat = Matrix4f::Perspective(90.0f, 0.1f, 100000.0f, float(width) / float(height));
|
||||
float nearPlane = cfg.cam ? ((Camera *)cfg.cam)->GetNear() : 0.1f;
|
||||
float farPlane = cfg.cam ? ((Camera *)cfg.cam)->GetFar() : 100000.0f;
|
||||
|
||||
Matrix4f projMat = Matrix4f::Perspective(90.0f, nearPlane, farPlane, float(width) / float(height));
|
||||
|
||||
Matrix4f camMat = cfg.cam ? ((Camera *)cfg.cam)->GetMatrix() : Matrix4f::Identity();
|
||||
|
||||
|
||||
@@ -274,7 +274,11 @@ void D3D12Replay::RenderMesh(uint32_t eventId, const rdcarray<MeshFormat> &secon
|
||||
|
||||
MeshVertexCBuffer vertexData;
|
||||
|
||||
Matrix4f projMat = Matrix4f::Perspective(90.0f, 0.1f, 100000.0f, viewport.Width / viewport.Height);
|
||||
float nearPlane = cfg.cam ? ((Camera *)cfg.cam)->GetNear() : 0.1f;
|
||||
float farPlane = cfg.cam ? ((Camera *)cfg.cam)->GetFar() : 100000.0f;
|
||||
|
||||
Matrix4f projMat =
|
||||
Matrix4f::Perspective(90.0f, nearPlane, farPlane, viewport.Width / viewport.Height);
|
||||
Matrix4f InvProj = projMat.Inverse();
|
||||
|
||||
Matrix4f camMat = cfg.cam ? ((Camera *)cfg.cam)->GetMatrix() : Matrix4f::Identity();
|
||||
|
||||
@@ -2292,7 +2292,10 @@ uint32_t D3D12Replay::PickVertex(uint32_t eventId, int32_t width, int32_t height
|
||||
cbuf.PickFlipY = cfg.position.flipY;
|
||||
cbuf.PickOrtho = cfg.ortho;
|
||||
|
||||
Matrix4f projMat = Matrix4f::Perspective(90.0f, 0.1f, 100000.0f, float(width) / float(height));
|
||||
float nearPlane = cfg.cam ? ((Camera *)cfg.cam)->GetNear() : 0.1f;
|
||||
float farPlane = cfg.cam ? ((Camera *)cfg.cam)->GetFar() : 100000.0f;
|
||||
|
||||
Matrix4f projMat = Matrix4f::Perspective(90.0f, nearPlane, farPlane, float(width) / float(height));
|
||||
|
||||
Matrix4f camMat = cfg.cam ? ((Camera *)cfg.cam)->GetMatrix() : Matrix4f::Identity();
|
||||
|
||||
|
||||
@@ -2487,7 +2487,10 @@ uint32_t GLReplay::PickVertex(uint32_t eventId, int32_t width, int32_t height,
|
||||
|
||||
drv.glUseProgram(DebugData.meshPickProgram);
|
||||
|
||||
Matrix4f projMat = Matrix4f::Perspective(90.0f, 0.1f, 100000.0f, float(width) / float(height));
|
||||
float nearPlane = cfg.cam ? ((Camera *)cfg.cam)->GetNear() : 0.1f;
|
||||
float farPlane = cfg.cam ? ((Camera *)cfg.cam)->GetFar() : 100000.0f;
|
||||
|
||||
Matrix4f projMat = Matrix4f::Perspective(90.0f, nearPlane, farPlane, float(width) / float(height));
|
||||
|
||||
Matrix4f camMat = cfg.cam ? ((Camera *)cfg.cam)->GetMatrix() : Matrix4f::Identity();
|
||||
Matrix4f pickMVP = projMat.Mul(camMat);
|
||||
|
||||
@@ -56,8 +56,11 @@ void GLReplay::RenderMesh(uint32_t eventId, const rdcarray<MeshFormat> &secondar
|
||||
GLMarkerRegion renderMesh(
|
||||
StringFormat::Fmt("RenderMesh with %zu secondary draws", secondaryDraws.size()));
|
||||
|
||||
float nearPlane = cfg.cam ? ((Camera *)cfg.cam)->GetNear() : 0.1f;
|
||||
float farPlane = cfg.cam ? ((Camera *)cfg.cam)->GetFar() : 100000.0f;
|
||||
|
||||
Matrix4f projMat =
|
||||
Matrix4f::Perspective(90.0f, 0.1f, 100000.0f, DebugData.outWidth / DebugData.outHeight);
|
||||
Matrix4f::Perspective(90.0f, nearPlane, farPlane, DebugData.outWidth / DebugData.outHeight);
|
||||
|
||||
Matrix4f camMat = cfg.cam ? ((Camera *)cfg.cam)->GetMatrix() : Matrix4f::Identity();
|
||||
|
||||
|
||||
@@ -1225,7 +1225,10 @@ uint32_t VulkanReplay::PickVertex(uint32_t eventId, int32_t width, int32_t heigh
|
||||
|
||||
VkMarkerRegion::Begin(StringFormat::Fmt("VulkanReplay::PickVertex(%u, %u)", x, y));
|
||||
|
||||
Matrix4f projMat = Matrix4f::Perspective(90.0f, 0.1f, 100000.0f, float(width) / float(height));
|
||||
float nearPlane = cfg.cam ? ((Camera *)cfg.cam)->GetNear() : 0.1f;
|
||||
float farPlane = cfg.cam ? ((Camera *)cfg.cam)->GetFar() : 100000.0f;
|
||||
|
||||
Matrix4f projMat = Matrix4f::Perspective(90.0f, nearPlane, farPlane, float(width) / float(height));
|
||||
|
||||
Matrix4f camMat = cfg.cam ? ((Camera *)cfg.cam)->GetMatrix() : Matrix4f::Identity();
|
||||
Matrix4f pickMVP = projMat.Mul(camMat);
|
||||
|
||||
@@ -508,8 +508,11 @@ void VulkanReplay::RenderMesh(uint32_t eventId, const rdcarray<MeshFormat> &seco
|
||||
VkViewport viewport = {0.0f, 0.0f, (float)m_DebugWidth, (float)m_DebugHeight, 0.0f, 1.0f};
|
||||
vt->CmdSetViewport(Unwrap(cmd), 0, 1, &viewport);
|
||||
|
||||
float nearPlane = cfg.cam ? ((Camera *)cfg.cam)->GetNear() : 0.1f;
|
||||
float farPlane = cfg.cam ? ((Camera *)cfg.cam)->GetFar() : 100000.0f;
|
||||
|
||||
Matrix4f projMat =
|
||||
Matrix4f::Perspective(90.0f, 0.1f, 100000.0f, float(m_DebugWidth) / float(m_DebugHeight));
|
||||
Matrix4f::Perspective(90.0f, nearPlane, farPlane, float(m_DebugWidth) / float(m_DebugHeight));
|
||||
Matrix4f InvProj = projMat.Inverse();
|
||||
|
||||
Matrix4f camMat = cfg.cam ? ((Camera *)cfg.cam)->GetMatrix() : Matrix4f::Identity();
|
||||
|
||||
@@ -46,6 +46,15 @@ public:
|
||||
pos = Vec3f(x, y, z);
|
||||
}
|
||||
|
||||
void SetNearFar(float n, float f)
|
||||
{
|
||||
m_Near = n;
|
||||
m_Far = f;
|
||||
}
|
||||
|
||||
float GetNear() { return m_Near; }
|
||||
float GetFar() { return m_Far; }
|
||||
|
||||
// Arcball functions
|
||||
void ResetArcball();
|
||||
void SetArcballDistance(float d)
|
||||
@@ -76,6 +85,8 @@ private:
|
||||
bool dirty;
|
||||
Matrix4f mat, basis;
|
||||
|
||||
float m_Near = 0.1f, m_Far = 100000.0f;
|
||||
|
||||
Vec3f pos;
|
||||
|
||||
// Arcball
|
||||
|
||||
Reference in New Issue
Block a user