New Release D3D9Client Development

N_Molson

Addon Developer
Addon Developer
Donator
Joined
Mar 5, 2010
Messages
9,271
Reaction score
3,244
Points
203
Location
Toulouse
I was more thinking the difference between Orbiter native and the D3D9 client, I don't expect the full features of blender materials to be available.

I guess it would be possible to export Blender properties like "roughness", and translate Blender "metallic" in D3D9 "reflectivity", that alone would be quite useful.
 

jarmonik

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 28, 2008
Messages
2,651
Reaction score
785
Points
128
There is a new Beta (4.12) of the D3D9Client published.

This version contains a new (experimental) PBR shader using a "Metalness" workflow. All models currently existing for the Orbiter are using the old shaders by default, so, the new shader shouldn't mess up any existing add-ons. This new "Metalness.fx" shader can be assigned into a Mesh by using the Material editor in D3D9DebugControls. This is very easy to use shader with very simple user input parameters and it's designed to be used with the "Light Glow" post processing to improve the "HDR" capabilities. Shader output isn't clamped to 0-1 so it extends beyond it. There is also a new "D3D9 Graphics Controls" dialog added, currently containing sliders to tune the post-processing. That is a control center for real-time adjustment, more controls are likely to appear. There are also intentions to create a more advanced shader that would use the reflection map "*_refl.dds" instead of metalness map.

The main Textures or Material properties required by the shader are:
  • Regular "diffuse" texture map as used by the DX7 as an example.
  • Grey scale Roughness texture "*_rghn.dds" and/or roughness material property. The texture is modulated by material just like in a case of the diffuse texture.
  • Grey scale Metalness texture "*_metal.dds" or metalness material property. The "metalness" value is 1.0 for metals and 0.0 for non-metals. Values between the two are rare. The "metalness" can be in most cases set by using the material property without need of a texture.

Optional texture maps supported by the shader:
  • Normal Map (Tested OK)
  • Transluciency "*_transl.dds" and Transmittance "_transm.dds" (Tested OK)
  • Emission map "*_emis.dds" (Not tested)

Not Supported by the shader:
  • Specular Map "*_spec.dds"
  • Reflection Map "*_refl.dds"


The questions for the "advanced" shader are:

1.) Should the reflection and roughness textures be modulated by material value to allow easy real-time fine tuning ?

2.) Should it be safe-guarded from an over saturation like the current default shader is, or should the responsibility be moved to a user not to over saturate textures. As an example the diffuse color of a radiators on the Space Shuttle is dark blue which is a bit difficult to archive with the safe-guards on, since it would require a bright blue diffuse texture and even that wouldn't work at all if the reflection is set to be slightly too intense.

Without safe guards: FinalColor = DiffuseColor + Reflection
With safe guards: FinalColor = DiffuseColor * ( 1.0 - intensity_of( Reflection ) ) + Reflection

Here are some images rendered with the new shader.
The shader is experimental and modifications are likely to occur. Feel free to experiment on your own by editing the Metalness.fx. Ideas and suggestions are always welcome.

EDIT: I forgot to mention that there is a "MaterialTestSphere" "vessel" located in a Scenario Editor, you can place it anywhere for testing. (No texture)
 

Attachments

  • s1.jpg
    s1.jpg
    69.4 KB · Views: 316
  • s2.jpg
    s2.jpg
    71.7 KB · Views: 45
Last edited:

DaveS

Addon Developer
Addon Developer
Donator
Beta Tester
Joined
Feb 4, 2008
Messages
9,429
Reaction score
680
Points
203
Tested it around a bit and the only thing I have found so far is that the "Glow" property of the material editor doesn't seem to do anything. It seems to be totally inert. Also, it seems like the atmosphere rendering has been improved as well and it looks great! Now even with proper sunrise/sunset effects.

Later edit:
Now that I have taken a closer look at things, it looks like it applies a uniform lighting to all parts of the mesh, ignoring shading completely. I've attached a screenshot that shows this. It looks like it has an emissive setting applied to it but it doesn't.

Any news on multi-cam setups for reflections?
 

Attachments

  • D3D9Client_new_shader.jpg
    D3D9Client_new_shader.jpg
    1 MB · Views: 35
Last edited:

jedidia

shoemaker without legs
Addon Developer
Joined
Mar 19, 2008
Messages
10,842
Reaction score
2,105
Points
203
Location
between the planets
PBR shader is awesome, makes it a lot easier to use free texture libraries for some stuff:
1614725056926.png

Aluminium foil from here: https://www.texturecan.com/details/25/
20 minutes to put it in, including jpg to dds conversion and some fiddling with the standard orbiter materials.

