Jump to content
mue

Extending the drawing distance for fading objects

Recommended Posts

Since I had a look into the shaders I also extended the drawing distance for fading objects.

 

The modified object shaders:

Update V1.1: fixed incorrect calculation of object distances outside the view center.

sf2_extfadingdistance_shaders_v1.1.zip

 

-Copy the shader files (*.fx) into the Terrains\<terrain> folder.

-Adjust the variables fadeStartDistance and fadeLength to your likings in the follwing code section of both shader files:

float fade_with_distance(float FadeDist)
{
    float fade_alpha = 1.0;
    
    //mue: distance at which the object still has alpha = 1.0 (full opaque)
    const float fadeStartDistance = 16000.0;    //in meters
    
    //mue: fadeStartDistance + fadeLength = distance at which the object has alpha = 0.0 (full transparent)
    const float fadeLength = 3000.0;            //in meters
    
    const float fd = FadeDist - fadeStartDistance;
    if (fd > 0.0)
    {
        fade_alpha = clamp(0.0, 1.0, 1.0 - (fd / fadeLength));
    }

    return (fade_alpha);
}

-Set in flightengine.ini DetailMeshSize so that

 (fadeStartDistance + fadeLength) / terrain_tile_size < DetailMeshSize

-Set in options.ini ObjectsFade=false

 

-Enjoy your flight!

 

Edited by mue
  • Like 6

Share this post


Link to post
Share on other sites

I'm assuming this is for TODs?  So we can have forests that extend to the horizon?

 

FC

Share this post


Link to post
Share on other sites
forests that extend to the horizon

 

 

that would be nice!

I can think of at least 5 terrains that could benefit from this!!

Share this post


Link to post
Share on other sites

This is great !

 

Thanks Mue, no more "popup" city blocks :biggrin:

Share this post


Link to post
Share on other sites

terrain_tile_size

 

Can you elaborate?

Share this post


Link to post
Share on other sites

What changes are made to flightengine

 

[unlimitedDetailOption]
HorizonDistance=62000.0
DetailMeshSize= 12
DetailLevel=2
WaterEffect=2
NoiseTexture=1
MaxTextureRes=0.0

Share this post


Link to post
Share on other sites

I'm assuming this is for TODs?  So we can have forests that extend to the horizon?

 

FC

 

Yes and yes if your rig can handle that number of tods.

 

terrain_tile_size

 

Can you elaborate?

 

Its the size of the terrain tiles. I think all stock terrains have a tile size of 2000 meters. If you don't know the tile size of the terrain, assume 2000 meters and set DetailMeshSize according to the given formula:

E.g. fadeStartDistance = 16000.0, fadeLength = 3000.0 and terrain_tile_size = 2000

(16000.0 + 3000.0) / 2000 = 9.5

Rounding 9.5 up to the next integer gives 10 => set DetailMeshSize=10

 

If you see that the tods pop up in roughly at the half distance (~10000 meters) then the tile size is probably 1000 meters and you have to set

(16000.0 + 3000.0) / 1000 = 19, rounding up gives still 19 => DetailMeshSize=19

 

Of course you can set a higher DetailMeshSize but it will only decrease your frame rate.

Share this post


Link to post
Share on other sites

I'm not seeing any difference in pop-up / fade in distance.  Are there any other factors that affect that?

 

FC

Share this post


Link to post
Share on other sites

in the Options ini, do you have ObjectesFade = FALSE?

Share this post


Link to post
Share on other sites

in the Options ini, do you have ObjectesFade = FALSE?

 

Nope...set as TRUE.

 

Let me run some other tests....

 

FC

 

Damn it...RTFP...I just realized I'm supposed to set it as FALSE...sheesh.

Share this post


Link to post
Share on other sites

Okay, now I'm impressed...set as 32000/3000 with DetailMeshSize=18 and it reaches darn near all the way to the horizon.

 

Little trepidation loading at 30% though...first time with it set at 64000/3000 it crashed the sim.

 

I'm also not seeing any sort issues with Stary's clouds in his Sarcasm mod (flying high).

 

Good frame rates too.

 

Anything I'm missing?

 

FC

Share this post


Link to post
Share on other sites

Stary, I'm beginning to think a Green Hell mod with the shimmering TOD shader fix plus this shader fix plus your clouds and terrain would really show off a 'lush' Vietnam.

 

