Texture resolution in P3D v4.5 POD view

Any issues, problems or troubleshooting topics related to the additional features present in the Prepar3D Professional Plus client application.
zamirk
Posts: 132
Joined: Mon Jul 21, 2014 8:39 am

Texture resolution in P3D v4.5 POD view

Post by zamirk »

Hi,

I am developing POD view for ISR but having issues in terrain loading while setting applied for world level of detail radius to max. As POD view can view beyond the settings available, how can I achieve high resolution textures beyond these settings. If this feature can't be achieved in P3D v4.5 then is it possible in your latest releases so that I can consider spending some bucks for upgrading my P3D.

Anyone from LM team, kindly guide me.

Regards,
Zamirk
User avatar
Martyson
Posts: 15188
Joined: Sun Mar 25, 2012 11:08 am

Re: Texture resolution in P3D v4.5 POD view

Post by Martyson »

Hello zamirk ,

You could do some testing for up to two weeks for free:

P3D Refund Policy:
https://www.prepar3d.com/support/refundpolicy/
Best Regards,
Vaughan Martell PP-ASEL (KDTW)
zamirk
Posts: 132
Joined: Mon Jul 21, 2014 8:39 am

Re: Texture resolution in P3D v4.5 POD view

Post by zamirk »

It means I have to upgrade otherwise there is no solution to this problem I am facing.
User avatar
Beau Hollis
Lockheed Martin
Posts: 2452
Joined: Wed Oct 06, 2010 3:25 pm

Re: Texture resolution in P3D v4.5 POD view

Post by Beau Hollis »

You should try using TerrainLodOrigin and SceneryLodOrigin in your camera definition as a first step. There is more info on this in the learning center. This features was available in v4.5.
https://prepar3d.com/SDKv4/sdk/cameras/ ... ation.html
If you are using C++ you can also control this behavior via the camera interface:
https://prepar3d.com/SDKv4/sdk/pdk_api/ ... aae1a95e58
https://prepar3d.com/SDKv4/sdk/pdk_api/ ... 5e0c9ddb95

In this case you set a LLA value, so you would need to pull that from the camera or target to emulate the simpler mode based approach used when setting it via the camera definition.

The same distance based loading is done, but the origin used for the distance calculation is set to your target so you should get full res terrain textures there. Also, because our GPU terrain uses whatever LODs are loaded across multiple view, you would still get full resolution terrain texture near the user if you have another camera open. That's not the case for scenery models which might not draw near the user if in a pod view with a scenery radius set 100 miles away. You also want to be careful about combining high terrain/scenery draw distances with multiple cameras that have very different origins. There is a hard limit of the total number of terrain tiles (2048) which you might max out if you have multiple views and your terrain texture resolution is set all the way up to say 7cm.

Thanks,
Beau Hollis
Prepar3D Software Architect
zamirk
Posts: 132
Joined: Mon Jul 21, 2014 8:39 am

Re: Texture resolution in P3D v4.5 POD view

Post by zamirk »

Thanks for your masterly guidance.

If I use C++ option and provide data to "SetTerrainLODOriginLLA()" which you have described above then I have to set TerrainLODOrigin to "Camera" in camera definition and same for the scenery. Am I Right?

Also I am using LOD 16 textures for photorealistic imagery, can you please guide to improve texture loading time if I implement C++ option which will help while pan operation in the POD view.

Thanks again for your precious time and help.
zamirk
Posts: 132
Joined: Mon Jul 21, 2014 8:39 am

Re: Texture resolution in P3D v4.5 POD view

Post by zamirk »

I have written the following code in Targeting Pod SDK sample, but it's not working. One thing to add, I am selecting Pod View on my main P3D window and running following code at 1Hz. Can you please highlight what I am missing?

Code: Select all

double lat, lng, alt;
g_spControllableCamera->GetCameraLookAtLLA(lat, lng, alt);

