Skip to content
View in the app

A better way to browse. Learn more.

The AVSIM Community

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

SwarmCloud.fx fully SM3.0 compliant

Featured Replies

Evidently, you'll need ALLOW_SHADER_30=1 in [GRAPHICS] and don't forget to prime the cache.Sorry, no instructions. If you DONT know what this is, then you are probably better off waiting for the full shader release. This is for experimentation only and for those who want to see if there is any change in the way SM3.0 clouds look (to me they look the same) but then again, I'm not sure I have a good eye for this.Some changes with the original FSX SM1.1 file:- This one has an increased cloud color level bands- Bump mapping is active (not needed, but testing them)- Shader Model 3.0 compiled shader (including correct calculation of fog, which is needed for SM3.0)

//---------------------------------------------------------------------------// Flight Simulator X - Shader Effect Files// Copyright (c) 2006, Microsoft Corporation//---------------------------------------------------------------------------//// SwarmCloud.fx////// KEEP THE CALCULATIONS IN HERE CONSISTENT WITH// THE NON-SHADER PATH IN SWARMCLOUD.CPP!//#include <Common.fxh>#include <MaterialDecl.fxh>#include <D3D9Texture.fxh>#include <FuncLibrary.fxh>// Use the same shader constant naming convention as the 4.0 shaders.#define g_mWorld mWorld#define g_mWorldViewProj mFullProj#define g_vSunVectorWorld vSunVectorWorldfloat4  g_vEyePoint				 : VIEWPOSITION;const bool EffectDeclaration<	string Name	 = "SwarmCloud";	string Class	= "Basic";	string Features = "Bump";	bool   NewMaterialUsage = false;> = true;//------------------------------------------------------------------------------// Swarm cloud parameters////// REVIEW: There are a lot of parameters here being// set for every single cloud. Is it worth creating// some custom parameters and setting them once per// frame instead?////// Lighting parameters//float   g_fMedianLine		   : CLOUDMATERIAL_MEDIANLINE;float   g_fMinIntensity		 : CLOUDMATERIAL_MININTENSITY;float   g_fMedianIntensity	  : CLOUDMATERIAL_MEDIANINTENSITY;float4  g_fCloudDirectional	 : CLOUDMATERIAL_DIRECTIONAL;float4  g_fCloudAmbient		 : CLOUDMATERIAL_AMBIENT;//// Fog//float   g_fFogDensity		   : FOG_DENSITY;float4  g_cFog				  : FOG_COLOR;//// Fade in/out parameters//float   g_fAlpha				: CLOUDMATERIAL_ALPHA;float   g_fAlphaEdges		   : CLOUDMATERIAL_ALPHAEDGES;float   g_fRadius			   : CLOUDMATERIAL_RADIUS;//// Level band coloring parameters//#define MAX_COLOR_LEVELS 10float   g_rgColorLevelHeights[MAX_COLOR_LEVELS] : CLOUDMATERIAL_COLORLEVELHEIGHTS;float4  g_rgColorLevelColors[MAX_COLOR_LEVELS]  : CLOUDMATERIAL_COLORLEVELCOLORS;//------------------------------------------------------------------------------// Vertex shader////// REVIEW: This somewhat twisted set of input parameters// matches an existing vertex type - basically I didn't// want to add a new one just for this purpose then have// to plumb it all the way through G2D. I might go back// and do that though once I look at sprites.//struct VS_INPUT{	float4 spriteCenter : POSITION0;	float3 groupCenter  : NORMAL;	float4 packedUV	 : COLOR0;	float2 packedCorner : TEXCOORD0;};struct VS_OUTPUT{	float4 position	 : POSITION;	float4 diffuse	  : COLOR;	float2 uv		   : TEXCOORD;	float  fFogDistance : FOG;};VS_OUTPUT VS(VS_INPUT In){	VS_OUTPUT Out;		//		// Make a viewpoint oriented billboard matrix	//	// See SwarmCloud.cpp, ConstructFacingMatrix() - KEEP SHADER IN SYNC!	//		float4x4 mBillboard;		float4 scaledSpriteCenter = In.spriteCenter;	scaledSpriteCenter.x *= g_mWorld[0][0];	scaledSpriteCenter.y *= g_mWorld[1][1];	scaledSpriteCenter.z *= g_mWorld[2][2];		mBillboard[1] = float4(0,1,0,0);	mBillboard[2] = normalize(g_mWorld[3] + scaledSpriteCenter);	mBillboard[0] = normalize(float4(cross(mBillboard[1], mBillboard[2]), 0));	mBillboard[1] = float4(cross(mBillboard[2], mBillboard[0]), 0);	mBillboard[3] = In.spriteCenter;		//	// Get the corner position relative to the cloud center	//		float4 corner = float4(In.packedCorner.x, In.packedCorner.y, 0, 1);	corner = mul(corner, mBillboard);	//	// Get the transformed corner position	//	Out.position = mul(corner, g_mWorldViewProj);		//	// Sun lighting	//	// See bglfp.cpp, g2d_LightCloudFromNormal() - KEEP SHADER IN SYNC!	//		float3 cloudGroupNormal = normalize(corner - In.groupCenter);	float  fIntensity = dot(g_vSunVectorWorld, cloudGroupNormal);	if (fIntensity < -g_fMedianLine)	{		fIntensity = g_fMinIntensity +			(g_fMedianIntensity - g_fMinIntensity) *			((1 + fIntensity) / (1.0001 - g_fMedianLine));			// The "1.0001" in the line above is a hack to fix a bug			// observed on some nVidia hardware (a 7800). Even though			// the else branch of this if/else was taken a divide by			// zero in this branch (when g_fMedianLine is 1.0) caused			// the whole shader to go crazy.	}	else	{		fIntensity = g_fMedianIntensity +			(1 - g_fMedianIntensity) *			((fIntensity + g_fMedianLine) / (1 + g_fMedianLine));	}	float fRed   = fIntensity * g_fCloudDirectional.r + g_fCloudAmbient.r;	float fGreen = fIntensity * g_fCloudDirectional.g + g_fCloudAmbient.g;	float fBlue  = fIntensity * g_fCloudDirectional.b + g_fCloudAmbient.b;	fRed	= min(fRed, 1.0f);	fGreen  = min(fGreen, 1.0f);	fBlue   = min(fBlue, 1.0f);		//	// Height band lighting/coloring	//	// See SwarmCloud.cpp, GetColor() - KEEP SHADER IN SYNC!	//	float height = corner.y;	float4 baseColor;	float4 topColor;	float  baseHeight;	float  topHeight;		if (height <= g_rgColorLevelHeights[0])	{		baseColor  = g_rgColorLevelColors[0];		topColor   = g_rgColorLevelColors[0];		baseHeight = g_rgColorLevelHeights[0];		topHeight  = g_rgColorLevelHeights[0] + 1; // +1 to avoid division by zero below	}	else if (height <= g_rgColorLevelHeights[1])	{		baseColor  = g_rgColorLevelColors[0];		topColor   = g_rgColorLevelColors[1];		baseHeight = g_rgColorLevelHeights[0];		topHeight  = g_rgColorLevelHeights[1];	}	else if (height <= g_rgColorLevelHeights[2])	{		baseColor  = g_rgColorLevelColors[1];		topColor   = g_rgColorLevelColors[2];		baseHeight = g_rgColorLevelHeights[1];		topHeight  = g_rgColorLevelHeights[2];	}	else if (height <= g_rgColorLevelHeights[3])	{		baseColor  = g_rgColorLevelColors[2];		topColor   = g_rgColorLevelColors[3];		baseHeight = g_rgColorLevelHeights[2];		topHeight  = g_rgColorLevelHeights[3];	}	else if (height <= g_rgColorLevelHeights[4])	{		baseColor  = g_rgColorLevelColors[3];		topColor   = g_rgColorLevelColors[4];		baseHeight = g_rgColorLevelHeights[3];		topHeight  = g_rgColorLevelHeights[4];	}	else if (height <= g_rgColorLevelHeights[5])	{		baseColor  = g_rgColorLevelColors[4];		topColor   = g_rgColorLevelColors[5];		baseHeight = g_rgColorLevelHeights[4];		topHeight  = g_rgColorLevelHeights[5];	}	else if (height <= g_rgColorLevelHeights[6])	{		baseColor  = g_rgColorLevelColors[5];		topColor   = g_rgColorLevelColors[6];		baseHeight = g_rgColorLevelHeights[5];		topHeight  = g_rgColorLevelHeights[6];	}	else if (height <= g_rgColorLevelHeights[7])	{		baseColor  = g_rgColorLevelColors[6];		topColor   = g_rgColorLevelColors[7];		baseHeight = g_rgColorLevelHeights[6];		topHeight  = g_rgColorLevelHeights[7];	}	else if (height <= g_rgColorLevelHeights[8])	{		baseColor  = g_rgColorLevelColors[7];		topColor   = g_rgColorLevelColors[8];		baseHeight = g_rgColorLevelHeights[7];		topHeight  = g_rgColorLevelHeights[8];	}	else	{		baseColor  = g_rgColorLevelColors[9];		topColor   = g_rgColorLevelColors[9];		baseHeight = g_rgColorLevelHeights[9];		topHeight  = g_rgColorLevelHeights[9] + 1; // +1 to avoid division by zero below	}	float s = (height - baseHeight) / (topHeight - baseHeight);	float4 color = lerp(baseColor, topColor, s);	//	// Fade in/out alpha	//		float distance_from_center = length(corner);		float fAlpha = 1.0f;	if (g_fAlpha > 0)	{		// Fading in from or out to the edges		float fMagnitude = 1.3f * g_fRadius - distance_from_center;		fMagnitude = max(0, fMagnitude);		fAlpha = g_fAlpha - g_fAlphaEdges * (fMagnitude / g_fRadius);	}	else	{		// Fading out to the core		fAlpha = -g_fAlpha - g_fAlphaEdges * (distance_from_center / g_fRadius);	}		Out.diffuse = float4(fRed, fGreen, fBlue, saturate(fAlpha)) * color;	Out.uv.x	= In.packedUV.b;	Out.uv.y	= In.packedUV.g;	Out.fFogDistance = FogVS(corner, g_mWorld, g_vEyePoint);	return Out;}//------------------------------------------------------------------------------// Pixel shader//float4 PS(VS_OUTPUT In): COLOR{	float4 cColor = In.diffuse * tex2D(BaseSampler, In.uv);	return float4(FogPS(cColor.xyz, In.fFogDistance, g_fFogDensity, g_cFog), cColor.a);}//------------------------------------------------------------------------------// Technique//technique T0<	int	Performance = EffectPerfLevel_MaxShader30;>{	pass P0	{		NormalizeNormals			= TRUE;		ZWriteEnable				= FALSE;		ZEnable					 = TRUE;		ZFunc					   = LESSEQUAL;		AlphaBlendEnable			= TRUE;		SrcBlend					= SRCALPHA;		DestBlend				   = INVSRCALPHA;		SeparateAlphaBlendEnable	= FALSE;		AlphaTestEnable			 = FALSE;		StencilEnable			   = FALSE;		SpecularEnable			  = FALSE;		ColorWriteEnable			= RED | GREEN | BLUE;		FogEnable				   = TRUE;		CullMode					= CCW;		VertexShader				= compile vs_3_0 VS();		PixelShader				 = compile ps_3_0 PS();	}}

  • Replies 32
  • Views 6.6k
  • Created
  • Last Reply