Of course, this would be for top range computers (though I'm running a 2 1/2 year old laptop and it seems to do really well with it so far).

 

FC

  • Like 3

Share this post


Link to post
Share on other sites

This really increases immersion (oh, that word) in the sim, Mue. Thank you. Wrench's Korea 3 looks even more incredible with these changes. The pop goes the building thing was one of the biggest immersion killers in the sim, for me, at least.

  • Like 1

Share this post


Link to post
Share on other sites

damn mue! I was close to that myself so kudos again for your involvement! I postesd the extended draw range and fading shaders in several of my treemods as I made discoveries but couldn't unti lrecently come up with the correct setings for the A->B fade distance ranges, much appreciated!


Oh! It works for buildings too? Can't test at the moment so please verify

 

Mue one more thing I'd like to ask you sir -have you considered tweaking the alphaobject shader so it adds sun position lighting and specular map to diffuse? Then we could have even better looking TODs

Share this post


Link to post
Share on other sites

Oh! It works for buildings too? Can't test at the moment so please verify

 

Yes. But that was a bit more tricky. The computation of the alpha value is the same as in teralphaobject.fx. The problem is, that the actual blending is done outside the vertex/pixel shaders. And with ObjectesFade = FALSE the blending is switched off for solid objects. Fortunately I found that the blending can be switched on in the shader file with SetBlendState(...) (It's near the end of the tersolidobject.fx file).

 

Mue one more thing I'd like to ask you sir -have you considered tweaking the alphaobject shader so it adds sun position lighting and specular map to diffuse? Then we could have even better looking TODs

 

 

If I have time I will have a look.

  • Like 1

Share this post


Link to post
Share on other sites

excellent find about the solid objects blending! You are definitely up to something

Share this post


Link to post
Share on other sites

I tried this and it is amazing being able to see mountains in the distance.   

 

However, does anyone have an idea on how to fix the issue illustrated below? It occurs when the camera is low to the ground at low viewing angles relative to ground objects.

 

post-56847-0-31454500-1430527642_thumb.jpg

 

post-56847-0-72131600-1430527744_thumb.jpg

 

post-56847-0-76433800-1430527807_thumb.jpg

Edited by KJakker

Share this post


Link to post
Share on other sites

After setting the ini to fade = false , my buildings pop up rather than fade in albeit at a further distance....anyone else?

Share this post


Link to post
Share on other sites

After setting the ini to fade = false , my buildings pop up rather than fade in albeit at a further distance....anyone else?

I find that too, just not as often as it used to happen. I believe you're going to encounter some, simply because of the way the game engine works, if I'm understanding things correctly. What this mod does for me is put those issues far off in the distance on my relatively modest computer system (8gigs ram, Quad core, 1gig nvidia card). That I can live with, as opposed to whole blocks of cities popping in and out relatively nearby during a dogfight. The settings I use for this mod are 18000/3000 and DetailMeshSize=11 based off of Mue's formula. These settings give me the best compromise between distance and frame rate on my system. The mod doesn't end all the graphical problems with TK's game engine, but it does eliminate a lot of the constantly irritating immersion issues for me, that's why I'm loving this.

Share this post


Link to post
Share on other sites

I updated the shaders in my first post. I found and fixed a bug in the original part of the shader code (so don't blame me). The distances of objects that are not in the view center were miscalculated. That can result in objects still popping up (instead of fading) outside of the view center especially near the screen border.

With the fixed shaders (and if DetailMeshSize is correctly set) TODs should no longer pop up.

Share this post


Link to post
Share on other sites

I updated the shaders in my first post. I found and fixed a bug in the original part of the shader code (so don't blame me). The distances of objects that are not in the view center were miscalculated. That can result in objects still popping up (instead of fading) outside of the view center especially near the screen border.

 

wonder if that part could be applied to clouds shader so we won't have clouds disappearing near the corners of the screen, though I DO realize these are calculated bit differently as these are billboards and when close t othe camera or at very large scale can mess thigns up a bit

Share this post


Link to post
Share on other sites

Thanks for the update, Mue. This mod really transforms the sim for me. Incredible work.

Share this post


Link to post
Share on other sites

Wow I feel dumb....Still no effect for me.

Set objects to fade in Flightdata.ini in flight folder

Set DetailMeshsize to 12 on unlimited

placed shader inis in actual terrain folder i.e. Panama, GermanyCEV3 etc....

used Hecks setting of 18000/3000

 

?

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

×

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..