Jump to content

Recommended Posts

Posted

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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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