Top Posters In This Topic

Changed the swarmCloudFx but really cant tell much difference?What are the benefits of SM3.0?EditAfter flying around with this for a bit I think the effect of passing through a cloud is much better, also haze/fog looks like it has improvedThis could all be a placebo but there seems to be a small difference

The visual comparison between Shader V1.1 & V3 on ATI seems very slight, Shader 3 seems a little more subtle in definition & has a slightly softer tone...but this is still quite difficult to pick up even comparing screenshotsNow interestingly, I seem to be seeing a SLIGHT performance gain in the region of 1-2 fps average with shader V3 with ATI5870 on Beta10.3 drivers. I tested this 3 or 4 times loading a saved flight JS41 external view at KJFK with a fair amount of cloud cover, swapping between Both Shaders.Is anyone else seeing this gain.......?Craig

Craig Sells

  • Author
Changed the swarmCloudFx but really cant tell much difference?What are the benefits of SM3.0?EditAfter flying around with this for a bit I think the effect of passing through a cloud is much better, also haze/fog looks like it has improvedThis could all be a placebo but there seems to be a small difference
For clouds, is not as dramatic as with 'water' however, 'fog' effects are much improved, and SM3.0 (vs 1.1) has the added benefit of processing more pixels per opeation, so in theory (because I have not tested that) under VERY heavy cloud cover and with NEWER cards there should be a performance increase (this is all academic) I've not tested the performance yet, so would be interesting for others to chime in and comment on that.Cloud coloring is also improved, there are now 10 color levels instead of 5, however those are BLACK -> WHITE color levels.try heavy weather and different kinds of clouds (thunderstorms, puffy etc.) fly through them, set visibility to 1nm, try an overcast, and see how it performs, meanwhile I'm working on the Terrain, General and Water shaders.. I've them already working with SM3.0 (the Vertex Shader) the Pixel Shader is a royal pain in the arse because they need custom fog calculations, annoying.
  • Author
