Depth buffer access from P3D post-processing system

SDK supports Prepar3D’s philosophy of an open development architecture and encourages third parties to bring new innovations with improved add-ons and training content.
Post Reply
BiologicalNanobot
Posts: 42
Joined: Wed Feb 10, 2021 4:15 pm

Depth buffer access from P3D post-processing system

Post by BiologicalNanobot »

Hi,

I'm making a simple post-processing shader for P3D v5, which requries depth input. However after drawing the depth buffer to the screen, I noticed that it's basically the grayscale version of the color buffer, instead of the expected depth buffer. Am I doing something wrong?

This is the shader code:

Code: Select all

#include "Quad.sh"

Texture2D<float4> srcTex;
Texture2D<float> srcDepth;

float4 PsSSAOMain(PsQuad vert) : SV_Target
{
    uint2 texture_dimensions;
    srcDepth.GetDimensions(texture_dimensions.x, texture_dimensions.y);

    int3 texture_coordinates = int3(vert.texcoord * texture_dimensions, 0);
    float depth = srcDepth.Load(texture_coordinates);

    return float4(depth, depth, depth, 1.0);
}
This is the XML file for configuration:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>

<SimBase.Document Type="AceXML" version="1,0">

    <PostProcessEffects.PostProcessDefinition>
        <EffectName>SSAO</EffectName>
        <ShaderFileName>SSAO.psh</ShaderFileName>
        <ShaderEntryPoint>PsSSAOMain</ShaderEntryPoint>
        <ColorRequest>TRUE</ColorRequest>
        <DepthRequest>TRUE</DepthRequest>
    </PostProcessEffects.PostProcessDefinition>

</SimBase.Document>
This is the result I'm getting:

Image

It doesn't look like the depth buffer at all. Is this expected behavior?

Thanks in advance.
Wonderboy
Posts: 65
Joined: Wed Feb 11, 2015 2:58 pm

Re: Depth buffer access from P3D post-processing system

Post by Wonderboy »

Hello. It clearly doesn't look like a depth buffer. When I experimented with reshade, I had to use a separate plugin to see what the picture should actually look like with the correct buffer. Unfortunately, I do not remember its name.
12700K @4.8 GHz, 3080ti, 32 Gb DDR4-3400
hso
Posts: 4
Joined: Wed Feb 17, 2021 7:42 am

Re: Depth buffer access from P3D post-processing system

Post by hso »

I hit exactly the same wall. Couldn't find a workaround. Even the provided examples that use depth (e.g. Blur.psh) don't work as intended.

The whole system seems quite buggy (in different ways in different versions). Say, I could never make PreVC (exclude the cocpit) work: by itself it can work, but always has disasterous consequences on the main view...
Post Reply