New Release D3D9Client Development

GLS

Well-known member
Orbiter Contributor
Addon Developer
Joined
Mar 22, 2008
Messages
5,873
Reaction score
2,868
Points
188
Website
github.com
OK, this one seems an Orbiter bug:
  • load a scenario with a "Context XYZ" entry
  • exit to the launch pad, but don't close it
  • load another scenario, this one without the "Context" entry
  • MOGE CTD, D3D9 loads as if "Context XYZ" was in the scenario

Nothing in the Orbiter.log, but the D3D9 log has several lines of
[ERROR] Base Object 0x253A460 = 'Zaragoza' not cataloged
for the "Context XYZ" surface bases.

Looks like something isn't being initialized between 2 runs in the same session.

BTW, running Orbiter 2016.
 

yitianetie

Member
Joined
Mar 24, 2020
Messages
50
Reaction score
18
Points
23
Location
Brittany
Hi everyone,

A question to Jarmonik and eventually others about a very old issue : From the long time you hardly work on this awesome graphical client, have you found some solutions to fix "floating" shadows from generic building above the terrain ? I cannot bear to see them while landing on the earth, so that I prefer to disable shadows ?. But as I see, it seems to be only related to generic building (those provided in Orbiter 2016) and especially on sharp terrain. And curiously, those same buildings can be crossed by sunlight.

Sorry for the inconvenience ?
 

Attachments

  • light_crossing_generic_buildings.JPG
    light_crossing_generic_buildings.JPG
    28.8 KB · Views: 26
  • shadows_generic_buildings.JPG
    shadows_generic_buildings.JPG
    24.3 KB · Views: 23

Abloheet

Addon Developer
Addon Developer
Joined
Apr 18, 2009
Messages
212
Reaction score
40
Points
43
Location
Kolkata,West Bengal
Hi everyone,

A question to Jarmonik and eventually others about a very old issue : From the long time you hardly work on this awesome graphical client, have you found some solutions to fix "floating" shadows from generic building above the terrain ? I cannot bear to see them while landing on the earth, so that I prefer to disable shadows ?. But as I see, it seems to be only related to generic building (those provided in Orbiter 2016) and especially on sharp terrain. And curiously, those same buildings can be crossed by sunlight.

Sorry for the inconvenience ?


The sunlight crossing through buildings, that is a side effect of the lens flare post processing filter. I recommend not using that processing filter. Instead, use the LightGlow filter, which gives a pseudo-HDR effect, or no filter at all.

The other issue with shadows, it is still there. Surface base object shadows do not map to the terrain properly. Plus, surface base objects do not seem to be affected by distance fog in atmosphere. I remember there was a discussion about z-buffer bug with rendering surface base objects? That issue does not seem to be fixed yet.
 

80mileshigh

Addon Developer
Addon Developer
Donator
Joined
Feb 18, 2008
Messages
365
Reaction score
258
Points
63
Location
Melbourne
Website
eightymileshigh.wordpress.com
Hello,how would I go about putting a bump map on a custom spacecraft?

I can tell you how to do it in GIMP. It's all the other maps I need a tutorial for! It might be handy to have a tutorial written if there's an expert texture artist among us.

This may not be the best method, but it will give you a result, it's what I've been doing ...

Using GIMP 2.10:
  1. Open your texture
  2. Go to: Colors>Desaturate>Desaturate and choose Mode: 'Value (HSV)' - I leave the rest as default (Blending Options Mode: Replace, Opacity 100.00)
  3. Go to: Filters>Generic>Normal Map - the only thing I change is the scale which I reduce to 2 or 3. Experiment and see what you like, high numbers = stronger effect. You might like to experiment with Flip X Flip Y options if your texture has a really obvious lighting direction and you want to get your bump to match this.
  4. File>Export As - add '_norm' to the filename of your original texture. Ie if your texture is red.dss, your accompanying bump should be red_norm.dds. As soon as you attempt to export a dds file extension you'll see the compression options to choose from.
Caveat: I bet there is a better way! I'm stumbling through the new features and I'm still not making good spec maps and haven't tried the others. But this gets me a working bump map. I'd love to see simple tutes like this for all the maps using GIMP or other free software. (and apologies if they're out there and I've missed them).

