# New ReleaseD3D9Client Development

#### N_Molson

Donator
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

Beta Tester
There is a new Beta (4.12) of the D3D9Client published.

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)

• Specular Map "*_spec.dds"
• Reflection Map "*_refl.dds"

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
69.4 KB · Views: 275
• s2.jpg
71.7 KB · Views: 33
Last edited:

#### DaveS

##### Space Shuttle Ultra Project co-developer
Donator
Beta Tester
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

1 MB · Views: 26
Last edited:

#### jedidia

##### shoemaker without legs
Normal Map (Tested OK)
Soooo... what's the filename convention for those?

#### DaveS

##### Space Shuttle Ultra Project co-developer
Donator
Beta Tester
Soooo... what's the filename convention for those?
They have the suffix _norm.

#### N_Molson

Donator
That Tianwen looks much better !!

#### Marg

##### Active member
Local light shadows would be good...

#### jedidia

##### shoemaker without legs
PBR shader is awesome, makes it a lot easier to use free texture libraries for some stuff:

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.

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
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

#### Attachments

• paint.NET.png
9.3 KB · Views: 9
• reset.png
332 bytes · Views: 7
Last edited:

#### jarmonik

Beta Tester
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

Tutorial Publisher
Donator
Here's another good example of reflecting space:

#### 4throck

##### Enthusiast !
It should reflect the full scene. As you can see on the Apollo photo above, it reflects the Moon, the LM and black space.

#### jarmonik

Beta Tester
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

Beta Tester
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

##### Space Shuttle Ultra Project co-developer
Donator
Beta Tester
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

1.6 MB · Views: 14

#### jarmonik

Beta Tester
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

##### Space Shuttle Ultra Project co-developer
Donator
Beta Tester
It looks alright to me. Here's the D3D9Client GC file:

Code:
CONFIG_VERSION 3
; =============================================
MESH SSU/Orbiter
; ---------------------------------------------
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

1.4 MB · Views: 19
Last edited:

#### jedidia

##### shoemaker without legs
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
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:

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:

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
; ---------------------------------------------
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 !
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.