Jump to content
mue

fading tod objects

Recommended Posts

I ported the fading tod objects functionality from the sf2 shaders to the fe2 shaders.

 

fe2_fading_tods_shader.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 = 3000.0;    //in meters
    
    //mue: fadeStartDistance + fadeLength = distance at which the object has alpha = 0.0 (full transparent)
    const float fadeLength = 1000.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 to the rounded up value of (fadeStartDistance + fadeLength) / terrain_tile_size.

E.g. fadeStartDistance = 3000.0, fadeLength = 1000.0 and terrain_tile_size = 500 (stock fe2 terrain_tile_size is 500):

(3000.0 + 1000.0) / 500 = 8.0, rounding up = 8  => DetailMeshSize=8

 

-Set in <terrain>_data.ini

[solidObjectTextureMaterial]

BlendOp=BLEND_SRC_ALPHA (or BLEND_DST_ALPHA)

This makes sure that the tod objects are drawn after the terrain tiles (It's a requirement for the fading to work correctly). Unfortunately this has the negative side effects that the tods don't cast shadows anymore and the shadows cast by target objects are visible through the tods.

Share this post


Link to post
Share on other sites

Got it.  More excellent work - thanks!

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