Hope this helps!
 

Jango Fett

New member
Joined
Sep 10, 2020
Messages
29
Reaction score
4
Points
3
Location
here
You don't even need to edit the config file, D3D9 just puts it on there for us or what? Oh and the dss and then dds HUH !

Sorry not a pro at this yet
 

Marg

Active member
Joined
Mar 20, 2008
Messages
482
Reaction score
66
Points
28
Yes, just add "_norm" to filename, making the second file: for example, file like "redgit.dds" has to have "redgit_norm.dds". I have plugin in paint.net Program which easily makes those files (they look blue-pink colored).
 
Last edited:

Jango Fett

New member
Joined
Sep 10, 2020
Messages
29
Reaction score
4
Points
3
Location
here
thanks!
this will really help me out

But I was also wondering is it possible to make a displacement map in orbiter or is that just dreaming? and does that even belong in this thread?
 

Abdullah Radwan

Addon Developer
Addon Developer
Joined
Aug 20, 2017
Messages
314
Reaction score
284
Points
78
Location
Cairo
I am trying to compile my Camera MFD to Orbiter 2010, but I couldn't find the GC API in the D3D9 client Orbiter 2010 version. How can I use the custom cameras in Orbiter 2010?
 

kuddel

Donator
Donator
Joined
Apr 1, 2008
Messages
2,064
Reaction score
507
Points
113
GC API is currently only available for Orbiter 2016 and Orbiter BETA.
From memory, I can not say whether it can be back-ported to Orbiter 2010.
Even if it could be done, I think it might only be a feature-reduced set and therefore most probably not going to happen. Sorry.
 

Abdullah Radwan

Addon Developer
Addon Developer
Joined
Aug 20, 2017
Messages
314
Reaction score
284
Points
78
Location
Cairo
GC API is currently only available for Orbiter 2016 and Orbiter BETA.
From memory, I can not say whether it can be back-ported to Orbiter 2010.
Even if it could be done, I think it might only be a feature-reduced set and therefore most probably not going to happen. Sorry.
There is a setting to control custom cameras in D3D9 client for Orbiter 2010. How can it be used without the API?
 

kuddel

Donator
Donator
Joined
Apr 1, 2008
Messages
2,064
Reaction score
507
Points
113
Good point. The documentation is not up to date with that setting.
After looking at the source-code[1] I remember that for Orbiter 2010 there is a predecessor to the GC API: OGCI
The interface is declared in Orbitersdk\include\OGCI.h and is defined in Orbitersdk\include\OGCI.cpp

Maybe you can find what you need in there.

[1] ...which is always the best documentation ;)
 

Abdullah Radwan

Addon Developer
Addon Developer
Joined
Aug 20, 2017
Messages
314
Reaction score
284
Points
78
Location
Cairo
Good point. The documentation is not up to date with that setting.
After looking at the source-code[1] I remember that for Orbiter 2010 there is a predecessor to the GC API: OGCI
The interface is declared in Orbitersdk\include\OGCI.h and is defined in Orbitersdk\include\OGCI.cpp

Maybe you can find what you need in there.

[1] ...which is always the best documentation ;)
The problem is that these files don't exist in the last D3D9 client for Orbiter 2010. It doesn't even have an Orbitersdk folder in the archive. Can you upload everything I need for me? I assume it's only the header and source file (no library because the source file is included). It would be great to include the documentation too (if they aren't already in the interface).

EDIT: Nevermind I found the files in the older version (R15). Looks like they will have what I need. Thank you!
Abdullah, thanks for your efforts!
I agree too thank you for doing this Abdullah.
No problem :giggle:
 
Last edited:

Abdullah Radwan

Addon Developer
Addon Developer
Joined
Aug 20, 2017
Messages
314
Reaction score
284
Points
78
Location
Cairo
Everything seems to be working fine, except that I can't see any vessel on the MFD:

E4DoiPG.png


