New Release D3D9Client Development

Joined
Mar 23, 2008
Messages
165
Reaction score
0
Points
16
ERMAHGERD!

Looks fantastic! (Kills my framerate!)

Thank you Jarmonik! Now I really do need to upgrade the 'puter.

Cheers, W.E.
 

Kendo

New member
Joined
Oct 16, 2007
Messages
589
Reaction score
1
Points
0
I remember when I was testing out a couple of meshes I made a while ago, I found you can set the mesh Specular settings above 100. I was using around 160 to get a really pin pointed reflection from the Sun. But I guess you need to work on what we already have.
 

Donamy

Addon Developer
Addon Developer
Donator
Beta Tester
Joined
Oct 16, 2007
Messages
6,907
Reaction score
205
Points
138
Location
Cape
Hubble would be the perfect test model.
 

Felix24

Active member
Joined
May 13, 2010
Messages
245
Reaction score
95
Points
43
Hubble would be the perfect test model.

A thousand times yes.

Also, the Apollo command module, lunar module (the gold foil), the solar sail, the Space Shuttle radiators on the payload bay doors, and practically every ship that has a bit of glass for a window.

This is absolutely amazing.
 

Cras

Spring of Life!
Donator
Joined
Apr 13, 2011
Messages
2,215
Reaction score
0
Points
36
Location
Los Angeles
Website
www.youtube.com
I was just talking with someone about this, mainly reflections in the Shuttle's radiators.

Very cool.

I have a question, can something like 'planet shine' also be worked into this somehow. I would think that if you can get reflections and also a glow from the Earth, really could get something sweet. I dont know if that is too much for D3D9, I know D3D11 client hopes to have such things, as well as self shadowing and stuff.

But really, it is great, so great, what you guys are doing with these graphics clients.
 

Felix24

Active member
Joined
May 13, 2010
Messages
245
Reaction score
95
Points
43
I have a question, can something like 'planet shine' also be worked into this somehow. I would think that if you can get reflections and also a glow from the Earth, really could get something sweet. I dont know if that is too much for D3D9, I know D3D11 client hopes to have such things, as well as self shadowing and stuff.

This.

I have been dreaming about this from the very beginning when I discovered Orbiter. Currently the only way to simulate planet shine is to crank up the ambient light level, but the light from that is gray, and shines on all objects evenly (even the planets themselves), so it doesn't go away when in the earth's shadow.
 

Donamy

Addon Developer
Addon Developer
Donator
Beta Tester
Joined
Oct 16, 2007
Messages
6,907
Reaction score
205
Points
138
Location
Cape
A little testing.
 

Attachments

  • HSTreflect.jpg
    HSTreflect.jpg
    191.6 KB · Views: 160

Felix24

Active member
Joined
May 13, 2010
Messages
245
Reaction score
95
Points
43
In my opinion, environment maps should be able to be applied to any textured surface in the same way that normal maps can be added. There are many models that for certain reasons have very weak reflections, and others (like the XR-2) that have very strong ones. I suspect that it is because of some material definition within the mesh itself.

It would be nice to instead control the intensity of the environment map with a texture file (or just a single channel of one). This would allow many favorite older addons to have reflections added to them, just like adding normal maps.

For non-textured surfaces (windows, transparent things), there should be a way to apply an environment map to those, too. It might be safer to apply it across all meshes, so that every window or pane of glass has reflections, no matter if special textures have been designed for the addon. It seems that there is already some sort of reflection on glass, like on the XR-2, so this may already be in place.
 
Last edited:

Kendo

New member
Joined
Oct 16, 2007
Messages
589
Reaction score
1
Points
0
Not sure I like it yet. It will also need reflections from the Sun which of course we haven,t got yet. My ISS panels (with norms) have reflections from the Earth but they are normal everywhere else. Plus its a bit of a frame rate hit.
 

Felix24

Active member
Joined
May 13, 2010
Messages
245
Reaction score
95
Points
43
EDIT3: The so called "HDR" equation can be enabled from a pixel shaders, atleast for XR2 it will give a better results in some scenarios.

