New Release D3D9Client Development

What ever is causing the problem must be something that's common with multiple rendering routines like initialization of something which is skipped during RenderSecondaryScene() pass but done properly during main scene pass. So, I guess I have to check every variable one by one.
 
Hi

Is there something like a 'lint' or any other static code analysis tool around for that?
cppcheck
But I actually checked the D3D9 files with it last week and found nothing serious. Maybe a eye with knowledge of that code will find something.
 
Hi

Is there something like a 'lint' or any other static code analysis tool around for that?
I don't know. So far, I have come up with nothing. I have done some code changes to verify a few things but not holding my breathe. The atmospheric rendering code should be replaced with a new one which is almost completed, just a gas-giant rendering and it's ready for final pre-merge tests. The failing code section is the only one using a render target with an alpha channel, so, maybe it should be tested with a regular surface instead.

From the subroutines vVessel::ProbeIrradiance() and Scene::IntegrateIrradiance() could you replace all D3DFMT_A16B16G16R16F types with D3DFMT_X8R8G8B8 and see how it goes. If this ain't working then we probably should wait for the new atmospheric model and see if that solves it. If not then we have to dig deeper.

It's really odd if a ring system rendering can cause the noise to appear.
 
[...]From the subroutines vVessel::probeIrradiance() and Scene::IntegrateIrradiance() could you replace all D3DFMT_A16B16G16R16F types with D3DFMT_X8R8G8B8 and see how it goes.[...]
Unbelievable!
1666897798238.png
The mip-map still shows some noise, but it's not noticable in the final result => no flashing visible! (y)
(y) (y) (y)

For the record - these 5 replacements were made (as suggested by you):

Diff:
 OVP/D3D9Client/Scene.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/OVP/D3D9Client/Scene.cpp b/OVP/D3D9Client/Scene.cpp
