Pass depth range to depth map visualization shader

Fixes #895
This commit is contained in:
Sascha Willems 2022-05-08 11:43:06 +02:00
parent 8e98d10f74
commit 8c376121c3
16 changed files with 46 additions and 16 deletions

View file

@ -3,10 +3,23 @@
Texture2D textureColor : register(t1);
SamplerState samplerColor : register(s1);
struct UBO
{
float4x4 projection;
float4x4 view;
float4x4 model;
float4x4 lightSpace;
float4 lightPos;
float zNear;
float zFar;
};
cbuffer ubo : register(b0) { UBO ubo; }
float LinearizeDepth(float depth)
{
float n = 1.0; // camera z near
float f = 128.0; // camera z far
float n = ubo.zNear;
float f = ubo.zFar;
float z = depth;
return (2.0 * n) / (f + n - z * (f - n));
}