PHP:
if (gEnvMapEnable) {
        float3 s = 0;
        float  r = pow(saturate(smoothstep(0.0, 80.0, cSpe.a)), 2);  // Specular to reflection mapping
        float  b = (1.0-r)*0.04;  // blur
        float3 v = normalize(reflect(-CamW, nrmW));
        s += texCUBE(EnvMapS, v);
        s += texCUBE(EnvMapS, v+float3(b,b,0));
        s += texCUBE(EnvMapS, v+float3(0,b,b));
        s += texCUBE(EnvMapS, v+float3(b,0,b));
        spec += s*(r*0.25);
        //spec += s*r;
    }
    
    if (gUseEmis) diff += tex2D(EmisS, frg.tex0).rgb;

    // -------------------------------------------------------------------------
       float3 color  = cTex.rgb * saturate(diff) + saturate(spec);   // Standard lighting
    // float3 color = 1.0f - exp(-1.0f*(cTex.rgb*diff+spec));         // "HDR" lighting
    // -------------------------------------------------------------------------

I changed the code slightly, and now I get better results for the XR-2. It blends the environment map and the diffuse texture in a different way, and it forces a given level of environment map intensity, regardless of specular information within the mesh.

PHP:
    if (gEnvMapEnable) {
        float3 s = 0;
    //    float  r = pow(saturate(smoothstep(0.0, 80.0, cSpe.a)), 2); // Specular to reflection mapping
        float  r = pow(saturate(smoothstep(0.0, 80.0, 100.0)), 2); // Specular to reflection mapping, ignores "flag" in mesh
        float  b = (1.0-r)*0.04; // blur
        float3 v = normalize(reflect(-CamW, nrmW));
        s += texCUBE(EnvMapS, v);
        s += texCUBE(EnvMapS, v+float3(b,b,0));
        s += texCUBE(EnvMapS, v+float3(0,b,b));
        s += texCUBE(EnvMapS, v+float3(b,0,b));
        spec += s*(r*0.25);
    }
    
    if (gUseEmis) diff += tex2D(EmisS, frg.tex0).rgb;

    // -------------------------------------------------------------------------
    float3 tempColor = cTex.rgb * saturate(diff);
    float3 color = 0.2 * (saturate(spec) - tempColor) + tempColor;    // the multiplying factor 0.2 controls how
                                //    intense the reflection is; 0.0=matte, 1.0=mirror
    //    float3 color  = cTex.rgb * saturate(diff) + saturate(spec);        // Standard lighting
    //    float3 color = 1.0f - exp(-1.0f*(cTex.rgb*diff+spec));         // "HDR" lighting
    // -------------------------------------------------------------------------
Best results in orbit during daytime are obtained if the ambient light level is set relatively high, say around 50.

The XR-2 was taken with a multiplying factor of 0.2, with the mesh flag taken into account; hence there are no real reflections on the heatshield. I painted it bright red because the default texture has a more matte look to it.

The MPLM was taken with a multiplying factor of 0.7, with the mesh flag ignored. I'm not totally pleased with the MPLM and how my blending method darkens the diffuse texture where it is sunlit. It is because of the higher reflectivity acting more like a mirror to deep space rather than a diffuse texture.

This tweak changes behavior only if there is a normal map defined for the particular texture. I don't know why.
 

Attachments

  • Image9.jpg
    Image9.jpg
    257.8 KB · Views: 50
  • Image17.jpg
    Image17.jpg
    145.3 KB · Views: 67

jarmonik

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 28, 2008
Messages
2,666
Reaction score
795
Points
128
Here is a new Alpha with some changes and bug fixes.

PHP:
if (gEnvMapEnable) {
    float  r = pow(saturate(smoothstep(0.0, 80.0, cSpe.a)), 2);  // Specular to reflection mapping
    float3 v = reflect(-CamW, nrmW);
    float3 s = r * texCUBE(EnvMapS, v);
     //spec += cTex.rgb * cSpe.rgb * s;    // Modulate reflection with a Diffuse & Specular texture
    spec += cSpe.rgb * s;            // Modulate reflection with a Specular texture/material alone
}

When testing the XR2 better results are obtained if the reflection is modulated with a Diffuse texture.
 

Attachments

  • D3D9ClientAlpha2.zip
    596.3 KB · Views: 26