The sky turns black and clouds grayscale when looking upward, ENBmod has no effect. Radeon 4850, Catalyst 10.3 Beta.
I experienced that too, but since removing the bump effect and changing the effectdeclaration to true (it doesn't seem to flash with SM3.0) I have not seen it again. Thanks for testing.
I experienced that too, but since removing the bump effect and changing the effectdeclaration to true (it doesn't seem to flash with SM3.0) I have not seen it again. Thanks for testing.
const bool EffectDeclaration<	string Name	 = "SwarmCloud";	string Class	= "Basic";	string Features = "Bump";	bool   NewMaterialUsage = false;> = true;

My SwarmCloud.fx looked like this when blackout occured, and I sure deleted shader cache before trying your fx-file.Do you mean that you

  • Author

I changed this since posting the file, and make sure you delete the shader cache again...as I said, I also saw the 'black sky' but not again, so it could be related to those two changes.const bool EffectDeclaration< string Name = "SwarmCloud"; string Class = "Basic"; string Features = "Bump"; // Remove this line bool NewMaterialUsage = true;> = true;

I changed this since posting the file, and make sure you delete the shader cache again...as I said, I also saw the 'black sky' but not again, so it could be related to those two changes.const bool EffectDeclaration<string Name = "SwarmCloud";string Class = "Basic";string Features = "Bump"; // Remove this linebool NewMaterialUsage = true;> = true;
Will you be also doing this mod to the special effects files, does this make sense? Would it help?
I changed this since posting the file, and make sure you delete the shader cache again...as I said, I also saw the 'black sky' but not again, so it could be related to those two changes.const bool EffectDeclaration< string Name = "SwarmCloud"; string Class = "Basic"; string Features = "Bump"; // Remove this line bool NewMaterialUsage = true;> = true;
That did the trick, nice skies again.But isn
  • Author
But isn
  • Commercial Member

Hey *******. First off, thanks for your tenacity in discovering and testing out all these tweaks so far. :)As the discoverer of the initial "cloud popping fix" with newmaterialusage=false etc a couple of years ago, I just had to try out your new swarmcloud file. It seems to work ok. I can't say anything about a performance difference yet, still some testing to do, but if the newmaterialusage variable in the file is still set to "true" then the popping is still there unfortunately, at least for me (285GTX 1GB, 197.45 driver, all shaders deleted and recompiled after change). The easiest way to test for that cloud popping bug by the way is to find an airport with a large number of animated jetways (LAX etc), set a full overcast cumulus layer, then, using slew mode, move to a position about 0.5-2nm away from the airport terminals (so that the jetways are using their middle or low LOD model). After that, pan your view so that all of the jetways or entire airport are off screen, wait for 10-30 seconds and then rapidly pan back towards them. If the clouds are going to pop, then they will do so every time using this test. The default FSX scenery yacht marinas will also cause this effect in their middle or low LOD form about 70% of the time (depending on how recently they've been loaded), as well as a dozen other default objects.Anyway, thanks for all your efforts so far and keep up the great sleuthing. :)-Mike

