local transforms = asset.require("./venus")



local Atmosphere = {
  Identifier = "VenusAtmosphere",
  Parent = transforms.Venus.Identifier,
  Renderable = {
    Type = "RenderableAtmosphere",
    -- Atmosphere radius in Km
    AtmosphereHeight = 6121.9 - 6051.9,
    PlanetRadius = 6051.9,
    PlanetAverageGroundReflectance = 0.018,
    GroundRadianceEmission = 0.8,
    SunIntensity = 11.47,
    Rayleigh = {
      Coefficients = {
          -- Wavelengths are given in 10^-9m
          Wavelengths = { 680, 550, 440 },
          -- Reflection coefficients are given in km^-1
          Scattering = { 0.019518, 0.01383, 0.00365 }
          -- In Rayleigh scattering, the coefficients of
          -- absorption and scattering are the same.
      },
      -- Thickness of atmosphere if its density were uniform, in Km
      H_R = 15.9 -- from https://nssdc.gsfc.nasa.gov/planetary/factsheet/venusfact.html
      -- H_R = 3.53
    },
    -- Default
    Mie = {
      Coefficients = {
        -- Reflection coefficients are given in km^-1
        Scattering = { 0.05361771, 0.05361771, 0.05361771 },
        -- Extinction coefficients are a fraction of the Scattering coefficients
        Extinction = { 0.05361771 / 0.98979, 0.05361771 / 0.98979, 0.05361771 / 0.98979 }
      },
      -- Mie Height scale (atmosphere thickness for constant density) in Km
      H_M = 5.42,
      -- Mie Phase Function Value (G e [-1.0, 1.0].
      -- If G = 1.0, Mie phase function = Rayleigh Phase Function)
      G = 0.85
    },
    Debug = {
      PreCalculatedTextureScale = 1.0,
      SaveCalculatedTextures = false
    }
  },
  GUI = {
    Name = "Venus Atmosphere",
    Path = "/Solar System/Planets/Venus",
    Description = "Simulation of Venus' Atmosphere"
  }
}


asset.onInitialize(function()
  openspace.addSceneGraphNode(Atmosphere)
end)

asset.onDeinitialize(function()
  openspace.removeSceneGraphNode(Atmosphere)
end)

asset.export(Atmosphere)



asset.meta = {
  Name = "Venus Atmosphere",
  Version = "1.1",
  Description = "Atmosphere of Venus",
  Author = "OpenSpace Team",
  URL = "http://openspaceproject.com",
  License = "MIT license"
}
