# New ReleaseD3D9Client Development

#### kuddel

##### Donator
Donator
...and: shure cubic interpolation takes more resouces than linear interpolation.
The interpolation is basically a way to "guess" the values between two set/known values. Linear interpolation just simply applies a linear transition between two values. While cubic interpolation looks a bit more into other points and tries to get a more smooth transition. Especially on "sharp edges" it gets nicer smoother curves - but, as said at a cost.

Here are some links (if you like):

Or a nice video might also give you a grip on what I was talking about

#### Jordan

##### Member
I had the same transparency problems. The solution was to place the meshes with transparent parts at the end of the scenery. In the meshes themselves, the transparent groups should also be placed last in the mesh.

Here is an example. You can't see the VAB in the transparent textures.

#### N_Molson

Donator
"cubic" should be "smoother", but if "linear" works better for you, go for it!

I think the D3D9 Client flattening feature doesn't work with "cubic interpolation".

#### jarmonik

##### Well-known member
Orbiter Contributor
Beta Tester
Now the tree itself has alpha problems. The "plates" that make the foliage seem in some case to conflict each other / are not drawn in the correct order :

Those indeed are drawing order issues, however, there is one special case in transparency, if one bit transparency is used then it should be possible to remove the drawing order problem by clipping the pixel entirely (no depth buffer write). We could add "one-bit-alpha" mesh group flag to deal with the issue. (should work with shadows as well)

You can test the idea by adding a line in PBR.fx file, but this will of course create some other problems since the clipping is always on:
If you have additional texture maps in used like normal-map (with the model) then the line should be added to "PBR_PS" and "MetalnessPS" as well.

Code:
float4 FAST_PS(float4 sc : VPOS, FASTData frg) : COLOR
{

float3 cEmis;
float4 cDiff;
float3 cDiffLocal;
float3 cSpecLocal;

// Start fetching texture data -------------------------------------------
//
if (gTextured) cDiff = tex2D(WrapS, frg.tex0.xy);
else           cDiff = 1;

if (cDiff.a < 0.5f) clip(-1);     //  <---- Add this line to test ---->

#### N_Molson

Donator
Thanks for the reply @jarmonik , I followed your suggestion. Still no luck I fear (the DG is still behind the tree) :

#### jarmonik

##### Well-known member
Orbiter Contributor
Beta Tester
Thanks for the reply @jarmonik , I followed your suggestion. Still no luck I fear (the DG is still behind the tree) :

It should work or is there something I have overlooked ?? I don't have a tree so can't test it. It might be good idea to check that the tree really goes through the shader being modified. You can test it by adding the following line in the shader. It should turn everything red that goes through it. You should have red tree.

Code:
float4 FAST_PS(float4 sc : VPOS, FASTData frg) : COLOR
{
return float4(1, 0, 0, 1);   // <-- add this -->

#### DaveS

##### Space Shuttle Ultra Project co-developer
Donator
Beta Tester
It should work or is there something I have overlooked ?? I don't have a tree so can't test it. It might be good idea to check that the tree really goes through the shader being modified. You can test it by adding the following line in the shader. It should turn everything red that goes through it. You should have red tree.

Code:
float4 FAST_PS(float4 sc : VPOS, FASTData frg) : COLOR
{
return float4(1, 0, 0, 1);   // <-- add this -->
I think I have an explanation for this, after looking at the code you posted earlier. The code you posted, deals with alpha levels used by materials which is all well and good but if I have understood N_Molson right, his tree uses texture alpha, not material alpha. So the branches are essentially textured 2D planes with the empty areas blanked out using an alpha layer in the texture.

Last edited:

#### jarmonik

##### Well-known member
Orbiter Contributor
Beta Tester
I think I have an explanation for this, after looking at the code you posted earlier. The code you posted, deals with alpha levels used by materials which is all well and good but if I have understood N_Molson right, his tree uses texture alpha, not material alpha. So the branches are essentially textured 2D planes with the empty areas blanked out using an alpha layer in the texture.
That's not the case. Material alpha is called "gMtrlAlpha". "cDiff.a" is a texture alpha and it's sampled just 3 lines earlier in the code.

#### N_Molson

Donator
Good news, it seems I forgot to check the "sort meshgroups by name" option in the exporter. So, with the foilage being the last meshgroup and the code fix provided by @jarmonik , it is much better ! 1) The DG is now correctly rendered 2) the "foilage plates" have stopped conflicting each others. The only thing is the shadow, but after all we can remove it completely by deleting "SHADOW" in the config file.

#### n72.75

Tutorial Publisher
Donator
That is a very nice tree.

#### N_Molson

Donator
Soon only in Orbiter, given how those are burning in France and the whole mediterranean basin ? ??

#### jarmonik

##### Well-known member
Orbiter Contributor
Beta Tester
The only thing is the shadow, but after all we can remove it completely by deleting "SHADOW" in the config file.
It should be possible to get the shadow appear right as well but it requires more then just one line.

#### 4throck

##### Enthusiast !
I like the tree. This old add-on might be useful to place them:

#### OvalDreamX

##### Member
Anyone knows whats the suffix d3d9 looks for when searching for metalness map? I guess the Metalness PBR has support for those kinds of maps, right? Maybe a short list of the suffixxes (_norm, _rghn, etc) the new Metalness PBR shader uses would be useful until we get an updated Doc

#### DaveS

##### Space Shuttle Ultra Project co-developer
Donator
Beta Tester
The Metalness shader makes use of only two additional textures, which is _metal and _rghn. The _rghn texture defines the roughness in an inverted way, in that the closer to pure white (255) something is the rougher it is. So for something ultra-smooth you want it close to pure black (0) rather than pure white (255).

#### OvalDreamX

##### Member
The Metalness shader makes use of only two additional textures, which is _metal and _rghn. The _rghn texture defines the roughness in an inverted way, in that the closer to pure white (255) something is the rougher it is. So for something ultra-smooth you want it close to pure black (0) rather than pure white (255).
Great! Thanks! And is there any way of setting the Metalness PBR shader as the default for a mesh? Or every user has to change it upon install?

#### DaveS

##### Space Shuttle Ultra Project co-developer
Donator
Beta Tester
Great! Thanks! And is there any way of setting the Metalness PBR shader as the default for a mesh? Or every user has to change it upon install?
Ctrl-F4, select D3D9 Debug Controls. Then click on any part of the mesh and make sure "Default Shader" is set to Metalness PBR. Then you will have to go through the mesh to make sure each separate material is set properly. Once you are done, click the "Save" button, this will create .cfg file in Config\GC\ that has the class name of the vessel that you will have to include with the actual download package.

#### OvalDreamX

##### Member
Ctrl-F4, select D3D9 Debug Controls. Then click on any part of the mesh and make sure "Default Shader" is set to Metalness PBR. Then you will have to go through the mesh to make sure each separate material is set properly. Once you are done, click the "Save" button, this will create .cfg file in Config\GC\ that has the class name of the vessel that you will have to include with the actual download package.
So if I include that cfg file with my mod, itll be activated by default? Nice, tnxs!

#### DaveS

##### Space Shuttle Ultra Project co-developer
Donator
Beta Tester
So if I include that cfg file with my mod, itll be activated by default? Nice, tnxs!
Yes.

#### n72.75

Tutorial Publisher
Donator
What causes this artefact at low sun angles?

This is with R1346 for Orbiter Beta.

Replies
2
Views
303
Replies
1
Views
127
Replies
3
Views
758
Replies
180
Views
4K