Mike Johnson - Lotus Simulations

Hi *******,I made the change shown above. However, when flying through clouds now, they just instantly disappear there is no gradual change anymore. Am I the only one seeing this?.Thanks

Former Beta Tester - (for a few companies) - As well as provide Regional Voice Set Recordings

                Two: AMD-9950X | One: AMD-7950X3D | Three: Asus TUF 4090s | Three: 64GB DDR5 RAM 6000mhz | Three: Cosair 1300 P/S | Three: 990Pro 2TB NVME                    One: Eugenius ECS2512 - 2.5 GHz Switch | Three: Ice Giant Elite CPU Coolers | Three: 75" 4K UHDTVs | One: Boeing 737NG Flight Deck

Hate to be a party pooper in this, and I applaud your ingenuity in finding all these tweaks, but by publicly posting this I believe this maybe one tweak too far. This file is clearly copyrighted (It states it right at the beginning) This comes very close if not crosses the line into system code, since it's not dealing with not just a model or scenery area, but with changes to the graphic engine itself. This would violate the EULA which clearly statesYou may notwork around any technical limitations in the software;reverse engineer, decompile or disassemble the software, except and only to the extent that applicable law expressly permits, despite this limitation;Setting changes is one thing, but code is something else!Tom

Thanks

Tom

My Youtube Videos!

http://www.youtube.com/user/tf51d

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.