Add realistic physics, and more realistic sky and lighting into this shade roblox script:

```
--[[
    Advanced and Optimized Visual Enhancements for Roblox
    - Configures detailed Lighting and Post-Processing for a "Midday Lite" aesthetic.
    - Implements a dynamic day-night cycle and advanced weather systems.
    - Adds environmental audio that adapts to time and weather.
    - Introduces dynamic customization for objects based on lighting.
    - Optimizes performance for smooth gameplay across devices.
    - Place this script in StarterPlayerScripts for client-side execution.
--]]

-- === Services ===
local Lighting = game:GetService("Lighting")
local RunService = game:GetService("RunService")
local TweenService = game:GetService("TweenService")
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Workspace = game:GetService("Workspace")

-- === Constants ===
local PLAYER = Players.LocalPlayer
local UPDATE_RATE = 1 / 30 -- 30 FPS update rate
local DAY_DURATION = 120 -- Seconds for a full day cycle
local WEATHER_CHANGE_INTERVAL = 60 -- Seconds between weather changes
local MAX_FOG_DISTANCE = 1000
local MIN_FOG_DISTANCE = 50

local WEATHER_TYPES = {"Clear", "Rain", "Foggy", "Storm"}

-- === Initialization ===
local currentTime = 14 * 60 * 60 -- Start at 14:00:00 (midday) in seconds
local currentWeather = "Clear"
local lastWeatherChange = 0

-- Cached References for Efficiency
local postProcessEffects = {}
local activeAudioSources = {}
local dynamicObjects = {}

-- === Utility Functions ===

-- Function to format time in HH:MM:SS
local function formatTime(seconds)
    local hours = math.floor(seconds / 3600) % 24
    local minutes = math.floor((seconds % 3600) / 60)
    local secs = math.floor(seconds % 60)
    return string.format("%02d:%02d:%02d", hours, minutes, secs)
end

-- Function to interpolate between two values
local function lerp(a, b, t)
    return a + (b - a) * t
end

-- Function to interpolate between two colors
local function lerpColor(color1, color2, alpha)
    return color1:Lerp(color2, alpha)
end

-- Function to clear existing PostProcess effects to prevent duplication
local function clearPostProcesses()
    for _, effect in ipairs(Lighting:GetChildren()) do
        if effect:IsA("PostProcess") then
            effect:Destroy()
        end
    end
    postProcessEffects = {}
end

-- Function to clear existing Audio sources
local function clearAudioSources()
    for _, audio in ipairs(activeAudioSources) do
        if audio and audio.Playing then
            audio:Stop()
            audio:Destroy()
        end
    end
    activeAudioSources = {}
end

-- Function to apply realistic materials to all BaseParts
local function applyRealisticMaterials()
    for _, part in ipairs(Workspace:GetDescendants()) do
        if part:IsA("BasePart") then
            if part.Material ~= Enum.Material.SmoothPlastic then
                part.Material = Enum.Material.SmoothPlastic
            end
            if part.Reflectance < 0.05 then
                part.Reflectance = 0.05 -- Slight reflectivity
            end
        end
    end
end

-- Function to create and apply PostProcess effects
local function setupPostProcessEffects()
    -- Color Correction
    local colorCorrection = Instance.new("ColorCorrectionEffect")
    colorCorrection.Name = "AdvancedColorCorrection"
    colorCorrection.Brightness = 0.1
    colorCorrection.Contrast = 0.2
    colorCorrection.Saturation = 0.3
    colorCorrection.TintColor = Color3.fromRGB(255, 255, 255)
    colorCorrection.Enabled = true
    colorCorrection.Parent = Lighting
    table.insert(postProcessEffects, colorCorrection)

    -- Bloom Effect
    local bloom = Instance.new("BloomEffect")
    bloom.Name = "AdvancedBloom"
    bloom.Intensity = 0.5
    bloom.Size = 24
    bloom.Threshold = 3
    bloom.Enabled = true
    bloom.Parent = Lighting
    table.insert(postProcessEffects, bloom)

    -- Depth of Field
    local depthOfField = Instance.new("DepthOfFieldEffect")
    depthOfField.Name = "AdvancedDOF"
    depthOfField.FarIntensity = 0.2
    depthOfField.FocusDistance = 500
    depthOfField.FocusRange = 50
    depthOfField.Enabled = true
    depthOfField.Parent = Lighting
    table.insert(postProcessEffects, depthOfField)

    -- Sun Rays Effect
    local sunRays = Instance.new("SunRaysEffect")
    sunRays.Name = "AdvancedSunRays"
    sunRays.Intensity = 0.3
    sunRays.Spread = 1
    sunRays.Enabled = true
    sunRays.Parent = Lighting
    table.insert(postProcessEffects, sunRays)

    -- Stars Effect (Initially Disabled)
    local stars = Instance.new("StarsEffect")
    stars.Name = "DynamicStars"
    stars.Intensity = 1
    stars.Spread = 1
    stars.Quality = Enum.StarsEffectQuality.High
    stars.Enabled = false
    stars.Parent = Lighting
    table.insert(postProcessEffects, stars)
end

-- Function to set up the Skybox
local function setupSkybox()
    local sky = Instance.new("Sky")
    sky.Name = "AdvancedSkybox"
    -- Replace with your own Skybox asset IDs
    sky.SkyboxBk = "rbxassetid://YOUR_SKYBOX_BACK_ID"
    sky.SkyboxDn = "rbxassetid://YOUR_SKYBOX_DOWN_ID"
    sky.SkyboxFt = "rbxassetid://YOUR_SKYBOX_FRONT_ID"
    sky.SkyboxLf = "rbxassetid://YOUR_SKYBOX_LEFT_ID"
    sky.SkyboxRt = "rbxassetid://YOUR_SKYBOX_RIGHT_ID"
    sky.SkyboxUp = "rbxassetid://YOUR_SKYBOX_UP_ID"
    sky.Parent = Lighting
end

-- Function to initialize all visual settings
local function initializeVisuals()
    clearPostProcesses()
    clearAudioSources()
    applyRealisticMaterials()
    setupPostProcessEffects()
    setupSkybox()

    -- Lighting Configuration for "Midday Lite"
    Lighting.TimeOfDay = "14:00:00" -- Start at midday
    Lighting.Brightness = 2
    Lighting.Ambient = Color3.fromRGB(200, 200, 200)
    Lighting.OutdoorAmbient = Color3.fromRGB(200, 200, 200)
    Lighting.FogColor = Color3.fromRGB(220, 220, 255)
    Lighting.FogStart = 100
    Lighting.FogEnd = 500
    Lighting.GlobalShadows = true
    Lighting.FogDensity = 0.002
    Lighting.EnvironmentDiffuseScale = 2
    Lighting.EnvironmentSpecularScale = 1
    Lighting.ShadowSoftness = 0.3
    Lighting.FresnelBias = 0.1
    Lighting.FresnelPower = 5

    print("Visuals Initialized Successfully!")
end

-- === Day-Night Cycle Functions ===

-- Function to update Lighting based on current time
local function updateLightingForTime()
    local hours = math.floor(currentTime / 3600) % 24
    local minutes = math.floor((currentTime % 3600) / 60)
    local seconds = math.floor(currentTime % 60)
    local formattedTime = formatTime(currentTime)

    Lighting.TimeOfDay = formattedTime

    -- Define color gradients for day and night
    local dayColor = Color3.fromRGB(200, 200, 200)
    local nightColor = Color3.fromRGB(50, 50, 70)

    -- Determine if it's day or night
    local isDay = hours >= 6 and hours < 18

    -- Smooth transition between day and night
    local alpha
    if isDay then
        alpha = lerp((hours + minutes / 60 + seconds / 3600 - 6) / 12, 1, 0)
    else
        alpha = lerp(((hours + minutes / 60 + seconds / 3600) % 24 - 18) / 12, 0, 1)
    end

    -- Update Ambient and OutdoorAmbient
    Lighting.Ambient = isDay and dayColor or nightColor
    Lighting.OutdoorAmbient = isDay and dayColor or nightColor

    -- Update FogColor based on time
    local fogDay = Color3.fromRGB(220, 220, 255)
    local fogNight = Color3.fromRGB(60, 60, 80)
    Lighting.FogColor = isDay and fogDay or fogNight

    -- Adjust Brightness
    Lighting.Brightness = isDay and 2 or 0.5

    -- Toggle Stars Effect
    local stars = Lighting:FindFirstChild("DynamicStars")
    if stars then
        stars.Enabled = not isDay
    end

    -- Adjust Post-Processing for Day/Night
    local colorCorrection = Lighting:FindFirstChild("AdvancedColorCorrection")
    if colorCorrection then
        if isDay then
            colorCorrection.Contrast = lerp(colorCorrection.Contrast, 0.2, 0.02)
            colorCorrection.Saturation = lerp(colorCorrection.Saturation, 0.3, 0.02)
        else
            colorCorrection.Contrast = lerp(colorCorrection.Contrast, -0.2, 0.02)
            colorCorrection.Saturation = lerp(colorCorrection.Saturation, 0.1, 0.02)
        end
    end
end

-- === Weather System Functions ===

-- Function to create and play a sound
local function playSound(soundId, volume, looped, parent)
    local sound = Instance.new("Sound")
    sound.SoundId = soundId
    sound.Volume = volume
    sound.Looped = looped
    sound.Parent = parent
    sound:Play()
    table.insert(activeAudioSources, sound)
    return sound
end

-- Function to create and add a particle emitter
local function addParticleEmitter(emitterName, parent)
    local emitter = ReplicatedStorage:FindFirstChild(emitterName)
    if emitter then
        local clonedEmitter = emitter:Clone()
        clonedEmitter.Parent = parent
        return clonedEmitter
    else
        warn("Emitter " .. emitterName .. " not found in ReplicatedStorage.")
        return nil
    end
end

-- Function to change the current weather
local function changeWeather(newWeather)
    if newWeather == currentWeather then return end

    -- Clear previous weather effects
    clearAudioSources()

    -- Access Post-Processing Effects
    local colorCorrection = Lighting:FindFirstChild("AdvancedColorCorrection")
    local bloom = Lighting:FindFirstChild("AdvancedBloom")
    local depthOfField = Lighting:FindFirstChild("AdvancedDOF")
    local sunRays = Lighting:FindFirstChild("AdvancedSunRays")

    if not (colorCorrection and bloom and depthOfField and sunRays) then
        warn("One or more Post-Processing effects are missing!")
        return
    end

    -- Tween Settings for Smooth Transitions
    local tweenInfo = TweenInfo.new(2, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)

    -- Apply Weather-Specific Settings
    if newWeather == "Clear" then
        -- Clear Weather Lighting Adjustments
        TweenService:Create(colorCorrection, tweenInfo, {
            Saturation = 0.3,
            Contrast = 0.2,
            Brightness = 0.1,
            TintColor = Color3.fromRGB(255, 255, 255)
        }):Play()

        TweenService:Create(bloom, tweenInfo, {
            Intensity = 0.5,
            Threshold = 3
        }):Play()

        TweenService:Create(depthOfField, tweenInfo, {
            FarIntensity = 0.2,
            FocusDistance = 500,
            FocusRange = 50
        }):Play()

        TweenService:Create(sunRays, tweenInfo, {
            Intensity = 0.3,
            Spread = 1
        }):Play()

        -- Play Clear Weather Audio (e.g., Birds Chirping)
        playSound("rbxassetid://301964312", 0.5, true, Lighting) -- Birds Chirping

    elseif newWeather == "Rain" then
        -- Rain Weather Lighting Adjustments
        TweenService:Create(colorCorrection, tweenInfo, {
            Saturation = 0.1,
            Contrast = 0.1,
            Brightness = 0.0,
            TintColor = Color3.fromRGB(150, 150, 160)
        }):Play()

        TweenService:Create(bloom, tweenInfo, {
            Intensity = 0.3,
            Threshold = 2
        }):Play()

        TweenService:Create(depthOfField, tweenInfo, {
            FarIntensity = 0.3,
            FocusDistance = 450,
            FocusRange = 100
        }):Play()

        TweenService:Create(sunRays, tweenInfo, {
            Intensity = 0.1,
            Spread = 0.5
        }):Play()

        -- Add Rain Particle Emitter
        local rainEmitter = addParticleEmitter("RainEmitter", Workspace)
        if rainEmitter then
            table.insert(dynamicObjects, rainEmitter)
        end

        -- Play Rain Sound
        playSound("rbxassetid://200602136", 0.7, true, Lighting) -- Rain Sound

    elseif newWeather == "Foggy" then
        -- Foggy Weather Lighting Adjustments
        TweenService:Create(colorCorrection, tweenInfo, {
            Saturation = 0.2,
            Contrast = 0.15,
            Brightness = 0.05,
            TintColor = Color3.fromRGB(200, 200, 220)
        }):Play()

        TweenService:Create(bloom, tweenInfo, {
            Intensity = 0.4,
            Threshold = 2.5
        }):Play()

        TweenService:Create(depthOfField, tweenInfo, {
            FarIntensity = 0.25,
            FocusDistance = 480,
            FocusRange = 80
        }):Play()

        TweenService:Create(sunRays, tweenInfo, {
            Intensity = 0.2,
            Spread = 0.8
        }):Play()

        -- Adjust Fog End Distance
        TweenService:Create(Lighting, tweenInfo, {
            FogEnd = 200
        }):Play()

        -- Play Fog Sound
        playSound("rbxassetid://301964312", 0.4, true, Lighting) -- Ambient Fog Sound

    elseif newWeather == "Storm" then
        -- Storm Weather Lighting Adjustments
        TweenService:Create(colorCorrection, tweenInfo, {
            Saturation = 0.0,
            Contrast = 0.3,
            Brightness = -0.1,
            TintColor = Color3.fromRGB(100, 100, 120)
        }):Play()

        TweenService:Create(bloom, tweenInfo, {
            Intensity = 0.2,
            Threshold = 1.5
        }):Play()

        TweenService:Create(depthOfField, tweenInfo, {
            FarIntensity = 0.4,
            FocusDistance = 400,
            FocusRange = 60
        }):Play()

        TweenService:Create(sunRays, tweenInfo, {
            Intensity = 0.05,
            Spread = 0.3
        }):Play()

        -- Add Storm Particle Emitter
        local stormEmitter = addParticleEmitter("StormEmitter", Workspace)
        if stormEmitter then
            table.insert(dynamicObjects, stormEmitter)
        end

        -- Play Thunder Sound
        playSound("rbxassetid://5390661340", 0.6, false, Lighting) -- Thunder Sound

        -- Optional: Implement Lightning Flashes (Requires Additional Scripting)

    else
        warn("Unknown weather type:", newWeather)
    end

    currentWeather = newWeather
    print("Weather changed to:", currentWeather)
end

-- Function to select a random weather condition
local function getRandomWeather()
    local index = math.random(1, #WEATHER_TYPES)
    return WEATHER_TYPES[index]
end

-- Function to update weather periodically
local function updateWeather(deltaTime)
    lastWeatherChange = lastWeatherChange + deltaTime
    if lastWeatherChange >= WEATHER_CHANGE_INTERVAL then
        lastWeatherChange = 0
        local newWeather = getRandomWeather()
        changeWeather(newWeather)
    end
end

-- === Dynamic Object Customization ===

-- Function to dynamically customize objects based on lighting
local function customizeObjects()
    for _, part in ipairs(Workspace:GetDescendants()) do
        if part:IsA("BasePart") and part.CanCollide then
            local originalColor = part.Color
            local highlight = part:FindFirstChild("Highlight") or Instance.new("Highlight")
            highlight.Name = "Highlight"
            highlight.FillTransparency = 1
            highlight.OutlineColor = Color3.new(1, 1, 1)
            highlight.OutlineTransparency = 0.5
            highlight.Parent = part

            -- Adjust Highlight based on brightness
            local brightnessFactor = Lighting.Brightness / 2
            highlight.FillColor = lerpColor(Color3.new(1, 1, 1), originalColor, brightnessFactor)
            highlight.FillTransparency = 1 - brightnessFactor
        end
    end
end

-- Function to update dynamic object customization
local function updateDynamicCustomization()
    customizeObjects()
end

-- === Environmental Audio Management ===

-- Function to stop and remove an audio source
local function removeAudio(audio)
    if audio and audio.Playing then
        audio:Stop()
    end
    if audio.Parent then
        audio:Destroy()
    end
end

-- Function to manage audio based on weather
local function manageAudio()
    -- Audio is managed within the changeWeather function
    -- Additional audio management can be implemented here if needed
end

-- === Performance Optimization ===

-- Function to optimize updates (placeholder for future optimizations)
local function optimizeUpdates()
    -- Currently, operations are efficient
    -- Future optimizations can be added based on specific game needs
end

-- === Dynamic Starfield ===

-- Function to toggle Stars Effect based on time
local function toggleStars()
    local stars = Lighting:FindFirstChild("DynamicStars")
    if not stars then return end

    local hours = math.floor(currentTime / 3600) % 24
    if hours >= 19 or hours < 6 then
        stars.Enabled = true
    else
        stars.Enabled = false
    end
end

-- === Main Loop ===

-- Initialize Visual Settings
initializeVisuals()

-- Start with Clear Weather
changeWeather("Clear")

-- Apply Dynamic Customization Initially
updateDynamicCustomization()

-- Connect to RenderStepped for smooth updates
RunService.RenderStepped:Connect(function(deltaTime)
    -- Update Time
    currentTime = currentTime + deltaTime * (24 * 60 * 60 / DAY_DURATION) -- Adjust for DAY_DURATION
    if currentTime >= 24 * 60 * 60 then
        currentTime = currentTime - 24 * 60 * 60
    end

    -- Update Lighting based on Time
    updateLightingForTime()

    -- Update Weather
    updateWeather(deltaTime)

    -- Update Dynamic Object Customization
    updateDynamicCustomization()

    -- Manage Environmental Audio
    manageAudio()

    -- Toggle Stars Effect
    toggleStars()

    -- Apply Optimizations
    optimizeUpdates()
end)

-- === Additional Features ===

-- Function to add Lightning Flashes during Storm (Optional)
local function addLightningEffect()
    if currentWeather ~= "Storm" then return end

    while currentWeather == "Storm" do
        wait(math.random(5, 15)) -- Random interval between lightning
        -- Flash the screen
        local flash = Instance.new("Frame")
        flash.Size = UDim2.new(1, 0, 1, 0)
        flash.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
        flash.BackgroundTransparency = 1
        flash.ZIndex = 10
        flash.Parent = PLAYER:WaitForChild("PlayerGui")

        -- Tween the Transparency to create a flash effect
        local tween = TweenService:Create(flash, TweenInfo.new(0.05, Enum.EasingStyle.Linear, Enum.EasingDirection.Out),
            {BackgroundTransparency = 0})

        tween:Play()
        tween.Completed:Wait()

        tween = TweenService:Create(flash, TweenInfo.new(0.15, Enum.EasingStyle.Linear, Enum.EasingDirection.Out),
            {BackgroundTransparency = 1})

        tween:Play()
        tween.Completed:Wait()

        flash:Destroy()
    end
end

-- Start Lightning Effect when Storm starts
RunService.RenderStepped:Connect(function()
    if currentWeather == "Storm" then
        coroutine.wrap(addLightningEffect)()
    end
end)

-- Function to apply advanced textures to objects (Optional)
local function applyAdvancedTextures()
    for _, part in ipairs(Workspace:GetDescendants()) do
        if part:IsA("BasePart") and not part:FindFirstChildOfClass("Texture") then
            local texture = Instance.new("Texture")
            texture.Name = "AdvancedTexture"
            texture.Texture = "rbxassetid://YOUR_TEXTURE_ID" -- Replace with your texture ID
            texture.StudsPerTileU = 1
            texture.StudsPerTileV = 1
            texture.Parent = part
        end
    end
end

-- Uncomment to apply advanced textures
applyAdvancedTextures()

-- Function to set up Dynamic Reflections using Skybox
local function setupDynamicReflections()
    -- Ensure the Skybox is set up
    setupSkybox()
    -- Additional reflection settings can be added here
end

-- Uncomment to set up Dynamic Reflections
setupDynamicReflections()

-- === Dynamic Customization GUI (Optional) ===

--[[
    To enable dynamic customization via a GUI, create a ScreenGui with controls.
    This section provides a basic framework for such customization.
    You can expand upon this to allow players to change lighting settings in-game.
--]]

-- Function to create a Dynamic Customization GUI
local function createCustomizationGUI()
    local player = Players.LocalPlayer
    local playerGui = player:WaitForChild("PlayerGui")

    local screenGui = Instance.new("ScreenGui")
    screenGui.Name = "CustomizationGUI"
    screenGui.Parent = playerGui

    local frame = Instance.new("Frame")
    frame.Size = UDim2.new(0.3, 0, 0.4, 0)
    frame.Position = UDim2.new(0.35, 0, 0.3, 0)
    frame.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
    frame.BackgroundTransparency = 0.5
    frame.Parent = screenGui

    -- Add Buttons or Sliders for customization
    local brightnessSlider = Instance.new("TextLabel")
    brightnessSlider.Size = UDim2.new(0.8, 0, 0.1, 0)
    brightnessSlider.Position = UDim2.new(0.1, 0, 0.1, 0)
    brightnessSlider.BackgroundColor3 = Color3.fromRGB(100, 100, 100)
    brightnessSlider.BackgroundTransparency = 0.3
    brightnessSlider.Text = "Brightness"
    brightnessSlider.TextColor3 = Color3.new(1, 1, 1)
    brightnessSlider.Parent = frame

    local brightnessInput = Instance.new("TextBox")
    brightnessInput.Size = UDim2.new(0.8, 0, 0.1, 0)
    brightnessInput.Position = UDim2.new(0.1, 0, 0.25, 0)
    brightnessInput.BackgroundColor3 = Color3.fromRGB(150, 150, 150)
    brightnessInput.Text = tostring(Lighting.Brightness)
    brightnessInput.Parent = frame

    brightnessInput.FocusLost:Connect(function()
        local newValue = tonumber(brightnessInput.Text)
        if newValue and newValue >= 0 and newValue <= 10 then
            Lighting.Brightness = newValue
        else
            brightnessInput.Text = tostring(Lighting.Brightness)
        end
    end)

    -- Add more customization controls as needed (e.g., contrast, saturation)
end

-- Uncomment to create the customization GUI
-- createCustomizationGUI()

-- === Dynamic Object Customization Example ===

-- Function to dynamically change object properties based on lighting
local function dynamicObjectCustomization()
    for _, part in ipairs(Workspace:GetDescendants()) do
        if part:IsA("BasePart") then
            -- Example: Change transparency based on lighting brightness
            part.Transparency = lerp(0, 0.5, Lighting.Brightness / 2)
        end
    end
end

-- Call dynamic customization in the main loop
RunService.RenderStepped:Connect(function(deltaTime)
    -- ... existing code ...

    -- Update dynamic object customization based on Lighting
    dynamicObjectCustomization()
end)

-- === Final Notes ===

print("Advanced and Optimized Visual Enhancements Loaded Successfully!")