Here is the code:
C++:
// Header
class Camera_MFD : public MFD2, public CameraMFD
{
public:
    Camera_MFD(DWORD w, DWORD h, VESSEL *vessel, UINT mfd);
    bool Update(oapi::Sketchpad *skp);
private:
    SURFHANDLE hRenderSrf = nullptr; // 3D render target
    CAMERAHANDLE hCamera = nullptr;  // Custom camera handle used to render views into surfaces and textures
    void setCustomCamera();
};

// Source Code
Camera_MFD::Camera_MFD(DWORD w, DWORD h, VESSEL* vessel, UINT mfd) : MFD2(w, h, vessel)
{
    if (ogciInitialize()) {
        // Create 3D render target
        hRenderSrf = ogciCreateSurfaceEx(W, H, OAPISURFACE_TEXTURE  | OAPISURFACE_RENDERTARGET |
                                               OAPISURFACE_RENDER3D | OAPISURFACE_NOMIPMAPS);
        // Clear the surface
        oapiClearSurface(hRenderSrf);

        setCustomCamera();
    }
}

bool Camera_MFD::Update(oapi::Sketchpad *skp)
{
    // Helper for static texts
    auto SKPTEXT = [skp](int x, int y, const char* str) { skp->Text(x, y, str, strlen(str)); };

    if (hRenderSrf && ogciSketchpadVersion(skp) == SKETCHPAD_DIRECTX) {
        // Blit the camera view into the sketchpad.
        ogciSketchBlt(skp, hRenderSrf, 0, 0);
    }
    else {
        ogciRequestDXSketchpad(skp);
    }
}

// Here is Orbiter 2016 code for comparison
bool Camera_MFD::Update(oapi::Sketchpad *skp)
{
    // Helper for static texts
    auto SKPTEXT = [skp](int x, int y, const char* str) { skp->Text(x, y, str, strlen(str)); };

    if (hRenderSrf && gcSketchpadVersion(skp) == 2) {
        Sketchpad2* skp2 = static_cast<Sketchpad2*>(skp);

        // Blit the camera view into the sketchpad.
        RECT sr = { 0, 0, LONG(W), LONG(H) };
        skp2->CopyRect(hRenderSrf, &sr, 0, 0);
    }
}
// End of Orbiter 2016 code

void Camera_MFD::setCustomCamera()
{
    hCamera = ogciSetupCustomCamera(hCamera, data->hVessel, camData.pos, dir, rot, camData.fov * RAD, hRenderSrf, 0xFF);
}
 

Abdullah Radwan

Addon Developer
Addon Developer
Joined
Aug 20, 2017
Messages
314
Reaction score
284
Points
78
Location
Cairo
It seems like I can't see the vessel that created the camera only, but I can see other vessels. This happens only in Orbiter 2010. I can see the vessel that created the camera in Orbiter 2016 without a problem.
 

80mileshigh

Addon Developer
Addon Developer
Donator
Joined
Feb 18, 2008
Messages
365
Reaction score
258
Points
63
Location
Melbourne
Website
eightymileshigh.wordpress.com
Hi Jarmonik,

As discussed here, I have a HUD which renders clearly in MOGE but only very faintly in your Dx9 client.

Admittedly I'm achieving this with Vinka's old Spacecraft 4, which might be the problem.

As per Urwumpe's suggestion in that thread, would it be possible to include some HUD rendering options in your client which may solve the issue?
 

BenSisko

Donator
Donator
Joined
Feb 18, 2008
Messages
419
Reaction score
44
Points
28
It seems like I can't see the vessel that created the camera only, but I can see other vessels. This happens only in Orbiter 2010. I can see the vessel that created the camera in Orbiter 2016 without a problem.

Abdullah,
I can't appreciate the subtleties of coding but from my perspective, the problem you've outlined developing Camera MFD 2010 may not be an issue. In our add-ons, Gattispilot and I have used Camera MFD to allow the flight crew to "see" outside the cockpit during proximity maneuvers (VTOL approach to landing, docking approach) when the ship's structure obstructs the view from the cockpit. Not seeing the craft that originates the camera point of view isn't an issue as long as it shows whatever vessel or structure it's pointed at.
 
Top