New Release D3D9Client Development

My feeling is that you should be seeing the effect more than that.

The clouds in your screenshot look very blurry at that angle. That could be the cause, but I'm not sure. What is your altitude and FOV? Also, can you enable planetarium mode so that I have more visual cues.
FoV: 60°
Altitude: 76.2 km
 

Attachments

  • No_cloud_normal_maps2.jpg
    No_cloud_normal_maps2.jpg
    144 KB · Views: 27
Dude, this is awesome!


clouds2.jpg


Yes, this is really awesome !
:thumbup:

---------- Post added at 02:53 ---------- Previous post was at 02:42 ----------

My question is : Do we need manually edit elevation tiles (hard work) or does exist a fix trough parameters (d3d9 client or nvidia driver...) ?


We are aware of some caps appearing between the tiles. Some places are more sensitive to caps than others, there are no known fix for that right now. Manually editing something is unlikely going to work. Since it's a minor cosmetic issue, I'll look into it when doing some other upgrades to the elevation, there are some other issues too with the elevation that would need to be solved.
 
FoV: 60°
Altitude: 76.2 km

I think the clouds look flat in that situation because the cloud bumps become really visible only when the sun is less than ~20 degrees above the horizon, and in the screenshot, the sun is closer to 45 degrees.

That, coupled with the relatively low altitude and the resolution of the cloud textures, I think this is a situation where microtextures are the only real solution. I'm experimenting with microtextures right now.
 
Dude, this is awesome!

clouds1.jpg

clouds2.jpg

clouds4.jpg


I was able to make it visible away from the terminator. Try this code in Surface.fx, starting at line 1079:
PHP:
        float dCS = dot(nrm, vSunDir);            // Cloud normal sun angle        //float dMN = dot(frg.nrmW, vSunDir);    // Planet mean normal sun angle                // increase brightness of sun illumination with low sun angle, twice is nicer        // Lambertian looks dull, this looks better        dCS = saturate((dCS * (1.0f -dCS)) + dCS); // new        dCS = saturate((dCS * (1.0f -dCS)) + dCS); // new        // Effect of normal/sun angle to color        // Add some brightness (borrowing red channel from sunset attenuation)        // Adding it to the sun illumination factor, taking care to keep from saturating        cTex.rgb *= (0.2f * frg.atten.r) + (0.8f * dCS); // new    }#endif#if defined(_CLOUDMICRO)        float f = cTex.a;        float g = lerp(1, cMic.a, frg.fade.y);        float h = (g + 4.0f)*0.2f;        cTex.a = saturate(lerp(g, h, f) * f);#endif    // make the light falloff to be grayscale; to me, cloud tops look better this way than colored    // borrow the red channel because it penetrates farther through atmosphere    // multiply it by 3 to keep it brighter closer to the terminator    float3 color = cTex.rgb*saturate(frg.atten.r*3)*fCloudInts + frg.insca.rgb*vHazeMax; // new    return float4(saturate(color + a), cTex.a*saturate(fCloudInts*fCloudInts));    //return float4(saturate(color + a), cTex.a*saturate(frg.fade.x*fCloudInts*fCloudInts));}




How do you get that beautiful 3D clouds effect?
 
@Jarmonik: We should make Felix' CloudTechPS the default one shouldn't we?
 
Would it be possible to implement a random cloud generator? That would eliminate these ugly things(the seams in the cloud layer texture):
 

Attachments

  • cloud_layer_seam.jpg
    cloud_layer_seam.jpg
    112.9 KB · Views: 26
Would it be possible to implement a random cloud generator?

That would be non-trivial, and I think that's quite an understatement... It would take quite some effort to make them look half as good as high-resolution satelite imagery. Maybe Artlav still has some code lying about...?
In any case, I'm not familiar with the clients architecture. It might take some major rearranging to stream the data in there. If it's getting the data from orbiter itself (which I assume it does, no point in forcing graphics clients to re-implement the whole file-streaming mess), it might even get pretty hacky...
 
That would be non-trivial, and I think that's quite an understatement... It would take quite some effort to make them look half as good as high-resolution satelite imagery. Maybe Artlav still has some code lying about...?
In any case, I'm not familiar with the clients architecture. It might take some major rearranging to stream the data in there. If it's getting the data from orbiter itself (which I assume it does, no point in forcing graphics clients to re-implement the whole file-streaming mess), it might even get pretty hacky...
kuddel did link to this earlier when clouds were being discussed: https://www.orbiter-forum.com/showthread.php?p=605539&postcount=5172
 
