# New ReleaseD3D9Client Development

#### Ripley

##### Tutorial translator
Donator
Hey Ripley,

could you please try this one? I've added filling the render area with black background first...
Ok, thanks. That did it.

#### Felix24

##### Active member
Will there be any way to control the .refl roughness separately from the specular power? I feel this is important because otherwise you can't have metallic paint with a glossy finish. It would end up looking either metallic and flat, or non-metallic and glossy. There should be a way to use a low specular power (wide specular highlight) with mirror smoothness.

#### jarmonik

##### Well-known member
Orbiter Contributor
Beta Tester
Though the two things to change now would be to boost the intensity of the sun light so it's brighter than the atmosphere; right now with the tonemapping the ships look dull and washed out compared to the atmosphere below. That should go for the star billboard texture as well. Now that we have a way higher dynamic range, we shouldn't be afraid to use it. Tonemapping and exposure adaptation will take care of displaying the scene under a [0,1] range.
EDIT: Actually, that should also go for all emissive materials as well. Exhausts and emissive particle systems also look washed but once properly lighted they'll shine back again.

The sun intensity for meshes is already added there "#define fSunIntensity 1.0".

Speaking of adapration, my idea of a local average kinda failed as the 4x4 mipmap wasn't behaving the way I expected; I'd have thought mipmapping would average the values, but there's some kind of weighting being done that emphasizes the center pixel from what I see, and that in turn gives weird results. So I resorted to a geometric mean but with the 4x4 mipmap and that weird emphasizing it's still behaving weirdly.
So my question is, would a 1x1 mipmap be an average of the whole image? If yes, then could you change that for it?

Eye adaption would need to be an integral of light received by eye during the past few minutes. How an average value of back-buffer would be any use ?

#### SolarLiner

##### It's necessary, TARS.
The sun intensity for meshes is already added there "#define fSunIntensity 1.0".

Must have missed that line. Let's see what it does.

Eye adaption would need to be an integral of light received by eye during the past few minutes. How an average value of back-buffer would be any use ?

That would be for proper eye adaptation with progressive exposure correction. Here it we only consider one frame, which might not be the best for motion under such a great contrast, but for now it'll be better than nothing.

#### jarmonik

##### Well-known member
Orbiter Contributor
Beta Tester
Will there be any way to control the .refl roughness separately from the specular power?

They are one and the same thing. But you are talking about dual layer material with different properties. The glossy finish is a Fresnel reflection and it should be possible to have it in basic shader otherwise a material like that would need to be sent to some other shader for rendering.

I suppose a Fresnel map could be a solution containing roughness and some other parameters. Could a Fresnel map replace specular map ?

I really haven't had time to focus in details between PBR, HDR, post-processing and local lights sources re-implementations going at the same time.

---------- Post added at 11:10 ---------- Previous post was at 11:03 ----------

That would be for proper eye adaptation with progressive exposure correction. Here it we only consider one frame, which might not be the best for motion under such a great contrast, but for now it'll be better than nothing.

I'll make it to 1x1 then. I already made some quick experiments with integration but there were some stability problems.

#### Abloheet

I recently installed d3d9 testbuild 6. Since I didn't like it's features, I then downloaded the latest general build of the client and installed it on top of test build 6. Now, the graphics is back to normal, but, why is the deltaglider's wings so shiny? As if environment reflection has been enabled for them? How is that possible? Or is it a new feature of the latest general build?

---------- Post added at 10:39 PM ---------- Previous post was at 10:36 PM ----------

These shiny wings and exhaust nozzles weren't there in test build 6. They are present now.

---------- Post added at 10:40 PM ---------- Previous post was at 10:39 PM ----------

Only the wings are shiny? Why? Why not the full body of the deltaglider's?

#### kuddel

##### Donator
Donator
Hi Abloheet,

maybe you still have some configurations left in "Config\GC" folder?
I would recommend to delete (or backup) all files in that folder and copy the original files from the D3D9Client ZIP into it.

#### T1234

##### New member
I recently installed d3d9 testbuild 6. Since I didn't like it's features, I then downloaded the latest general build of the client and installed it on top of test build 6. Now, the graphics is back to normal, but, why is the deltaglider's wings so shiny? As if environment reflection has been enabled for them? How is that possible? Or is it a new feature of the latest general build?

---------- Post added at 10:39 PM ---------- Previous post was at 10:36 PM ----------

These shiny wings and exhaust nozzles weren't there in test build 6. They are present now.