index 61b3069e..a1fcc63e 100644
--- a/OVP/D3D9Client/Scene.cpp
+++ b/OVP/D3D9Client/Scene.cpp
@@ -2454,15 +2454,15 @@ bool Scene::IntegrateIrradiance(vVessel *vV, LPDIRECT3DCUBETEXTURE9 pSrc, LPDIRE
     pOuts->GetDesc(&desc_out);
     
     if (!pIrradTemp) {
-        if (D3DXCreateCubeTexture(pDevice, 16, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A16B16G16R16F, D3DPOOL_DEFAULT, &pIrradTemp) != S_OK) {
+        if (D3DXCreateCubeTexture(pDevice, 16, 1, D3DUSAGE_RENDERTARGET, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &pIrradTemp) != S_OK) {
             LogErr("Failed to create irradiance temp");
             return false;
         }
-        if (D3DXCreateTexture(pDevice, 128, 128, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A16B16G16R16F, D3DPOOL_DEFAULT, &pIrradTemp2) != S_OK) {
+        if (D3DXCreateTexture(pDevice, 128, 128, 1, D3DUSAGE_RENDERTARGET, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &pIrradTemp2) != S_OK) {
             LogErr("Failed to create irradiance temp");
             return false;
         }
-        if (D3DXCreateTexture(pDevice, desc_out.Width, desc_out.Height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A16B16G16R16F, D3DPOOL_DEFAULT, &pIrradTemp3) != S_OK) {
+        if (D3DXCreateTexture(pDevice, desc_out.Width, desc_out.Height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &pIrradTemp3) != S_OK) {
             LogErr("Failed to create irradiance temp");
             return false;
         }
 OVP/D3D9Client/VVessel.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/OVP/D3D9Client/VVessel.cpp b/OVP/D3D9Client/VVessel.cpp
index aad1441d..fe1e1ef9 100644
--- a/OVP/D3D9Client/VVessel.cpp
+++ b/OVP/D3D9Client/VVessel.cpp
@@ -1306,11 +1306,11 @@ bool vVessel::ProbeIrradiance(LPDIRECT3DDEVICE9 pDev, DWORD cnt, DWORD flags)
     {
         D3DSURFACE_DESC desc;
         pIrDS->GetDesc(&desc);
-        if (D3DXCreateCubeTexture(pDev, desc.Width, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A16B16G16R16F, D3DPOOL_DEFAULT, &pIrdEnv) != S_OK) {
+        if (D3DXCreateCubeTexture(pDev, desc.Width, 1, D3DUSAGE_RENDERTARGET, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &pIrdEnv) != S_OK) {
             LogErr("Failed to create env cubemap for visual %s", _PTR(this));
             return true;
         }
-        if (D3DXCreateTexture(pDev, 128, 64, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A16B16G16R16F, D3DPOOL_DEFAULT, &pIrrad) != S_OK) {
+        if (D3DXCreateTexture(pDev, 128, 64, 1, D3DUSAGE_RENDERTARGET, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &pIrrad) != S_OK) {
             LogErr("Failed to create irradiance map for visual %s", _PTR(this));
             return true;
         }
 
Last edited:
New issue for the list: the HUD group is reflecting light (Sun), making it visible. Does not happen in Orbiter 2016, but I remember this happened before.
 
The mip-map still shows some noise, but it's not noticable in the final result => no flashing visible!
Yeah, that is expected since a 8-bit integer doesn't have a dynamic range of 16-bit float. The test was to see if the alpha channel is the source of the problem.

I can't really understand where the noise is coming from because no shader is supposed to write on that part of the image. Can you see any abnormal pixels in that region in "Irrad.Probe" image, that's where the "IrdPreItg" is made from.

I'll make some finals tests with d3d9_local_lights branch then merge it and I'll start working a merge of the new atmospheric model. Maybe it fixes the flashing issue or not.
 
New issue for the list: the HUD group is reflecting light (Sun), making it visible. Does not happen in Orbiter 2016, but I remember this happened before.
I'll look into this when starting to merge the virtual cockpit baked lights and sunlight shadows update.
 
[...]Can you see any abnormal pixels in that region in "Irrad.Probe" image, that's where the "IrdPreItg" is made from.
Sure:
1666906191096.png
and
1666906212994.png

Can it be that there's some kind of "feedback"? I mean like the ship is creating reflections, that create reflections, that ....
 
[...]I'll make some finals tests with d3d9_local_lights branch then merge it and I'll start working a merge of the new atmospheric model. Maybe it fixes the flashing issue or not.
Do that. It makes sense to keep the changes in d3d9_local_lights to only that: "local lights" ! (y)
In the meantime I'll either live with the flashy DG or apply those "fixes" (which are actually only "attenuators" ;) )
 
For me that looks clean. I see nothing there other than compression artifacts. If it's really clean then something must cause interference to ImageProcessing() class.
We should verify the input to be sure. Could you modify the Scene::IntegrateIrradiance() to save an image (the top most image):
C++:
    // ---------------------------------------------------------------------
    // Pre-Integrate Irradiance Cube
    //
    pIrradiance->Activate("PSPreInteg");
    pIrradiance->SetFloat("fD", &D3DXVECTOR2(1.0f / float(desc.Width), 1.0f / float(desc.Height)), sizeof(D3DXVECTOR2));

    for (DWORD i = 0; i < 6; i++)
    {
        pSrc->GetCubeMapSurface(D3DCUBEMAP_FACES(i), 0, &pSrf);
        pIrradTemp->GetCubeMapSurface(D3DCUBEMAP_FACES(i), 0, &pTgt);
        
        pDevice->StretchRect(pSrf, NULL, pTmp2, NULL, D3DTEXF_POINT);

        // Add
        static int q = 0;
        if (i == 2) {
            q++; if (q == 5) D3DXSaveTextureToFile("CubeFace.dds", D3DXIFF_DDS, pIrradTemp2, NULL);
        }
        // Add end
        
        pIrradiance->SetOutputNative(0, pTgt);
        pIrradiance->SetTextureNative("tSrc", pIrradTemp2, IPF_POINT | IPF_CLAMP);

        if (!pIrradiance->Execute(true)) {
            LogErr("pIrradiance Execute Failed");
            return false;
        }

        SAFE_RELEASE(pTgt);
        SAFE_RELEASE(pSrf);
    }
 
I may have found the problem. Could you add following lines in IProcess.cpp ImageProcessing::Execute() somewhere near the line 352

C++:
    // Execute ----------------------------------------------------------------
    //
    if (!bInScene) HR(pDevice->BeginScene());

// ADD BEGIN
    // Clear the viewport -----------------------------------------------------
    //
    if (blendop == 0)
    {
        if (pDepth) {
            HR(pDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xFF000000, 1.0f, 0L));
        }
        else {
            HR(pDevice->Clear(0, NULL, D3DCLEAR_TARGET, 0xFF000000, 1.0f, 0L));
        }
    }
// ADD END

    if (mode == gcIPInterface::ipitemplate::Rect)
    {
        HR(pDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, 4, 2, &cIndex, D3DFMT_INDEX16, &Vertex, sizeof(SMVERTEX)));
    }
 
  • Like
Reactions: GLS
For me that looks clean. I see nothing there other than compression artifacts. If it's really clean then something must cause interference to ImageProcessing() class.
We should verify the input to be sure. Could you modify the Scene::IntegrateIrradiance() to save an image (the top most image):
Here's this (1st with the D3DFMT_A16B16G16R16F -> D3DFMT_X8R8G8B8 replacement, 2nd with "unattenuated" Scene.cpp & VVessel.cpp)
ZIPped as .dds extension will not upload.
Seems like the "unattenuated" dds is not a valid dds.
 

Attachments

I may have found the problem. Could you add following lines in IProcess.cpp ImageProcessing::Execute() somewhere near the line 352[...]
Did that, but flashing is still there - slightly different, but still there
1666979115219.png
 
Thanks for the tests and texture samples. It is now clear what ever is wrong is about the ImageProcessing shader or shader pipeline configuration. Those textures were clean, nothing there that could cause this. I'll keep searching...
 
@jarmonik Would a TeamViewer session help you "see" the things? My machine is all yours if you like ;)
 
@jarmonik Would a TeamViewer session help you "see" the things? My machine is all yours if you like ;)
I am not familiar with that and not sure if there's anything to be seen other that what we already know. If you can still confirm that "Irrad.Probe" is clean of anomalous flickering pixels at the problem regions. I have made few commits to d3d9_noise_problem branch, if you can check if it fixes the problem. If not then you could change PSPreInteg() code to this. Number of flashing pixels should drop but are they all gone ?

C++:
float4 PSPreInteg(float x : TEXCOORD0, float y : TEXCOORD1) : COLOR
{
    float2 p = float2(x, y);
    return float4(tex2D(tSrc, p).rgb, 1);
}
 
I will so that as soon as I am Back Home.
And you should get your well deserved sleep :salute:
 
@kuddel Just in case you don't have enough work assigned yet ;) could you also have a quick look at this pull request? It updates the way the force vector and object frame axis display options are accessed by the graphics clients. For the D3D9 client it removes the need for the dialog message loop hooks in OapiExtension. I edited the OapiExtension code quite extensively, and since I think you are the author, you should probably make sure it's fine. I think it all works ok. The only issue I noticed is that the frame axis vectors for celestial bodies and surface bases are not displayed, but I am not sure if that was ever implemented in the D3D9 client.
 
Back
Top