55 const auto surface =
input.get();
56 const auto output_size = surface->get_size();
64 if(atmospheric_program_.program->is_valid())
66 atmospheric_program_.program->begin();
71 float t = (turbidity - 1.9f) / (10.0f - 1.9f);
74 math::vec3 kr_clear(0.12867780436772762f, 0.2478442963618773f, 0.6216065586417131f);
75 math::vec3 kr_hazy(0.05f, 0.1f, 0.25f);
76 math::vec3 u_kr = math::mix(kr_clear, kr_hazy, t);
78 float rayleigh_brightness_clear = 9.0f;
79 float rayleigh_brightness_hazy = 5.0f;
80 float u_rayleigh_brightness = math::mix(rayleigh_brightness_clear, rayleigh_brightness_hazy, t);
82 float mie_brightness_clear = 0.1f;
83 float mie_brightness_hazy = 0.5f;
84 float u_mie_brightness = math::mix(mie_brightness_clear, mie_brightness_hazy, t);
86 float spot_brightness_clear = 10.0f;
87 float spot_brightness_hazy = 5.0f;
88 float u_spot_brightness = math::mix(spot_brightness_clear, spot_brightness_hazy, t);
90 float spot_distance_clear = 300.0f;
91 float spot_distance_hazy = 100.0f;
92 float u_spot_distance = math::mix(spot_distance_clear, spot_distance_hazy, t);
94 float scatter_strength_clear = 0.078f;
95 float scatter_strength_hazy = 0.15f;
96 float u_scatter_strength = math::mix(scatter_strength_clear, scatter_strength_hazy, t);
98 float rayleigh_strength_clear = 0.139f;
99 float rayleigh_strength_hazy = 0.05f;
100 float u_rayleigh_strength = math::mix(rayleigh_strength_clear, rayleigh_strength_hazy, t);
102 float mie_strength_clear = 0.264f;
103 float mie_strength_hazy = 0.5f;
104 float u_mie_strength = math::mix(mie_strength_clear, mie_strength_hazy, t);
106 float rayleigh_collection_power_clear = 0.81f;
107 float rayleigh_collection_power_hazy = 0.6f;
108 float u_rayleigh_collection_power =
109 math::mix(rayleigh_collection_power_clear, rayleigh_collection_power_hazy, t);
111 float mie_collection_power_clear = 0.39f;
112 float mie_collection_power_hazy = 0.6f;
113 float u_mie_collection_power = math::mix(mie_collection_power_clear, mie_collection_power_hazy, t);
115 float mie_distribution_clear = 0.53f;
116 float mie_distribution_hazy = 0.7f;
117 float u_mie_distribution = math::mix(mie_distribution_clear, mie_distribution_hazy, t);
119 float intensity_clear = 1.8f;
120 float intensity_hazy = 0.8f;
121 float u_intensity = math::mix(intensity_clear, intensity_hazy, t);
125 math::vec4 u_kr_and_intensity(u_kr, u_intensity);
126 math::vec4 u_turbidity_parameters1(u_rayleigh_strength, u_mie_strength, u_mie_distribution, u_scatter_strength);
127 math::vec4 u_turbidity_parameters2(u_rayleigh_brightness, u_mie_brightness, u_spot_brightness, u_spot_distance);
128 math::vec4 u_turbidity_parameters3(u_rayleigh_collection_power, u_mie_collection_power, 0.0f, 0.0f);
131 gfx::set_uniform(atmospheric_program_.u_kr_and_intensity, u_kr_and_intensity);
132 gfx::set_uniform(atmospheric_program_.u_turbidity_parameters1, u_turbidity_parameters1);
133 gfx::set_uniform(atmospheric_program_.u_turbidity_parameters2, u_turbidity_parameters2);
134 gfx::set_uniform(atmospheric_program_.u_turbidity_parameters3, u_turbidity_parameters3);
140 gfx::set_state(topology | BGFX_STATE_WRITE_RGB | BGFX_STATE_WRITE_A | BGFX_STATE_DEPTH_TEST_EQUAL);
142 gfx::submit(pass.
id, atmospheric_program_.program->native_handle());
144 atmospheric_program_.program->end();