---------- Post added at 10:40 PM ---------- Previous post was at 10:39 PM ----------

Only the wings are shiny? Why? Why not the full body of the deltaglider's?

The reflectivity is to reflect exessive radiation away keeping the ship cooler as a realistic concept. It can be increased or reduced in d3d9 debug controls with the reflection paramiter,select group and pick the mesh you want to change.

#### Abloheet

Well, the whole deltaglider could be made shiny like it's wings and nozzles. The shininess doesn't look bad. Infact, it looks quite cool. I would be happy if it can be replicated for other vessels too

#### Felix24

##### Active member
The glossy finish is a Fresnel reflection and it should be possible to have it in basic shader otherwise a material like that would need to be sent to some other shader for rendering.

Fresnel reflections do not have any roughness, at least at low viewing angles. There's probably a way to make the roughness match the normal reflection at high angles and then transition to no roughness at low angles, but that would take away the control I'm trying to achieve, which is the ability to simulate a dual-layer material. Here's some code I tweaked to make sure the Fresnel reflection is always sharp, separate from the ordinary reflection which can have roughness.

Code:
#if defined(_ENVMAP)
if (gEnvMapEnable) {

// Compute LOD level for blur effect
float fLOD = (1.0f - fRghn) * 5.0f;

// Get reflection with roughness parameter
float3 cEnv = texCUBElod(EnvMapAS, float4(RflW, fLOD)).rgb;

// Get mirror reflection for fresnel
float3 cEnvFres = texCUBElod(EnvMapAS, float4(RflW, 0)).rgb;

// Compute a fresnel term
float fFrsl = gMtrl.fresnel.y * pow(abs(1.0f - dCN), gMtrl.fresnel.z);

// Compute material reflectivity
float fRefl = cmax(cRefl);

// Compute reflection
cRefl.rgb *= cEnv;

// Compute total reflected light with fresnel reflection
cRefl.rgb = any(cRefl)*fFrsl*cEnvFres*(1.0f - cRefl) + cRefl;

// Accummulate in cSpec
cSpec.rgb += cRefl.rgb;

// Intensity of reflected light
float fInt = dot(cSpec.rgb, cLuminosity);
//float fInt = cmax(cTotal);

// Attennuate diffuse surface
cTex.rgb *= (1.0f - fRefl) * saturate(1.0f - fInt);

// Re-compute output alpha for alpha blending stage
cTex.a = saturate(cTex.a + fInt);
}

#endif

#### SolarLiner

##### It's necessary, TARS.
Speaking of adapration, my idea of a local average kinda failed as the 4x4 mipmap wasn't behaving the way I expected; I'd have thought mipmapping would average the values, but there's some kind of weighting being done that emphasizes the center pixel from what I see, and that in turn gives weird results. So I resorted to a geometric mean but with the 4x4 mipmap and that weird emphasizing it's still behaving weirdly.
So my question is, would a 1x1 mipmap be an average of the whole image? If yes, then could you change that for it?

Well... Rookie mistake here.
So a proper implementation of an adaptation would need a luminance map, which is usually very small (hence the 4x4 mipmap of the backbuffer). But that needs to be desaturated, and we need the log of that saturation, instead of directly using it.
How I could have gone through all of it and not see the ovbious is making me go :facepalm: ...

But now I assume it'll behave much better now than previously.

#### Cras

##### Spring of Life!
Donator
in the R16-5 build of the client for 2010p1 there is a definite performance degradation with prolonged use of external MFDs. Seen it take a frame rate of 400+ and eventually bring it down to the 30s. Only shows up after very long sessions, first showed up for me when doing a fly around after undocking from a space station so I had two MFDs (Pursuit and RPOP) open for quite some time .

There is an immediate drop in performance upon opening the MFDs which is to be expected, but after time the degradation becomes very severe and can be seen early on even when rotating the camera around the spacecraft in an external view, the camera moves appear jerky, lacking the smoothness you would expect from a high frame rate, even before it hits a critical point where the frame rate drops below the refresh rate of the display.

#### Felix24

##### Active member
Will there be an easy way to disable HDR? I'm asking because that was the single biggest turn-off for me for the D3D11 client- it was implemented very poorly, and there was no way to disable it.

Is exposure compensation applied selectively to very bright and dim objects, or is it applied to the whole screen all at one time? I don't want the exposure compensation to wash out contrast and detail in any part of the image. HDR photography is meant to bring out detail, but too often HDR in simulations does the opposite, looking more like viewing the world through a cheap CCTV camera.