:cheers: :hailprobe:

One note, though. It seems the reflection map reflects the blackness of space, which as far as I understand physics isn't quite as it should be. I'm not sure if they have always done that (this was my first), or if that is a problem specific to this shader.
 

kuddel

Donator
Donator
Joined
Apr 1, 2008
Messages
2,064
Reaction score
507
Points
113
Hi Jarmo,
I've taken a quick look at some of the new features. Here my comments:

  • It would be nice to have [reset to default] buttons (for each slider) on the "Graphic controls" pane (like paint.NET dialogs have them[1] for example).
  • If I am not mistaken, some of those sliders are only effective when the "Light Glow" post processing is enabled, right? It might be nice to disable them[2] if that's not the case.
  • I took the liberty to update/unify the project files ;)

Other than that I haven't found enough time for more in-depth tests, but as always:

Nice work ?


[1] see Attachment
[2]...and maybe add a bubble-help popup to inform the user about this.
 

Attachments

  • paint.NET.png
    paint.NET.png
    9.3 KB · Views: 12
  • reset.png
    reset.png
    332 bytes · Views: 10
Last edited:

jarmonik

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 28, 2008
Messages
2,651
Reaction score
785
Points
128
One note, though. It seems the reflection map reflects the blackness of space, which as far as I understand physics isn't quite as it should be. I'm not sure if they have always done that (this was my first), or if that is a problem specific to this shader.
That is actually correct, mostly. More reflective a metal is, less color it has of it's own. But, I'll still have to make some tests...

Here's a video of a heat shield separation form Mars 2020 rover, notice the black reflection. https://www.orbiter-forum.com/threads/nasas-mars-2020-rover.31356/post-577840

EDIT: One thing should be noted in our roughness map is that it's actually inverted 1.0 is smooth/glossy and 0.0 is rough. That would make it actually a smoothness or a gloss map. In a typical roughness map 0.0 is smooth/glossy and 1.0 is rough. So, some attention is required there.
 
Last edited:

n72.75

Move slow and try not to break too much.
Orbiter Contributor
Addon Developer
Tutorial Publisher
Donator
Joined
Mar 21, 2008
Messages
2,687
Reaction score
1,337
Points
128
Location
Saco, ME
Website
mwhume.space
Preferred Pronouns
he/him
Here's another good example of reflecting space:

Apollo_17_Command_Module_AS17-145-22261HR.jpg
 

jarmonik

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 28, 2008
Messages
2,651
Reaction score
785
Points
128
Now that I have taken a closer look at things, it looks like it applies a uniform lighting to all parts of the mesh, ignoring shading completely. I've attached a screenshot that shows this. It looks like it has an emissive setting applied to it but it doesn't.
I suppose there could be somekind of conflict that might feed incorrect data to emission material, ambient light could also be the source. Which one it is or is it something else.