kuddel did link to this earlier when clouds were being discussed: https://www.orbiter-forum.com/showthread.php?p=605539&postcount=5172


I did look into that but I don't remember the details nothing that would really solve anything. What kind of cloud rendering policy should we have ? There are three main conditions:
1) How the clouds looks when standing at sea level.
2) How the clouds looks when flying near them (slightly above/below)
3) And how do they look when viewed from Orbit.

Should we focus on orbital rendering and forget the rest. Most computer games only deal with cases 1 & 2. And most topics/publications regarding cloud rendering are about those two cases.

When comparing Orbiter clouds to many photographs they are pretty good when the sun angle is high.

Combined cloud visual image and altimeter data (in pixel basis) would be useful but I highly doubt that any exists.
 
Wouldn't cases 1 and 2 take care of case 3 given their 3D nature? Clouds are never flat like we have them right now, they always have a thickness to them as they're measured by their bases and tops.
 
Try this updated CloudTechPS (goes in Surface.fx, replacing lines 1034-1102 of the original), and don't forget to download the updated cloud microtextures zip file below the screenshots.

This is not perfect- see the artifacts in the last screenshot.

Reset your atmospheric parameters or else it won't look like the other screenshots.

Thanks to Jarmonik for adding this capability and for pointing out the section of code to play with.

PHP:
float4 CloudTechPS(CloudVS frg) : COLOR
{
	float2 vUVMic = frg.texUV.xy * vMicroOff.zw + vMicroOff.xy;
	float2 vUVTex = frg.texUV.xy;

	float a = (tex2Dlod(NoiseTexS, float4(vUVTex,0,0)).r - 0.5f) * ATMNOISE;

	float4 cTex = tex2D(DiffTexS, vUVTex);
	float4 cMic = tex2D(CloudMicroS, vUVMic);

#if defined(_CLOUDNORMALS)

	if (bCloudNorm) {

#if defined(_CLOUDMICRO)
		float4 cMicNorm = tex2D(CloudMicroNormS, vUVMic);  // Filename "cloud1_norm.dds" (does not exists in distribution)
#endif

		// Filter width
		float d = 2.0 / 512.0;
		float3 nrm = 0;
		float3 nrmMicro = 0;

		float x1 = tex2D(DiffTexS, vUVTex + float2(-d, 0)).a;
		float x2 = tex2D(DiffTexS, vUVTex + float2(+d, 0)).a;
		nrm.x = (x1*x1 - x2*x2);

		float y1 = tex2D(DiffTexS, vUVTex + float2(0, -d)).a;
		float y2 = tex2D(DiffTexS, vUVTex + float2(0, +d)).a;
		nrm.y = (y1*y1 - y2*y2);

		float m = max(abs(nrm.x), abs(nrm.y));

		float dMN = dot(frg.nrmW, vSunDir);	// Planet mean normal sun angle
		// Bump magnitude/contrast function
		// Increase normals contrast based on sun-earth angle.
		float contrast = (m * (1.0f + (dMN*2.0f)));

#if defined(_CLOUDMICRO)
		// Blend in cloud normals only on thick clouds.
		nrm.xy = (nrm.xy + saturate((cTex.a * 4.0f) - 1.5f) * (cMicNorm.rg - 0.5f));
#endif

		nrm = normalize(nrm) * contrast;
		nrm.z = sqrt(1.0f - nrm.x*nrm.x - nrm.y*nrm.y);

		// Approximate world space normal from local tangent space
		nrm = normalize((vTangent * nrm.x) + (vBiTangent * nrm.y) + (frg.nrmW * nrm.z));

		float dCS = dot(nrm, vSunDir);			// Cloud normal sun angle

		// Brighten the lighting model for clouds, based on sun-earth angle.
		// Low sun angles = greater effect. No modulation leads to washed out normals at high sun angles.
		dCS = saturate((1.0f - dMN) * (dCS * (1.0f - dCS)) + dCS);
		dCS = saturate((1.0f - dMN) * (dCS * (1.0f - dCS)) + dCS);

		// Effect of normal/sun angle to color
    // Add some brightness (borrowing red channel from sunset attenuation)
    // Adding it to the sun illumination factor, taking care to keep from saturating
		cTex.rgb *= dCS + ((1.0f - dCS) * 0.2f);
	}
#endif

#if defined(_CLOUDMICRO)
		float f = cTex.a;
		float g = lerp(1.0f, cMic.a, frg.fade.y);
		float h = (g + 4.0f)*0.2f;
		cTex.a = saturate(lerp(g, h, f) * f);
#endif

  // Reduce attenuation near terminator (multiply by 3)
	// Change attenuation to be grayscale, not colored (.r not .rgb)
	// Ensure illumination goes as far as possible by borrowing red channel (.r)
	float3 color = cTex.rgb*saturate(frg.atten.r*3)*fCloudInts + frg.insca.rgb*vHazeMax;

	return float4(saturate(color + a), cTex.a*saturate(fCloudInts*fCloudInts));
}