jarmonik

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 28, 2008
Messages
2,666
Reaction score
795
Points
128
In my opinion, environment maps should be able to be applied to any textured surface in the same way that normal maps can be added.... It would be nice to instead control the intensity of the environment map with a texture file (or just a single channel of one).

Environment map it self cannot be applied like normal maps because the env-map texture will change for every frame. We already have a specular map support in the client and it can be used to control the reflections in a per-pixel basis.

Currently specular map is a RGBA texture. Reflected image is multiplied by the rgb-color in s specular map and the alpha channel is containing a specular power for every pixel. This should allow to control how the image is reflected and it might be possible to do more metallic like reflections instead of a pure mirror like reflections.

I find it a difficult to create a textures where an alpha channel is containing some data so maybe we should consider an alternative ways to define the specular maps.

a) One channel texture (L8) that would modulate the reflected image but the color and power information would come from a meterial defination.

b) Dual channel texture (DXT1, U8V8). Red channel would modulate the reflection and green channel would modulate the specular power.

Then the question is how do we enable the environmental reflections ?
Would the reflections be enabled for a mesh group only if there is a specular map defined ?

---------- Post added at 14:26 ---------- Previous post was at 14:22 ----------

This tweak changes behavior only if there is a normal map defined for the particular texture. I don't know why.

There are different shaders for normal mapped and non-normal mapped meshes (NormalMap.fx and Mesh.fx) the tweaks must be applied in both files.
 

jarmonik

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 28, 2008
Messages
2,666
Reaction score
795
Points
128
There is also an other problem. If we have a specific instrument or a section in a space craft that is reflective then we should be able to place the environmental camera into the instrument or a section. We can have multible cameras and environmental maps for a vessel. Then how do we choose which one of the env-maps are used to render a specific mesh group ?

One possibility is an graphics client API. But since the graphics clients are licensed under the GPL, a non-GPL:ed application connot link into an GPL:ed client legally. If some one would do so then non of the current developper would care about it but someone might try to take an advantage of it, in the future. So, not very good choise unless we are able to change the license to LGPL or EPL to allow applications to legally link into it.

There is an other option through a configuration files. We could have a configuration file for a vessel class that would define the camera locations and the mesh groups those will receive an image from a defined cameras. It could be used to control what is visible in the env maps and what is not visible. That file could be useful for many other purposes as well.

Any thoughts about how should we continue ?

---------- Post added at 15:14 ---------- Previous post was at 14:54 ----------

I have added an experimental Earth "glow" effect in Mesh.fx, but the earth is glowing at the night time as well. Have to find an easy way to fix that. It will only effect in non-normal mapped meshes since, it is in Mesh.fx

PHP:
// Earth "glow" ------------------------------------------------------------
//float dota = -dot(gCameraPos, nrmW);
//float angl = saturate((dota-gProxySize)/(1.0f-gProxySize));
//outVS.diffuse += gAtmColor * pow(angl, 0.2) * 0.1;
 
Last edited:

DaveS

Addon Developer
Addon Developer
Donator
Beta Tester
Joined
Feb 4, 2008
Messages
9,434
Reaction score
689
Points
203
Suggestion for next version:
Change this in Particle.fx:
Code:
ParticleVS ParticleDiffuseVS(NTVERTEX vrt)
{
	ParticleVS outVS = (ParticleVS)0;
	outVS.tex0    = vrt.tex0;
    outVS.light   = saturate(dot(-gSun.direction, vrt.nrmL)) + 0.2f;
	outVS.posH    = mul(float4(vrt.posL, 1.0f), gVP);
    return outVS;
}

to
Code:
ParticleVS ParticleDiffuseVS(NTVERTEX vrt)
{
	ParticleVS outVS = (ParticleVS)0;
	outVS.tex0    = vrt.tex0;
    outVS.light   = saturate(dot(-gSun.direction, vrt.nrmL)) + 0.6f;
	outVS.posH    = mul(float4(vrt.posL, 1.0f), gVP);
    return outVS;
}
This will make white PSTREAMs appear white without having to resort to using emissive PSTREAMs which I consider cheating. With it set to the default 0.2, they appear grey even in direct sunlight.
 

