This file defines the API to use our atmosphere model on CPU. To use it:
Model instance with the desired atmosphere
parameters, and a directory where the precomputed textures can be cached,Init to precompute the atmosphere textures (or read
them from the cache directory if they have already been precomputed),GetSolarRadiance, GetSkyRadiance,
GetSkyRadianceToPoint and GetSunAndSkyIrradiance as
desired,Model when you no longer need it (the destructor
deletes the precomputed textures from memory).
#ifndef ATMOSPHERE_REFERENCE_MODEL_H_
#define ATMOSPHERE_REFERENCE_MODEL_H_
#include <memory>
#include <string>
#include <vector>
#include "atmosphere/reference/definitions.h"
namespace atmosphere {
namespace reference {
class Model {
public:
Model(const AtmosphereParameters& atmosphere,
const std::string& cache_directory);
void Init(unsigned int num_scattering_orders = 4);
RadianceSpectrum GetSolarRadiance() const;
RadianceSpectrum GetSkyRadiance(Position camera, Direction view_ray,
Length shadow_length, Direction sun_direction,
DimensionlessSpectrum* transmittance) const;
RadianceSpectrum GetSkyRadianceToPoint(Position camera, Position point,
Length shadow_length, Direction sun_direction,
DimensionlessSpectrum* transmittance) const;
IrradianceSpectrum GetSunAndSkyIrradiance(Position p, Direction normal,
Direction sun_direction, IrradianceSpectrum* sky_irradiance) const;
private:
const AtmosphereParameters atmosphere_;
const std::string cache_directory_;
std::unique_ptr<TransmittanceTexture> transmittance_texture_;
std::unique_ptr<ReducedScatteringTexture> scattering_texture_;
std::unique_ptr<ReducedScatteringTexture> single_mie_scattering_texture_;
std::unique_ptr<IrradianceTexture> irradiance_texture_;
};
} // namespace reference
} // namespace atmosphere
#endif // ATMOSPHERE_REFERENCE_MODEL_H_