#include <DepthRangeCalculator.hpp>
Classes | |
struct | ComputeRangeAttribs |
Attributes for ComputeRange() method. More... | |
struct | CreateInfo |
Depth range calculator create info. More... | |
Public Member Functions | |
DepthRangeCalculator (const CreateInfo &CI) noexcept(false) | |
Constructs a depth range calculator object. | |
bool | IsReady () const |
Returns true if the depth range calculator is ready to be used. | |
RefCntAutoPtr< IShaderResourceBinding > | CreateSRB (ITextureView *pDepthBufferSRV, IBuffer *pCameraAttribs) |
Creates a shader resource binding object to use in ComputeRange() method. | |
void | ComputeRange (const ComputeRangeAttribs &Attribs) |
Computes the depth range. | |
IBuffer * | GetDepthRangeBuffer () const |
Returns the depth range buffer. | |
const DepthRange & | GetDepthRange (IDeviceContext *pCtx=nullptr) |
Returns the depth range read back to the CPU. | |
Computes depth range from the scene depth buffer.
The class uses a compute shader to read the depth buffer and compute the near and far depth values. It writes the results to a buffer with the following layout:
struct DepthRange { float SceneNearZ; float SceneFarZ; float SceneNearDepth; float SceneFarDepth; };
SceneNearZ
is always less than SceneFarZ
.SceneNearDepth
is the depth value corresponding to SceneNearZ
.SceneFarDepth
is the depth value corresponding to SceneFarZ
.SceneNearDepth
will be greater than SceneFarDepth
.SceneNearZ
and SceneFarZ
must be positive values. Diligent::DepthRangeCalculator::DepthRangeCalculator | ( | const CreateInfo & | CI | ) |
Constructs a depth range calculator object.
[in] | CI | Create info. |
In case of failure, an exception is thrown.
void Diligent::DepthRangeCalculator::ComputeRange | ( | const ComputeRangeAttribs & | Attribs | ) |
Computes the depth range.
[in] | Attribs | Method attributes. |
The near/far depth values are written to the depth range buffer. If the ReadBackData
option was set to true in the CreateInfo
structure, the depth range will also be read back to the CPU and can be accessed using the GetDepthRange() method.
Note that the data read back to the CPU is typically a few frames behind the GPU.
const DepthRangeCalculator::DepthRange & Diligent::DepthRangeCalculator::GetDepthRange | ( | IDeviceContext * | pCtx = nullptr | ) |
Returns the depth range read back to the CPU.
[in] | pCtx | If not null, the function will poll the read back queue for the latest data. |