Jump to content

Recommended Posts

The shimmering of TODs and target objects and the flickering of shadows in the thirdwire game engine always anoyed me. And since I'm playing FE2 recently, there this problems are more intense,I decided to have a closer look at this issue and possible solutions. This is what I came up with:

As many of you already know, the shimmering of the objects and flickering of shadows is caused by the limited precision of the z-buffer.
The precision of the z-buffer depends (besides the buffers bit depth) on two values: the near clipping plane distance (znear) and the far clipping plane distance (zfar). To increase the z-buffer precision you have to shorten the interval[znear,zfar], either by decreasing zfar or by increasing znear. Whereby increasing znear is FAR more effective for increasing z-buffer precision.

Changing zfar:

I'm not quite sure what *.ini setting defines zfar. But I think that decreasing the horizon distance in the game options menu decreases zfar. But I found to see any (minor) effect (regarding reducing shimmering/flickering) I had to change the horizon setting to Near. But I like the horizon setting at Very Far and I will let it at Very Far.

Changing znear:

znear is defined in the flightengine.ini by

FE2:
[NearSceneClip]
NearClipDistance=

SF2 with object fading disabled (fading enabled I haven't investigated yet):
[ForegroundSceneClip]
NearClipDistance=

But there is an exception: If in the <aircraft>_cockpit.ini OpenCockpit= is set to TRUE, then znear is defined by (the usually smaller value) ExternalClipDistMin=. Thats the reason why in some aircraft the shimmering happens, while in the external view it does not. The external view uses the flightengine.ini setting.

The znear value has to be increased as much as possible. Unfortunately this value can not be increased arbitrary without side effects: e.g. clipping issues. You have to experiment until you find a maximum znear value without side effects.

If you are lucky then the znear increase was sufficient to stop the shimmering/flickering.
If not, then you have to tweak further.

Tweaks against flickering shadows:

Against the flickering shadows I don't know any tweaks. The only solution is to switch them off: Shadow option = High switches TOD shadows off, = Medium also switches target object shadows off.


The following tweaks are meant to reduce the shimmering caused by z-fighting between the terrain and the TODs / target objects. What the tweaks do is to increase the z value distances between the terrain and the TODs / target objects.


Tweak against shimmering TODs:

In the <terrain>_data.ini set

[solidObjectTextureMaterial]
ZBufferOffset=2.0 or higher (in FE2 I set it to 5.0 to stop the shimmering)

That modifies the z value by an offset so that the TODs are put a bit "forward" in the z-buffer.
But this doesn't affect target objects shimmering.


Tweak against shimmering target objects (and TODs).

The solution I found is to modify the terrain shaders:
TERTERRAINEFFECT.FX (near terrain)
TERFARTERRAINEFFECT.FX (far terrain)
TERWATEREFFECT0.FX (terrain with water, Water Detail = Low)
TERWATEREFFECT1.FX (terrain with water, Water Detail = Medium)
TERWATEREFFECT2.FX (terrain with water, Water Detail = High)

In each shader I added the following lines in the vertex shader code

const float zOffset = 3.0e-7;
output.pos.z += zOffset * output.pos.w;

That adds an offset to the z value so that the terrain is put a bit "back" in the z-buffer.
This tweak ALSO affects TOD shimmering.
But it has a side effect: The TOD / target object shadows are a bit shifted if viewed from greater distances. It's a tradeoff: choosing a greater zOffset value lessens the shimmering but shifts the shadows more and vice versa. You can try to decrease/increase zOffset in small steps (e.g. 1.0e-7) to see which offset fits best.


The terrain shaders for FE2:
fe2_zbufferoffset_shaders.zip

 

Put the shader files (*.fx) into the Terrains\<terrain> directory.

@admins/moderators: I also have modified SF2 shaders. But I don't know if the combatace policy allows to upload modified LOCKED shaders.

 

Update:

The terrain shaders for SF2:

sf2_zbufferoffset_shaders.zip

Edited by mue
  • Like 5

Share this post


Link to post
Share on other sites

now that is most interesting find Mue! :clapping:

 

the shimmering city TODs of mine were driving me crazy for ages now! So big thanks for every and any of your findings!

  • Like 1

Share this post


Link to post
Share on other sites

Thank you!  That fixed the problem on my rig - the shimmering towns went away.

  • Like 2

Share this post


Link to post
Share on other sites

as far as I'm concerned, you certainly MAY upload them!!

Share this post


Link to post
Share on other sites

I added the modified terrain shaders for SF2 to the first post.

Share this post


Link to post
Share on other sites

I tried on sf2v expansion terrain : a good value seems 5e-7, 3e-7 is too low

Edited by jeanba

Share this post


Link to post
Share on other sites

I also tried with the Isreal Map from 1948 War for Independence/1956 Suez Crisis 2.1 :

It does not work, if I put ZBufferOffset=2.0, the runways are disappearing, 0 is ok, obviously

Share this post


Link to post
Share on other sites

I also tried with the Isreal Map from 1948 War for Independence/1956 Suez Crisis 2.1 :

It does not work, if I put ZBufferOffset=2.0, the runways are disappearing, 0 is ok, obviously

 

Have you really set ZBufferOffset of [solidObjectTextureMaterial]?

Disappearing runways seems to indicate that you changed [NormalTextureMaterial] or [backgroundMaterial].

Share this post


Link to post
Share on other sites

Thank you for the tip, I will check

Share this post


Link to post
Share on other sites

mue, you wrote:

"But there is an exception: If in the <aircraft>_cockpit.ini OpenCockpit= is set to TRUE, then znear is defined by (the usually smaller value) ExternalClipDistMin=. Thats the reason why in some aircraft the shimmering happens, while in the external view it does not. The external view uses the flightengine.ini setting."

 

Where´s "ExternalClipDistMin="? What´s the best parameter?
 

Share this post


Link to post
Share on other sites

mue, you wrote:

"But there is an exception: If in the <aircraft>_cockpit.ini OpenCockpit= is set to TRUE, then znear is defined by (the usually smaller value) ExternalClipDistMin=. Thats the reason why in some aircraft the shimmering happens, while in the external view it does not. The external view uses the flightengine.ini setting."

 

Where´s "ExternalClipDistMin="? What´s the best parameter?

 

 

It's in the <aircraft>_cockpit.ini. Try to increase it as much as possible as long as you don't get any clipping issues. E.g. in FE2 for an aircraft I could increase that value only from 0.05 to 0.08 without clipping issues.

  • Like 1

Share this post


Link to post
Share on other sites

Starting head-on into this: what's the todo? Just add mue's .ini's into all terrains I am using? Or is that only good against shimmering target objects and more/other shimmering needs attention by more "individual" adjustments as per mue's explanations?

Thanks

Share this post


Link to post
Share on other sites

Okay, in mue's FX.-files I changed the values to 5.0e-7 as per jeanba's hint and dropped the files into my terrain-folders in SF2V with the Expansion Pack...

I still see shimmering on bridges and some antenna-structures (inside cockpits and outside) - so I guess I will also need to look into the NearClipDistance in the FLIGHTENGINE.INI.

The standard/current value is something like 0.45 - any idea to what value I should start changing as a start.

I have no clue and this is absolute new terrain to me, so any advice is MUCH appreciated!

 

Thanks, guys!

Share this post


Link to post
Share on other sites
An Extremely Complex Issue Connected To Hardware Capability And Settings And Rewriting The
Instructions. I Combine Mues's Settings With My Own Tweaks.
For Instance I Installed His Zbufferoffset Shaders And Added ZBufferOffset=2.0 In GERMANYCE_DATA.INI
Under SolidObjectTextureMaterial Which Solved Most Of The Shimmer. But I Also Combine It With Other
Effects For Instance.
ENVIRONMENTSYSTEM.ini
[Fog]
StartClear=4000
EndClear=0.8
StartOvercast=-2000
EndOvercast=38000
OvercastColor=0.82,0.82,0.81
StartInclement=-2000
EndInclement=18000
InclementColor=0.4,0.4,0.4
StartCloud=-500
EndCloud=500
HazeFogColor=0.64,0.75,0.83
CloudColor=0.8,0.8,0.8
StartMorning=TRUE
MorningStartTime=0.5
MorningEndTime=0.6
LightSrcModifier=2.0
[CloudMaterial]
EffectShaderName=envClouds.fx
DepthBufferCheck=TRUE<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<Important
DepthBufferWrite=FALSE
RenderedInOrder=FALSE
AlphaTestEnabled=TRUE
CullMode=NO_CULL
LightEnabled=FALSE
SpecularEnabled=FALSE
EmissiveEnabled=FALSE
FogEnabled=TRUE
AmbientColor=1.000000,1.000000,1.000000,1.000000
DiffuseColor=1.000000,1.000000,1.000000,1.000000
ZBufferOffset=0.000000
PriorityLevel=1
BlendOp=BLEND_SRC_ALPHA
NumTextureStages=1
TextureStage[01].TextureName=cloud1.tga
TextureStage[01].MipMap=TRUE
TextureStage[01].MipMapLevels=6
TextureStage[01].FilterEnabled=TRUE
TextureStage[01].StageColorOp=TEXTURE_MODULATE_DIFFUSE
TextureStage[01].StageAlphaOp=TEXTURE_MODULATE_DIFFUSE
And Added A Special Tweak In FLIGHTENGINE.ini
[GraphicsSettings]
ZBufferDepth=32//24<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<Important Tweak
MaxVertexCount=16384
MaxIndexCount=98303
MaxTextureCount=4096
MaxModelType=2024
MaxMeshPerScene=4096
MaxModelPerScene=2024
MaxLightPerScene=256
AspectRatio=1.333333
MinPixelSize=1.0
Ive Been Told That The ZBufferDepth=32 Will Automatic Default Your Card To Its Highest Setting.
The Word Being That Some Nvidia Cards Actually Support 32 Depth Where As Most ATI-AMD Will Utilize
24 With Rare Exceptions Of Higher Performance. A Quote From The Internet Follows.
"The depth-buffer is a buffer that, just like the color buffer (that stores all the fragment colors: the visual output), stores information per fragment and (usually) has the same width and height as the color buffer. The depth buffer is automatically created by the windowing system and stores its depth values as 16, 24 or 32 bit floats. In most systems you'll see a depth buffer with a precision of 24 bits.
Today most GPUs support a hardware feature called early depth testing. Early depth testing allows the depth test to run before the fragment shader runs. Wherever it is clear a fragment is never going to be visible (it is behind other objects) we can prematurely discard the fragment."
And A Few Screenshots For Seemless Horizons And Ground Haze. Notice The Ground Haze In The Valley Beyond Extending Down The Ridge Line Most Air To Ground
Vision Beyond 11 Nautical Miles Normaly Starts To Degrade At Low Altitudes.
Tweaking Never Stops And Thanks To Mue For His Insights.
P.S. I Shall Include My FLIGHTENGINE.ini As A Reference.
[Debug]
SkipFlight=FALSE
[FlightEngine]
HUDDLL=HUD.dll
HUDDataFilename=HUDData.ini
CommDLL=Comm.dll
CommDataFilename=CommData.ini
ObjectList=ObjectList.ini
SoundList=SoundList.ini
ViewList=ViewList.ini
ParticleSystem=ParticleSystem.ini
EnvironmentSystem=EnvironmentSystem.ini
MessageSystem=MessageSystem.ini
SpeechSystem=SpeechSystem.ini
DeltaT=0.016667
MaxDeltaT=0.100
RefreshTime=0.016667
ChangeTimeAmount=15
MaxTimeCompression=8.0
StartTimeCompression=1
StartPaused=FALSE
ShowCockpit=TRUE
TextFilename=FlightText.str
EjectView=EjectView
[ForceFeedback]
ForceFeedback=FlightFFBEffect.ini
ForceFeedbackControl=PITCH_CONTROL
FadeStartTime=0.2
FadeTime=1.0
[LoadingScreen]
BackgroundImage=LoadingScreen1.JPG
BackgroundImageSize=1024,768
TextFontName=Arial
TextSize=20
TextFontColor=250,250,250
TextFile=LoadingText.str
LoadingTextStringID=TXT_FLT_LOADING
PercentTextStringID=TXT_FLT_LOADING_PERCENT
ProgressBarRange=100
ProgressBarRect=204,733,820,753
StreamAudio=loading.wav
FadeTime=0.2
[GraphicsSettings]
ZBufferDepth=32//24
MaxVertexCount=16384
MaxIndexCount=98303
MaxTextureCount=4096
MaxModelType=2024
MaxMeshPerScene=4096
MaxModelPerScene=2024
MaxLightPerScene=256
AspectRatio=1.333333
MinPixelSize=1.0
[backgroundSceneClip]
FarClipDistance=240000.0//80000.0
NearClipDistance=2400.0//3000.0
[ForegroundSceneClip]
FarClipDistance=240000.0//14000.0
NearClipDistance=0.72//0.45
[insideSceneClip]
FarClipDistance=240.0//250.0
NearClipDistance=0.024//0.01
[LowDetailOption]
HorizonDistance=48000.0//30000.0
DetailMeshSize=2
DetailLevel=1//0
WaterEffect=0
NoiseTexture=0
MaxTextureRes=128
[MedDetailOption]
HorizonDistance=56000.0//42000.0
DetailMeshSize=4//2
DetailLevel=1
WaterEffect=1
NoiseTexture=0
MaxTextureRes=256
[HighDetailOption]
HorizonDistance=64000.0//50000.0
DetailMeshSize=8//3
DetailLevel=2
WaterEffect=2
NoiseTexture=1
MaxTextureRes=512
[unlimitedDetailOption]
HorizonDistance=72000.0//62000.0
DetailMeshSize=12//4
DetailLevel=2
WaterEffect=2
NoiseTexture=1
MaxTextureRes=-1
[soundSettings]
SampleFrequency=44100
BitsPerSample=16
DopplerFactor=1.0
[WorldSettings]
SectorWidth=20
SectorHeight=20
SectorMaxObject=256
Border=80000.0//locked tk
MinHeight=1.0
MaxHeight=240000.0//35000.0 ceiling not locked opened for balistic missile effects
[MapSettings]
MapMaxSize=800000//200000
MapMinSize=10000//20000
MapInitSize=100000
MapScaleRate=5.0
ZoomControl=CAMERA_ZOOM_CONTROL
[screenShot]
FilenameFormat=img%05d.JPG
MaxScreenShot=99999
SoundEffect=shutter.wav
[TextStrings]
GamePaused=TXT_FLT_GAME_PAUSED
GameUnpaused=TXT_FLT_GAME_UNPAUSED
TimeCompress=TXT_FLT_TIME_COMPRESS
NormalTime=TXT_FLT_NORMAL_TIME
TimeSet=TXT_FLT_TIME_SET
StartFlight=TXT_FLT_START_FLIGHT
WaitJoin=TXT_FLT_WAIT_JOIN
[skipToNext]
Timer=3.0
FadeTimer=1.0
SkipToNextView=FlybyView
AutoPilotCommand=AUTO_PILOT
[startView]
StartView000=ShoulderView
StartView001=CockpitFront
[EndGame]
EndGameTimer=5.0
EndGameView=DeathView
AutoEndGame=FALSE
[inFlightChat]
TargetText=ChatTarget.str
RepeatDelay=0.5
RepeatRate=0.1
CursorFlashTime=0.4
CursorString=|
As Always Test Your Hardware For Capabilities I Rewrote Most Of My Visual Effects Not To Exceed
240 Kilometers In The Extreme Nuclear Environment.
My Card Is A XFX R9-280X Running With An AMD FX-8350 Eight-Core 4+Ghz With 16 GB Of GSkill Mem
On A Crosshair Z Board.

post-62958-0-30262200-1500533180_thumb.jpg

post-62958-0-25763400-1500533193_thumb.jpg

Edited by EMCON360

Share this post


Link to post
Share on other sites

Thanks for your answer and providing your details...

 

First I just tried changing ZBufferDepth= from 24 to 32 and checked out results, which were none visible...

 

Next I looked into your

[ForegroundSceneClip]
FarClipDistance=240000.0//14000.0 ........ mine is 240000.0
NearClipDistance=0.72//0.45 .....................and 0.45

What exactly does a change in these values trigger? Maybe that will help me evaluating what changes might be needed.....

 

For now I will just change 0.45 to 0.72 (without knowing what I'm doing :baby: ), go for a hop and check it out...

 

 

Nope - same situation....... :aggressive:

Edited by stingray77

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Content

    • By JaneyBananey
      Howdy y'all!
      So, I installed Wings Over Europe via Steam, promptly updated it to the October 2008 patch, and fixed the stuttering by using the ENB patch for Skyrim (of all things). I also cribbed the DDraw.dll from the DgVoodoo install, which prevented the game crashing when pressing escape at the end of a mission. A couple of things to note here:
      - The renderer indicated in the options menu is not ENB, but my GPU still. Despite this, the game runs perfectly fine.
      - I turned the shadows down from Unlimited to High as I read on a forum post that this could help with z-fighting, but this did not solve the issue. I will turn it back up to Unlimited if it is all the same.
      - There are absolutely no other graphical issues in the sim what so ever, no matter the aircraft, time of day, or weather.
      The issue I am describing in the title appears like so in sim. I took three screenshots so you could see the way the dark boxes flicker on surfaces. It is not just aircraft, either, but also terrain. It seems to get culled in a circle as I turn my head with TrackIR:



      As you can see, my wingman gets periodically eaten by this weird black blob. I am at a loss as to how to fix it, and if it cannot be fixed, that's completely understandable given the Biblical age of the engine. Thanks in advance!
×

Important Information

By using this site, you agree to our Terms of Use, Privacy Policy, and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..