Microtextures disabled:
clouds11.jpg


Microtextures enabled:
clouds21.jpg


Not sure why Antarctica is pink/orange:
clouds3.jpg


Microtextures enabled:
clouds41.jpg


Microtextures disabled:
clouds5.jpg


In the next image, the shadows turn into some ugly artifacts when the sun is directly overhead.
clouds6.jpg
 

Attachments

That looks really good. Now if we could just sort out the atmosphere, things are set.
 
Wouldn't cases 1 and 2 take care of case 3 given their 3D nature?


Most definitely not, since, cases 1 & 2 wont require a global cloud coverage at all if the camera doesn't go higher that 30km, some synthetic clouds resembling a current local weather is perfectly good enough and that's what FSX and X-Plane are doing as far as I can tell. There's no "big picture" about a global cloud patterns.

---------- Post added at 06:49 ---------- Previous post was at 05:45 ----------

In the next image, the shadows turn into some ugly artifacts when the sun is directly overhead.
clouds6.jpg




I made some changes, does this work better ?


Code:
float4 CloudTechPS(CloudVS frg) : COLOR
{
    float2 vUVMic = frg.texUV.xy * vMicroOff.zw + vMicroOff.xy;
    float2 vUVTex = frg.texUV.xy;

    // jarmonik: reduce microtex resolution
    vUVMic *= 0.33f;

    float a = (tex2Dlod(NoiseTexS, float4(vUVTex,0,0)).r - 0.5f) * ATMNOISE;

    float4 cTex = tex2D(DiffTexS, vUVTex);
    float4 cMic = tex2D(CloudMicroS, vUVMic);

#if defined(_CLOUDNORMALS)

    if (bCloudNorm) {

#if defined(_CLOUDMICRO)
        float4 cMicNorm = tex2D(CloudMicroNormS, vUVMic);  // Filename "cloud1_norm.dds" (does not exists in distribution)
#endif

                                                           // Filter width
        float d = 2.0 / 512.0;
        float3 nrm = 0;
        float3 nrmMicro = 0;

        float x1 = tex2D(DiffTexS, vUVTex + float2(-d, 0)).a;
        float x2 = tex2D(DiffTexS, vUVTex + float2(+d, 0)).a;
        nrm.x = (x1*x1 - x2*x2);

        float y1 = tex2D(DiffTexS, vUVTex + float2(0, -d)).a;
        float y2 = tex2D(DiffTexS, vUVTex + float2(0, +d)).a;
        nrm.y = (y1*y1 - y2*y2);

        float m = max(abs(nrm.x), abs(nrm.y));

        float dMN = dot(frg.nrmW, vSunDir);    // Planet mean normal sun angle
                                               // Bump magnitude/contrast function
                                               // Increase normals contrast based on sun-earth angle.
        float contrast = (m * (1.0f + (dMN*2.0f)));

#if defined(_CLOUDMICRO)
        // Blend in cloud normals only on thick clouds.
        nrm.xy = (nrm.xy + saturate((cTex.a * 4.0f) - 1.5f) * (cMicNorm.rg - 0.5f));
#endif

        nrm = normalize(nrm) * contrast;

        // jarmonik: sarutate() added as a safety check
        nrm.z = sqrt(1.0f - saturate(nrm.x*nrm.x + nrm.y*nrm.y));

        // Approximate world space normal from local tangent space
        nrm = normalize((vTangent * nrm.x) + (vBiTangent * nrm.y) + (frg.nrmW * nrm.z));

        float dCS = dot(nrm, vSunDir);            // Cloud normal sun angle

                                                  // Brighten the lighting model for clouds, based on sun-earth angle.
                                                  // Low sun angles = greater effect. No modulation leads to washed out normals at high sun angles.
        dCS = saturate((1.0f - dMN) * (dCS * (1.0f - dCS)) + dCS);
        dCS = saturate((1.0f - dMN) * (dCS * (1.0f - dCS)) + dCS);


        // jarmonik: With a high sun angle, don't let the dCS go below 0.65f to avoid unnaturally dark edges.
        dCS = lerp(0.65f*dMN, 1.0f, dCS);
    

        // Effect of normal/sun angle to color
        // Add some brightness (borrowing red channel from sunset attenuation)
        // Adding it to the sun illumination factor, taking care to keep from saturating
        cTex.rgb *= dCS + ((1.0f - dCS) * 0.2f);
    }
#endif

#if defined(_CLOUDMICRO)
    float f = cTex.a;
    float g = lerp(1.0f, cMic.a, frg.fade.y);
    float h = (g + 4.0f)*0.2f;
    cTex.a = saturate(lerp(g, h, f) * f);
#endif

    // Reduce attenuation near terminator (multiply by 3)
    // Change attenuation to be grayscale, not colored (.r not .rgb)
    // Ensure illumination goes as far as possible by borrowing red channel (.r)
    float3 color = cTex.rgb*saturate(frg.atten.r * 3)*fCloudInts + frg.insca.rgb*vHazeMax;

    return float4(saturate(color + a), cTex.a*saturate(fCloudInts*fCloudInts));    
 }
 
Last edited:
Most definitely not, since, cases 1 & 2 wont require a global cloud coverage at all if the camera doesn't go higher that 30km, some synthetic clouds resembling a current local weather is perfectly good enough and that's what FSX and X-Plane are doing as far as I can tell. There's no "big picture" about a global cloud patterns.
What about FlightGear? It has an orbital element as well as an atmospheric flight element.
 
Many improvements in microtexture code and overall rendering:

clouds111.jpg

clouds10.jpg


Here's the code. I think it's ready, but if anybody tries it and finds something they don't like, let me know.

PHP:
float4 CloudTechPS(CloudVS frg) : COLOR
{
    float2 vUVMic = frg.texUV.xy * vMicroOff.zw + vMicroOff.xy;
    float2 vUVTex = frg.texUV.xy;

    // jarmonik: reduce microtex resolution
    // vUVMic *= 0.5f; // new

    float a = (tex2Dlod(NoiseTexS, float4(vUVTex,0,0)).r - 0.5f) * ATMNOISE;

    float4 cTex = tex2D(DiffTexS, vUVTex);
    float4 cMic = tex2D(CloudMicroS, vUVMic);

#if defined(_CLOUDNORMALS)

    if (bCloudNorm) {

#if defined(_CLOUDMICRO)
        float4 cMicNorm = tex2D(CloudMicroNormS, vUVMic);  // Filename "cloud1_norm.dds" (does not exists in distribution)
#endif

    // Filter width
    float d = 2.0 / 512.0;
    float3 nrm = 0;
    float3 nrmMicro = 0;

    float x1 = tex2D(DiffTexS, vUVTex + float2(-d, 0)).a;
    float x2 = tex2D(DiffTexS, vUVTex + float2(+d, 0)).a;
    nrm.x = (x1*x1 - x2*x2);

    float y1 = tex2D(DiffTexS, vUVTex + float2(0, -d)).a;
    float y2 = tex2D(DiffTexS, vUVTex + float2(0, +d)).a;
    nrm.y = (y1*y1 - y2*y2);

    float dMN = dot(frg.nrmW, vSunDir);    // Planet mean normal sun angle

#if defined(_CLOUDMICRO)
        // Blend in cloud normals only on moderately thick clouds, allowing the highest cloud tops to be smooth.
        nrm.xy = (nrm.xy + saturate((cTex.a * 10.0f) - 3.0f) * saturate(((1.0f - cTex.a) * 10.0f) - 1.0f) * (cMicNorm.rg - 0.5f)); // new
#endif

    // Increase normals contrast based on sun-earth angle.
		nrm.xyz = nrm.xyz * (1.0f + (0.5f * dMN));

    // jarmonik: saturate() added as a safety check
    nrm.z = sqrt(1.0f - saturate(nrm.x*nrm.x + nrm.y*nrm.y));

    // Approximate world space normal from local tangent space
    nrm = normalize((vTangent * nrm.x) + (vBiTangent * nrm.y) + (frg.nrmW * nrm.z));

    float dCS = dot(nrm, vSunDir); // Cloud normal sun angle

    // Brighten the lighting model for clouds, based on sun-earth angle. Twice is better.
    // Low sun angles = greater effect. No modulation leads to washed out normals at high sun angles.
    dCS = saturate((1.0f - dMN) * (dCS * (1.0f - dCS)) + dCS);
    dCS = saturate((1.0f - dMN) * (dCS * (1.0f - dCS)) + dCS);

    // jarmonik: With a high sun angle, don't let the dCS go below 0.65f to avoid unnaturally dark edges.
    dCS = lerp(0.2f*dMN, 1.0f, dCS);

    // Effect of normal/sun angle to color
    // Add some brightness (borrowing red channel from sunset attenuation)
    // Adding it to the sun illumination factor, taking care to keep from saturating
    cTex.rgb *= dCS + ((1.0f - dCS) * 0.2f);
  }
#endif

#if defined(_CLOUDMICRO)
    float f = cTex.a;
    float g = lerp(1.0f, cMic.a, frg.fade.y);
    float h = (g + 4.0f)*0.2f;
    cTex.a = saturate(lerp(g, h, f) * f);
#endif

    // Reduce attenuation near terminator (multiply by 3)
    // Change attenuation to be grayscale, not colored (.r not .rgb)
    // Ensure illumination goes as far as possible by borrowing red channel (.r)
    float3 color = cTex.rgb*saturate(frg.atten.r * 3)*fCloudInts;
		// Blend haze without saturating
		color = lerp(color, 1.0f, frg.insca.rgb*vHazeMax);

    return float4(saturate(color + a), cTex.a*saturate(fCloudInts*fCloudInts));
}

