Results 1 to 1 of 1

Thread: Ultiimate Sky and Clouds lua script

  1. #1

    Lightbulb Ultiimate Sky and Clouds lua script

    I have tried several lua scripts to get my Xplane11 environment the way I like it, but I wanted to consolidate all of them with my modifications into one script that uses the default Xplane11 sky and cloud bitmaps and maximized performance on systems with low VRAM, like mine, which only has 3GB VRAM below I am pasting the result for forum members and Xplane11 simmers. I have uploaded the same script to the Flightsim.com file library, but it has not been posted there yet, so I am also making it available here. I have used the coding and logic suggested by the lua experts, but I found some challenges, especially cloud shadows that were too faint.

    I have corrected those challenges, and also have changed the haze settings to be less sharp at a distance, closer to an average flight world wide rather than a flight with pristine conditions. I am also including a link to an almost 30 minute youtube video I made on 9-26-19 to show how the environment looked on the quite stormy day we had in Arizona yesterday, with building mesocyclones, one of which I almost got nailed by as I was walking home with my arms full of groceries--the heavy rain and thunder you will hear reported in the ATC background swept in from east of Sky Harbor and hit my part of the city hard, for a full week of Hurricane Lorena leftovers including a Tornado Monday night.

    ___________________

    --Hello! Welcome to John Cillis's combined lua tweaks! It's pretty extensive, so it may conflict with similar luas, that is why I have made it one script. Please scroll down and have a read, there's some important notes to be had shared by other lua experts:

    --Add -- before set( to disable effects

    --Go down to the DSF section for an important note for anyone using VR!

    --Clouds
    --overdraw_control affects how many clouds are drawn. Higher numbers mean less cloud puffs but better performance.
    --plot_radius affects size of cloud puffs, reduce this if you encounter clipping issues. My personal sweet spot is 1.25
    --Suggested overdraw_control value is 0.5, will give you more puffs than default, and should cost less in performance than the initial value
    --Lua was designed around the Default XP11 Clouds, your mileage may vary with different textures
    --Custom Values for cloud type start at 3 and end at 5, default has first res set at 0

    set( "sim/private/controls/clouds/ambient_gain", 1.155)
    set( "sim/private/controls/clouds/diffuse_gain", 0.8)
    set( "sim/private/controls/clouds/first_res_3d", 3)
    set( "sim/private/controls/clouds/last_res_3d", 5)
    set( "sim/private/controls/clouds/overdraw_control", 0.5)
    set( "sim/private/controls/clouds/plot_radius", 1.5)
    set( "sim/private/controls/clouds/cloud_shadow_lighten_ratio", .99)
    set( "sim/private/controls/clouds/shad_radius", 1.0)
    set( "sim/private/controls/clouds/limit_far", 0.1)
    set( "sim/private/controls/clouds/shadow_size", 4096)
    set("sim/private/controls/shadow/cockpit_near_adjust", 2.0)
    set("sim/private/controls/shadow/cockpit_near_proxy", 2.0)

    --Sky
    --I've honestly forgotten what this does, but if you toy around with it I'm sure you'll be able to find out.
    --I think the default value for the first is 13? I wrote this part a fair while back, but I believe it has something to do with the fullness of the colours, I.E a less thin horizon, for instance.

    set( "sim/private/controls/atmo/atmo_scale_raleigh", 10)
    set( "sim/private/controls/atmo/inscatter_gain_raleigh", 2)

    --Fog
    --Higher Number = More Fog, contrary to the name of the value

    set( "sim/private/controls/fog/fog_be_gone", 0.8)

    --Cars
    --Controls distance cars are visible and...Don't know what lod_hdr does, but it saved me frames being lower and I saw no visible difference.
    --Default value for both is 20000

    set( "sim/private/controls/cars/lod_min", 7000.000000)
    set( "sim/private/controls/cars/lod_hdr", 2000.000000)

    --DSF
    --The first value controls the minimum view distance of the Distant Scenery textures.
    --These settings below have a small performance impact in particular. If your FPS is hit, lower the min_dsf_vis_ever value. Default is 20000
    --If you have a VR setup, it would be wise to comment out the first value, as others reported issues when it was active.


    set( "sim/private/controls/skyc/min_dsf_vis_ever", 15000)
    set( "sim/private/controls/skyc/max_dsf_vis_ever", 100000)
    set( "sim/private/controls/skyc/dsf_fade_ratio", 0.75)
    set( "sim/private/controls/skyc/dsf_cutover_scale", 1)

    --Shadows
    --Controls the angle shadows are visible. Not typically necessary as lots of people use shadow tweaks already. Add a -- in front of both of the settings if you are one of those people. Default values are 15 and 5 respectively
    --The Cam size controls shadow resolution, may affect FPS. Disable to get more jaggy shadows but possibly more performance

    set( "sim/private/controls/skyc/max_shadow_angle",-89)
    set( "sim/private/controls/skyc/min_shadow_angle",-90)
    set( "sim/private/controls/fbo/shadow_cam_size", 8192)

    --White Out Inside Clouds
    --This is seperate because I haven't tested this value enough yet. It seems to work fine, and visibility changes appear to still happen regularly going through many cloud layers, but there could be unforseen issues. If there are any, leave a comment on the .org or PM me on X-Pilot

    set( "sim/private/controls/skyc/white_out_in_clouds", 0)

    --X-Visibility Plugin
    --For X-Plane 11.25+
    --Developed by: ChinNoobonic & SNowblind7
    xvis_version = "1.0.2"
    xvis_build = "2018-09-23"

    --PLUGIN OPTIONS
    xvis_plugin_on = true --enable plugin
    xvis_debug_info = false --show debug info
    xvis_atmoTop_visibility = 30480 --elevation to apply the max visibility, default is 30480 m
    xvis_minFog_value = 0.6 --minimum fog value. Recommending values 0.0-1.0, default is 0.6
    xvis_atmoTop_Fog = 1.5 --fog value after passing atmoTop_visibility
    xvis_highAltFogMult = 1 --reduce to 0.5 or 0.25 if you feel the haze at higher altitude is too strong, default is 1

    -------------------------------------------------------------------------------------------------------
    --INTERNAL VARIABLES (Don´t change!)
    dataref("gnd_imm_max","sim/private/controls/skyc/gnd_imm_max", "writable")
    dataref("lit_imm_max","sim/private/controls/skyc/lit_imm_max", "writable")
    dataref("lit_imm_min","sim/private/controls/skyc/lit_imm_min", "writable")
    dataref("sky_imm_max","sim/private/controls/skyc/sky_imm_max", "writable")
    dataref("sky_imm_min","sim/private/controls/skyc/sky_imm_min", "writable")
    dataref("cld_imm_max","sim/private/controls/skyc/cld_imm_max", "writable")
    dataref("cld_imm_min","sim/private/controls/skyc/cld_imm_min", "writable")
    dataref("visibility_reported_m","sim/weather/visibility_reported_m", "readonly")
    dataref("realFrame_time","sim/operation/misc/frame_rate_period","readonly")
    dataref("view_y_meters", "sim/graphics/view/view_y", "readonly", 0)
    dataref("fog_be_gone", "sim/private/controls/fog/fog_be_gone", "writable")
    dataref("vis_graphical","sim/private/stats/skyc/fog/far_fog_cld", "readonly")

    gnd_imm_max = 20
    cld_imm_max = -1
    cld_imm_min = 0
    local fog_threshold = 1
    -------------------------------------------------------------------------------------------------------

    function change_visbility()
    if xvis_plugin_on then

    local fog_Ratio = (vis_graphical * xvis_highAltFogMult)/visibility_reported_m

    if xvis_minFog_value > fog_threshold then
    fog_threshold = xvis_minFog_value
    end

    if visibility_reported_m >= 9000 then
    sky_imm_max = -1
    sky_imm_min = 0
    lit_imm_max = 1
    lit_imm_min = 0
    elseif visibility_reported_m < 9000 then
    sky_imm_max = 20
    sky_imm_min = -2
    lit_imm_max = -1
    lit_imm_min = -34
    end

    if fog_Ratio > fog_threshold+0.1 and view_y_meters < xvis_atmoTop_visibility then
    if fog_be_gone <= fog_Ratio-0.1 then
    fog_be_gone = fog_be_gone + realFrame_time * fog_Ratio
    else
    fog_be_gone = fog_Ratio
    end
    elseif math.floor(view_y_meters+.5) >= xvis_atmoTop_visibility then
    if fog_be_gone >= xvis_atmoTop_Fog+0.1 then
    fog_be_gone = fog_be_gone - realFrame_time * fog_be_gone
    else
    fog_be_gone = xvis_atmoTop_Fog
    end
    else
    if fog_be_gone >= xvis_minFog_value+0.1 then
    fog_be_gone = fog_be_gone - realFrame_time * fog_be_gone
    else
    fog_be_gone = xvis_minFog_value
    end
    end

    end

    end

    function draw_debug()
    local infoBox_x = 40
    local infoBox_y = 600
    local line_pos = 0
    graphics.set_color( 1, 1, 0)

    line_pos = line_pos-12
    draw_string_Helvetica_12( infoBox_x, infoBox_y+line_pos, "reported_vis:" .. visibility_reported_m )
    line_pos = line_pos-12
    draw_string_Helvetica_12( infoBox_x, infoBox_y+line_pos, "calculated_vis:" .. vis_graphical )
    line_pos = line_pos-12
    draw_string_Helvetica_12( infoBox_x, infoBox_y+line_pos, "fog_be_gone:" .. fog_be_gone )
    line_pos = line_pos-12
    draw_string_Helvetica_12( infoBox_x, infoBox_y+line_pos, "view_y_meters:" .. view_y_meters )
    end

    if xvis_debug_info then
    do_every_draw("draw_debug()")
    end

    do_every_frame("change_visbility()")


    Attached Files Attached Files

Similar Threads

  1. TimeStay. lua
    By flytv1 in forum X-Plane
    Replies: 14
    Last Post: 09-06-2018, 10:35 AM
  2. Lua function names
    By stinger2k2 in forum Cockpit Builders
    Replies: 4
    Last Post: 12-06-2016, 04:53 AM
  3. LUA Plug-ins with FSUIPC
    By bobnewhart in forum FS2004
    Replies: 4
    Last Post: 09-27-2013, 04:36 PM
  4. Clouds, clouds and more clouds!!!!!!
    By PHCO in forum MSFS Screen Shot Forum
    Replies: 9
    Last Post: 03-18-2005, 08:43 AM
  5. clouds, clouds, clouds...
    By sehender in forum FS2004
    Replies: 23
    Last Post: 08-16-2004, 11:17 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •