New Release D3D9Client Development

kuddel

Donator
Donator
Joined
Apr 1, 2008
Messages
2,064
Reaction score
507
Points
113
...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

Active member
Joined
May 13, 2010
Messages
136
Reaction score
80
Points
43
Location
Germany
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.
Zwischenablage04.jpg
 

N_Molson

Addon Developer
Addon Developer
Donator
Joined
Mar 5, 2010
Messages
9,271
Reaction score
3,244
Points
203
Location
Toulouse
"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
Addon Developer
Beta Tester
Joined
Mar 28, 2008
Messages
2,651
Reaction score
785
Points
128
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 ---->
 

jarmonik

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 28, 2008
Messages
2,651
Reaction score
785
Points
128
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

Addon Developer
Addon Developer
Donator
Beta Tester
Joined
Feb 4, 2008
Messages
9,429
Reaction score
680
Points
203
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
Addon Developer
Beta Tester
Joined
Mar 28, 2008
Messages
2,651
Reaction score
785
Points
128
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

Addon Developer
Addon Developer
Donator
Joined
Mar 5, 2010
Messages
9,271
Reaction score
3,244
Points
203
Location
Toulouse
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.

AlphaBug_05.jpg
 

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
That is a very nice tree.
 

jarmonik

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 28, 2008
Messages
2,651
Reaction score
785
Points
128
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.
 

OvalDreamX

Active member
Joined
Sep 16, 2019
Messages
85
Reaction score
164
Points
33
Location
Bariloche, Patagonia Argentina
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

Addon Developer
Addon Developer
Donator
Beta Tester
Joined
Feb 4, 2008
Messages
9,429
Reaction score
680
Points
203
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

Active member
Joined
Sep 16, 2019
Messages
85
Reaction score
164
Points
33
Location
Bariloche, Patagonia Argentina
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

Addon Developer
Addon Developer
Donator
Beta Tester
Joined
Feb 4, 2008
Messages
9,429
Reaction score
680
Points
203
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

Active member
Joined
Sep 16, 2019
Messages
85
Reaction score
164
Points
33
Location
Bariloche, Patagonia Argentina
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!
 

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
What causes this artefact at low sun angles?

This is with R1346 for Orbiter Beta.

1662174274807.png
 
Top