And here's an updated pair of microtexture files.
 

Attachments

No complaints here! Looks great from orbit and I'm with that. Here's my latest on Earth atmosphere settings:

Earth.atms.cfg:
Code:
Red = 0.6397
Green = 0.55
Blue = 0.4
RWaveDep = 8
MWaveDep = 2.304
ScaleHeight = 8.11965
DepthClamp = 0.99875
Exposure = 1.1045
TGamma = 1.0128
OutScatter = 0.596748
InScatter = 1.1495
RayleighPhase = 0
MiePower = 0.13005
MiePhase = 0.967558
Aux1 = 0.2073
Aux2 = 1
Aux3 = 0
AGamma = 1.1016
HazeClr = -0.423
HazeIts = 1.6096

Earth.atmo.cfg:
Code:
Red = 0.6397
Green = 0.5692
Blue = 0.5086
RWaveDep = 8
MWaveDep = 0
ScaleHeight = 8.11965
DepthClamp = 1.25
Exposure = 0.9785
TGamma = 0.3
OutScatter = 0.699867
InScatter = 1.1285
RayleighPhase = -0.75
MiePower = 0.133128
MiePhase = 0.8
Aux1 = 0.2286
Aux2 = 0.725904
Aux3 = 0
AGamma = 1.3308
HazeClr = 1.5
HazeIts = 1.6474
 
New Builds are out

New builds of the Client are released for Orbiter Beta and 2016.


- Felix24's Implementation of normal mapped clouds is included.
- "Pink"/"Orange" Antarctica should be fixed (at-least reduced)
- Some black lines in the horizon that may have appeared before should be gone.
- Rendering of mesh based objects like "Nix" & "Hydra" should be fixed and vessel shadow should be visible. (but, of course, you can't land there, no physics surface exists).
- Some elevation functions are changed to operate in float basis instead of int16 which should allow rendering of smooth slopes without "staircase" visual effect. But the "staircase" still exists at the physics level as far as I can tell (not confirmed) feedback regarding this issue would be nice.
 
Back
Top