//Query for ICameraSystem
if (!g_spCameraSystem)
{
     auto* wndPluginSystem = PdkServices::GetWindowPluginSystem();
     if (wndPluginSystem)
     {
             auto* curwnd = wndPluginSystem->GetCurrentwindow();
             if (curWnd)
             {
                     auto* camSystem = curwind->GetCameraSystem();

                     if(camSystem)
                     {
                               camSystem->QueryInterface(IID_ICameraSystemV450, (void**)&g_spCameraSystem);
                      }
               }
        }
}

if (g_spCameraSystem)
{
        g_spCameraSystem->SetTerrainLODOriginLLA(lat, lng, alt);
        g_spCameraSystem->SetSceneryLODOriginLLA(lat, lng, alt);
}
Clifton Crane
Lockheed Martin
Posts: 1207
Joined: Tue Sep 25, 2012 2:34 pm

Re: Texture resolution in P3D v4.5 POD view

Post by Clifton Crane »

Hi zamirk,

I believe GetCameraLookAtLLA() will return latitude/longitude in degrees, whereas SetTerrainLODOriginLLA() and SetSceneryLODOriginLLA() expect lat/lon in radians. Both functions should use meters for altitude.

Regards,
Clifton
Clifton Crane
Prepar3D® Software Engineer Sr.
zamirk
Posts: 132
Joined: Mon Jul 21, 2014 8:39 am

Re: Texture resolution in P3D v4.5 POD view

Post by zamirk »

Hi Clifton,

Thanks for your response.

But documentation says:

Set the LLA of where the center of the terrain LOD radius for this camera will go.

Parameters
lat Latitude of LOD ring center in degrees
lon Longitude of LOD ring center in degrees
alt Altitude of LOD ring center in meters

Regards,
Clifton Crane
Lockheed Martin
Posts: 1207
Joined: Tue Sep 25, 2012 2:34 pm

Re: Texture resolution in P3D v4.5 POD view

Post by Clifton Crane »

Hi zamirk,

Thanks for pointing that out. I've taken a second look and can confirm that SetSceneryLODOriginLLA and SetTerrainLODOriginLLA expect radians for lat/lon. I will correct the documentation.

Regards,
Clifton
Clifton Crane
Prepar3D® Software Engineer Sr.
zamirk
Posts: 132
Joined: Mon Jul 21, 2014 8:39 am

Re: Texture resolution in P3D v4.5 POD view

Post by zamirk »

Hi Clifton,

Thanks for the update.

I have tried setting latitude and longitude in radians but still P3D failed to load terrain. I am setting 'TerrainLODOrigin = Target' in Camera definition. When we lock ground P3D loads terrain successfully but on unlock it unloads terrain immediately. We want P3D to load terrain where camera is pointing and for this purpose on your guidance I have impleted the previously posted snippet in Targeting Pod sample. It seems that what we are setting by using "SetTerrainLODOriginLLA()" is being overriden from somewhere else.

Regards,
Zamirk
zamirk
Posts: 132
Joined: Mon Jul 21, 2014 8:39 am

Re: Texture resolution in P3D v4.5 POD view

Post by zamirk »

Hi Clifton,

Any idea, what else I can do?

Regards,
zamirk
Posts: 132
Joined: Mon Jul 21, 2014 8:39 am

Re: Texture resolution in P3D v4.5 POD view

Post by zamirk »

Any hint on to SetTerrainLODOriginLLA?
User avatar
Beau Hollis
Lockheed Martin
Posts: 2452
Joined: Wed Oct 06, 2010 3:25 pm

Re: Texture resolution in P3D v4.5 POD view

Post by Beau Hollis »

One issue is that you are calling GetCurrentWindow() which may not give you the same window as your controllable camera. If no window is currently drawing, it will give you the active window or the main app window. Our frame and 1hz callbacks don't happen during a camera draw. You will get valid result for current window inside OnCustomRender callback but your callback would be hit once per window in the case where multiple windows are drawing so you would need to do some logic to filter out other views.

You can look up the correct window by name. In the case of that sample the name is stored in a static variable:

