Firs time poster, long time user!. ![]()
I am banging my head against this bug in my project. I am using SDL3 GPU to write a deferred renderer and try to reconstruct the world positions in the scene from the depth pass. However, I can not get it to work.
Here is the albedo of the scene for reference:
Here is the raw depth, original world positions and the reconstructed world positions from the depth visualised:
Using this shader code to reconstruct the world positions:
// Reconstruct position from depth value
float3 ReconstructPosition(float2 texCoord, float depth, float4x4 invViewProj) {
// Convert to NDC
float4 clipSpace = float4(
texCoord.x * 2.0 - 1.0,
texCoord.y * 2.0 - 1.0,
depth,
1.0
);
// Transform to world space
float4 worldSpace = mul(invViewProj, clipSpace);
// Perspective divide
return worldSpace.xyz / worldSpace.w;
}
As you can see above the reconstruction did not work. The original and reconstructed world position visualisations should be the same if correct.
Anyone got a clue where it goes wrong?