IRL,the eye-brain system builds a virtual scene within the mind by combining snapshots of very different brightness levels into one idea so that nothing seems washed out and everything has lots of detail. The eye adjusts so quickly when scanning the surroundings, that it's hard to notice just how much brighter a computer screen is than a piece of paper. It's true that the eye has a much larger dynamic range, but it still adjusts so that the center of vision is in the "sweet spot" level of brightness.

If we had eye tracking, we could link the eye gaze to the exposure control, so that the exposure would compensate if I was looking at something bright or dim.

#### kuddel

##### Donator
Donator
Cras, are you using the "default" External MFD or the "DX9ExtMFD" version?
IIRC the "DX9ExtMFD" was made by Jarmo exactly to counter the FPS drops

P.S.: Don't ask me where to get the "DX9ExtMFD.dll", it has been posted somewhere in the forum I think

#### Cras

##### Spring of Life!
Donator
Yeah I recall the problem being excessive a few builds ago and that the Dx9extmod did help. When I updated to the latest build I do see the new module there and I used it. Perhaps I do not have the newest one? I will look around and see if it is posted elsewhere, see if there is a different version of it

Donator
Last edited:

#### Cras

##### Spring of Life!
Donator
Has it? Isn't it directly included in the builds?
(I can't check by myself right now)

I had thought it was myself

#### Ripley

##### Tutorial translator
Donator
In the first post of this thread there is an attachment called D3D9goodies. Inside it, there is a source folder with what we are looking for.
I don't know if it was attached somewhere else in a dll form (Edit: of course it was, since I have never compiled it myself).

Wishlist: include it in the next releases please.

---------- Post added at 11:19 ---------- Previous post was at 09:01 ----------

Found another bit:
...However, running the Map MFD in DX9ExtMFD window (Included in Beta 6 package)...

DLL is attached in post #3003.

Last edited:

#### jarmonik

##### Well-known member
Orbiter Contributor
Beta Tester
Beta 23.7 for rev. 55

Here is a new beta for testing. I am hoping to copy the current changes in this beta to the trunk, so, it would need to be tested pretty well.

So, what new:

- PBR should be mostly operational now, we should still look if we could include a second roughness value for fresnel/specular reflection like suggested earlier.
- There are some shader and local light-sources optimizations done via light cone/bounding sphere checks.
- Some new information has been added to statistics "Ctrl+Shift+C". Looks like the current renderer is heavily GPU limited, the CPU is idling and waiting the GPU to catch up most of the time (50-80%).
- Light-blur post processing effect exists (disabled by default) that should make specular highlights to "glow".
- Specular color range is expanded to (0.0 - 3.0) to provide better compatibility with existing models and more flexible control.

I'll look into the HDR stuff next.

#### Attachments

• D3D9ClientBeta23_7-forRev55.zip
1.8 MB · Views: 26

#### jarmonik

##### Well-known member
Orbiter Contributor
Beta Tester
Fresnel reflections do not have any roughness, at least at low viewing angles. There's probably a way to make the roughness match the normal reflection at high angles and then transition to no roughness at low angles, but that would take away the control I'm trying to achieve, which is the ability to simulate a dual-layer material. Here's some code I tweaked to make sure the Fresnel reflection is always sharp, separate from the ordinary reflection which can have roughness.

Thanks, I have included the code in the build. I suppose we could have a second roughness value if needed. At least if I look at my mouse which is made from black plastics it shows pretty blurry fresnel reflection.

---------- Post added at 13:10 ---------- Previous post was at 13:01 ----------

in the R16-5 build of the client for 2010p1 there is a definite performance degradation with prolonged use of external MFDs. Seen it take a frame rate of 400+ and eventually bring it down to the 30s. Only shows up after very long sessions, first showed up for me when doing a fly around after undocking from a space station so I had two MFDs (Pursuit and RPOP) open for quite some time.

I made two hours long test run at LEO at 10x acceleration and I experienced a frame rate drop form 1200 fps to 600 fps. It looks like surface tiles aren't unloaded from memory after they become obsolete. In my case there was 200MB of unnecessary tiles loaded, not a problem really but with a high resolution textures installed it could become a problem. I'll try to find some time to fix it. No other problems detected. 200MB of textures shouldn't cause a framerate impact so the exact reason remains unknown. The framerate was restored after restarting the scenario.

Replies
2
Views
226
Replies
1
Views
49
Replies
3
Views
703
Replies
15
Views
1K
Replies
30
Views
4K