Code: Select all

static const std::wstring s_name(L"TargetingPodView");
Our default f-16 targeting pod uses a similar approach to update these values one per second but it creates a window plugin and does the origin set on the post camera update. The windows callbacks pass in the correct window as a parameter.

Code: Select all


void TargetingPod::TargetingPodWindowPlugin::OnPostCameraUpdate(IWindowV400* pWindow, ICameraSystemV400* pCamera)
{
    if (pWindow && pCamera && m_bUpdate)
    {
        static bool bValidLla = false;
        double dTime;
        int iSeconds;
        PdkServices::GetGlobalData()->GetUnitCode(L"Seconds", iSeconds);
        PdkServices::GetGlobalData()->GetAbsoluteTime(dTime, iSeconds);
        if ((dTime - m_dElapsedTime) > 1)
        {
            m_dElapsedTime = dTime;
            bValidLla = pCamera->GetCameraLookAtLLA(m_fLookAtLat, m_fLookAtLon, m_fLookAtAlt);
        }

        if (bValidLla)
        {
            double latRad = DEGREES_TO_RADIANS(m_fLookAtLat);
            double lonRad = DEGREES_TO_RADIANS(m_fLookAtLon);
            pCamera->SetSceneryLODOriginLLA(latRad, lonRad, m_fLookAtAlt);
            pCamera->SetTerrainLODOriginLLA(latRad, lonRad, m_fLookAtAlt);

            // If the controllable camera isn't locked on then update the target LLA to where the camera is currently looking
            // This won't cause the camera to lock to this position but will keep the autogen centered around this point
            if (!m_bHasTarget)
            {
                pCamera->SetTargetLatLonAltDegrees(m_fLookAtLat, m_fLookAtLon, m_fLookAtAlt);
            }
        }
    }
}
It's often the case that any full LLA type setter needs to be set every frame in the post camera update callback so that it can override the default value which would be calculated and set inside our camera update. I suspect that the above code works because the camera definition has set both LOD origins to the 'Target' and the target LLA isn't being recalculated and overridden because entity/position tracking are not currently enabled.

A similar approach might be the simplest workaround for you. Set the lod origin modes to target and then update the target once per second.
Beau Hollis
Prepar3D Software Architect
zamirk
Posts: 132
Joined: Mon Jul 21, 2014 8:39 am

Re: Texture resolution in P3D v4.5 POD view

Post by zamirk »

Hi Beau Hollis,

Thanks for your guidance and time, I will update after working on your guidelines.

Regards,
zamirk
Posts: 132
Joined: Mon Jul 21, 2014 8:39 am

Re: Texture resolution in P3D v4.5 POD view

Post by zamirk »

Hi Beau Hollis,
I have worked on guidelines you provided and implemented this function in TargetingPodPlugin class

Code: Select all

virtual void OnPostCameraUpdate(IWindowV400* pWindow, ICameraSystemV400* pCamera) override{
....
}
The TargetingPodPlugin class is inheriting from PdkPlugin and WindowPlugin so that I can override the OnPostCameraUpdate method. I have added some file handling in this method to debug whether the function is being called or not but it is not being executed.

Code: Select all

class TargetingPodPlugin : public PdkPlugin, public WindowPlugin{
...
}
I have initialized the ICameraV400 object in OnOneHz method

Code: Select all

if (!g_spCameraSystem) //g_spCameraSystem is the object of ICameraSystemV400
{
     auto* wndPluginSystem = PdkServices::GetWindowPluginSystem();
     if (wndPluginSystem)
     {
             auto* curwnd = wndPluginSystem->GetCurrentwindow();
             if (curWnd)
             {
                     auto* camSystem = curwind->GetCameraSystem();

                     if(camSystem)
                     {
                               camSystem->QueryInterface(IID_ICameraSystemV400, (void**)&g_spCameraSystem);
                      }
               }
        }
}
Any clue how I can invoke the OnPostCameraUpdate method?
Thanks for your consideration.
Post Reply