Could you find the following line from Metalness.fx (it's approximately somewhere near line 278)
Code:
// Combine diffuse terms
float3 zD = cDiff.rgb * fA * LightFX(cSun * fR * dLN + cDiffLocal + cAmbient) + (cDiff.rgb * gMtrl.emissive.rgb) + cE;

And change it to by removing the emission terms
Code:
float3 zD = cDiff.rgb * fA * LightFX(cSun * fR * dLN + cDiffLocal + cAmbient) + cE;

It that doesn't work then remove the cAmbient term
Code:
float3 zD = cDiff.rgb * fA * LightFX(cSun * fR * dLN + cDiffLocal) + cE;

The main problem with additional env-cams is that how to properly configure them. A configuration file is a possibility but it would require to manually type a lot of mesh group IDs into the file. I was hoping to create an editor that would allow to do the thing visually but I just don't have the time for that. That could be relatively easy job for someone else.
 

jarmonik

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 28, 2008
Messages
2,651
Reaction score
785
Points
128
It should reflect the full scene. As you can see on the Apollo photo above, it reflects the Moon, the LM and black space.
There is a "Full Scene" option in D3D9 Configuration and it's set to "Planet Only" by default. In most cases it's sufficient enough.
 

DaveS

Addon Developer
Addon Developer
Donator
Beta Tester
Joined
Feb 4, 2008
Messages
9,429
Reaction score
680
Points
203
Going down to the third option eliminates the emissivity issue but produces this. As far as typing mesh group IDs, how about making use of mesh group resource file created by the Orbiter SDK included meshres.exe file? It takes a mesh file and spits out a standard C++ header file (*.h) that has all of the mesh group labels indexed by their mesh group IDs.
 

Attachments

  • D3D9Client_new_shader2.jpg
    D3D9Client_new_shader2.jpg
    1.6 MB · Views: 20

jarmonik

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 28, 2008
Messages
2,651
Reaction score
785
Points
128
Going down to the third option eliminates the emissivity issue but produces this.
So, the cAmbient was the source ? The Earth glow is a part of it. The "Glow" material you mentioned earlier in not in use and it has nothing to do with this. There might be a problem with environment maps and if that's the case it may have existed a long time.

Could you check in a D3D9DebugControl after pressing ">>>" to see the extended page. In a "Scene Debugger" section select "Display env map for level: "Blur 4". Is the cube-map all white or heavily blurred Earth as it should be ?
 

DaveS

Addon Developer
Addon Developer
Donator
Beta Tester
Joined
Feb 4, 2008
Messages
9,429
Reaction score
680
Points
203
It looks alright to me. Here's the D3D9Client GC file:

Code:
CONFIG_VERSION 3
; =============================================
MESH SSU/Orbiter
SHADER Metalness
; ---------------------------------------------
MATERIAL 1
AMBIENT 0.000000 0.000000 0.000000
DIFFUSE 1.000000 1.000000 1.000000 1.000000
EMISSION2 0.000000 0.000000 0.000000
GLOW 0.000000
; ---------------------------------------------
MATERIAL 2
AMBIENT 0.000000 0.000000 0.000000
ROUGHNESS 0.950000
METALNESS 1.000000
GLOW 0.129412
 

Attachments

  • D3D9Client_new_shader3.jpg
    D3D9Client_new_shader3.jpg
    1.4 MB · Views: 25
Last edited:

jedidia

shoemaker without legs
Addon Developer
Joined
Mar 19, 2008
Messages
10,842
Reaction score
2,105
Points
203
Location
between the planets
Say, is the specular power in the debug controls supposed to be the same as in the .msh? Because if I adjust it so it looks good, then save it in the .msh material, it doesn't seem to be the same result at all...
 

jedidia

shoemaker without legs
Addon Developer
Joined
Mar 19, 2008
Messages
10,842
Reaction score
2,105
Points
203
Location
between the planets
Following up on this because it's really bothering right now. Pretty sure it's not a bug but that I have some misconception and I'm doing something wrong, so a bit of clarification would be great.

The focus here is the aluminium foil. It's got a diffuse map, a narmal map and a roughness map, but no specular map, beause I figured it's uniform enough ot not need one, but then the specularity isn't quite as I expected it to work.

Here's what it looks like if I set a white specular color and a power of 2.5 in the (old) PBR shader:
1615024191828.png

This looks about the way I want it, so I set these properties (including all the others) in the material of the .msh file. But the result looks like this:
1615024079498.png

When I go to the debug controls to edit those materials, they are shown as loaded from the .msh file, but it looks like they are not applied. If I edit the specular power, the whole look immediately changes, and I can set it back to the old value (2.5) and the result is as it should be (i.e. different to what the material looked like when it loaded in). What am I missing here?

Here's the material definition from the .msh, if that is any help:
Code:
MATERIAL ThermalCoating
0.7 0.7 0.796 1
0.9 0.9 0.9 1
1 1 1 1 2.5
0 0 0 0

If I save the settings in debug control, this is produced:
Code:
CONFIG_VERSION 3
; =============================================
MESH space_station_pack\JunctionSquare
SHADER PBR-Old
; ---------------------------------------------
MATERIAL 12
SPECULAR 1.000000 1.000000 1.000000 2.500000

So the specular settings are identical. If I load the sim with the D3D9 cfg in place, everything works. But the problem is a bit that I would really like to have those materials applied by mesh, not by vessel, since the mesh might appear in multiple vessels.

Since reflectivity and roughness are both applied as intended, I guess the takeaway here is that if I want that, the PBR shader ignores the orbiter .msh settings and either takes the values from the cfg file or from the maps. Which would be a bit confusing, because it totally does respect the diffuse and ambient color settings. Is this intended behaviour?
 

4throck

Enthusiast !
Joined
Jun 19, 2008
Messages
3,502
Reaction score
1,008
Points
153
Location
Lisbon
Website
orbiterspaceport.blogspot.com
You should change your textures to use the values coming from the debugger. Convert the numbers to 0-255 and edit levels as needed...
This will make your textures the same across different meshes.

As I mentioned before, try with test meshes if needed. Texture with a gradient and check what values work.

Orbiter default material values need to remain compatible with the inline render. ;)
 
Top