Face

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 18, 2008
Messages
4,403
Reaction score
581
Points
153
Location
Vienna
There is also an other problem. If we have a specific instrument or a section in a space craft that is reflective then we should be able to place the environmental camera into the instrument or a section. We can have multible cameras and environmental maps for a vessel. Then how do we choose which one of the env-maps are used to render a specific mesh group ?

One possibility is an graphics client API. But since the graphics clients are licensed under the GPL, a non-GPL:ed application connot link into an GPL:ed client legally. If some one would do so then non of the current developper would care about it but someone might try to take an advantage of it, in the future. So, not very good choise unless we are able to change the license to LGPL or EPL to allow applications to legally link into it.

You are indeed right that a link would need applications to be GPL'ed too. I do not understand what you mean with "take an advantage", though. If a developer uses the library without using GPL (or a compatible license), then it is him who takes advantage, not someone complaining later on. Everybody using open-source should get it that it is not necessarily free as in beer, but free as in speech.

OTOH, there is of course a way to change the license to a "lesser" GPL or to simply add a linking exception: all contributors have to agree to do so, and from that moment on the license is changed (for releases from that point on). As I see it, Martin would be the first to ask, as the D3D7Client code was started by him and could be argued to be the base for all of the OVP clients.

It is not so much about the implication of a so-called viral license model, but about respecting the decision and perspective of the author(s) you based your work on. If somebody releases his code with GPL, he normally wants that users of the code show their work under the same conditions. To me this is the only way to justify open source at all: although others can benefit from my work in terms of computing, they can not benefit from it in terms of greed.

There is an other option through a configuration files. We could have a configuration file for a vessel class that would define the camera locations and the mesh groups those will receive an image from a defined cameras. It could be used to control what is visible in the env maps and what is not visible. That file could be useful for many other purposes as well.

Any thoughts about how should we continue ?

What about putting additional lines into the mesh file? E.g. put an optional element "ENVIRONMENTCAM <pos> <dir> <FOV>" into the mesh group section and parse it accordingly. I've tested and found that Orbiter's default parser simply ignores it, at least in 2010P1.

my :2cents:
 

kuddel

Donator
Donator
Joined
Apr 1, 2008
Messages
2,064
Reaction score
507
Points
113
current SVN (r23345) not working with Orbiter BETA?

Hi jarmonik,

I've just updated my working-copy and it seems that your recent commits seem to break the Client for Orbiter BETA (r20).
Here my observations:
If I build if for Orbiter 101030 and enable the 'envionment mapping' in the advanced dialog, everything seems to be O.K. (it seems that my Graphic Card can not hande 'environment mapping, but that' another issue[1])
If however I build it for Orbiter BETA (r20) and enable the 'envionment mapping' in the advanced dialog, the screen is completely black! Independent of the view (outside, cockpit, VC,...). When I disable the 'envionment mapping' in the advanced dialog, it works again.

Any hints, tips?

/Kuddel

[1] ..when enabeling 'env. mapping' in the DebugControl Dialog, I only see a "cross" showing the reflections ;) But as I said, that's another issue.
 

fausto

FOI SuperMod
Joined
Jul 13, 2008
Messages
797
Reaction score
2
Points
0
Location
Monza (Milan)
Good news for Antares capsule! Now bmp textures substitution and GET display work nicely!
Last thing: I have a little problem with heat shield incandescence effect.. I basically create a new mesh and I work on transparency to have a variable emissive texture, in order to simulate high temperature. This is my code:

Code:
if(GetDynPressure()>=1000&&GetAltitude()>14901&&GetAltitude()<100000){ SetMeshVisibilityMode (InsertMesh (hHeatshield,8, &offsetHS),MESHVIS_EXTERNAL);oapiBlt(tex3,HS_srf2,0,0, 0,0,128,128); //nota 1 
oapiSetMeshProperty (hHeatshield,MESHPROPERTY_MODULATEMATALPHA,1);//nota 2
MATERIAL *mat = oapiMeshMaterial (hHeatshield, 0);
mat->diffuse.a = alpha;
mat->ambient.a = alpha;
mat->specular.a = alpha;
mat->emissive.a = alpha;}

.. but I get no effects on transparency.. My goal is to create what you can see in this video at 9:32


any suggestion?
 
Top