Skip to content

Commit e9c9782

Browse files
committed
Add sun position algorithm
1 parent 26a9527 commit e9c9782

File tree

6 files changed

+1549
-0
lines changed

6 files changed

+1549
-0
lines changed

sandbox/settings/appleseed.studio.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010
<parameter name="tile_ordering" value="spiral" />
1111
</parameters>
1212
<parameters name="ui">
13+
<parameters name="file_dialog">
14+
<parameters name="projects">
15+
<parameter name="last_directory" value="C:\Users\joao_\OneDrive\Desktop\git\Appleaseed\appleseed\sandbox\tests\test scenes\sppm" />
16+
<parameter name="selected_filter" value="Project Files (*.appleseed *.appleseedz)" />
17+
</parameters>
18+
</parameters>
1319
<parameters name="render_region">
1420
<parameter name="triggers_rendering" value="true" />
1521
</parameters>

src/appleseed/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2181,6 +2181,8 @@ set (renderer_utility_sources
21812181
renderer/utility/settingsparsing.cpp
21822182
renderer/utility/settingsparsing.h
21832183
renderer/utility/shadowterminator.h
2184+
renderer/utility/solarpositionalgorithm.cpp
2185+
renderer/utility/solarpositionalgorithm.h
21842186
renderer/utility/spectrumclamp.h
21852187
renderer/utility/stochasticcast.h
21862188
renderer/utility/testutils.cpp

src/appleseed/renderer/modeling/environmentedf/hosekenvironmentedf.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include "renderer/modeling/input/inputarray.h"
4040
#include "renderer/modeling/input/source.h"
4141
#include "renderer/modeling/input/sourceinputs.h"
42+
#include "renderer/utility/solarpositionalgorithm.h"
4243
#include "renderer/utility/transformsequence.h"
4344

4445
// appleseed.foundation headers.
@@ -133,6 +134,29 @@ namespace
133134
// Evaluate uniform values.
134135
m_inputs.evaluate_uniforms(&m_uniform_values);
135136

137+
spa_data test;
138+
test.hour = m_params.get_optional<int>("hour", 12);
139+
test.minute = m_params.get_optional<int>("minute", 0);
140+
test.second = m_params.get_optional<int>("second", 0);
141+
142+
test.year = m_params.get_optional<int>("year", 2020);
143+
test.month = m_params.get_optional<int>("month", 1);
144+
test.day = m_params.get_optional<int>("day", 1);
145+
146+
test.timezone = 0;
147+
test.longitude = m_params.get_optional<float>("longitude", 0);
148+
test.latitude = m_params.get_optional<float>("latitude", 0);
149+
150+
test.azm_rotation = 0.0;
151+
test.elevation = 0.0;
152+
153+
test.function = SPA_ZA;
154+
155+
spa_calculate(&test);
156+
157+
m_uniform_values.m_sun_theta = static_cast<float>(test.zenith);
158+
m_uniform_values.m_sun_phi = static_cast<float>(test.azimuth);
159+
136160
// Compute the sun direction.
137161
m_sun_theta = deg_to_rad(m_uniform_values.m_sun_theta);
138162
m_sun_phi = deg_to_rad(m_uniform_values.m_sun_phi);

src/appleseed/renderer/modeling/environmentedf/ienvironmentedffactory.cpp

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,142 @@ void IEnvironmentEDFFactory::add_common_sky_input_metadata(DictionaryArray& meta
173173
.insert("use", "optional")
174174
.insert("default", "0.0")
175175
.insert("help", "Shift the horizon vertically"));
176+
177+
metadata.push_back(
178+
Dictionary()
179+
.insert("name", "hour")
180+
.insert("label", "hour")
181+
.insert("type", "integer")
182+
.insert("min",
183+
Dictionary()
184+
.insert("value", "0")
185+
.insert("type", "hard"))
186+
.insert("max",
187+
Dictionary()
188+
.insert("value", "24")
189+
.insert("type", "hard"))
190+
.insert("use", "optional")
191+
.insert("default", "12")
192+
.insert("help", "..."));
193+
194+
metadata.push_back(
195+
Dictionary()
196+
.insert("name", "minute")
197+
.insert("label", "minute")
198+
.insert("type", "integer")
199+
.insert("min",
200+
Dictionary()
201+
.insert("value", "0")
202+
.insert("type", "hard"))
203+
.insert("max",
204+
Dictionary()
205+
.insert("value", "60")
206+
.insert("type", "hard"))
207+
.insert("use", "optional")
208+
.insert("default", "0")
209+
.insert("help", "..."));
210+
211+
metadata.push_back(
212+
Dictionary()
213+
.insert("name", "second")
214+
.insert("label", "second")
215+
.insert("type", "integer")
216+
.insert("min",
217+
Dictionary()
218+
.insert("value", "0")
219+
.insert("type", "hard"))
220+
.insert("max",
221+
Dictionary()
222+
.insert("value", "60")
223+
.insert("type", "hard"))
224+
.insert("use", "optional")
225+
.insert("default", "0")
226+
.insert("help", "..."));
227+
228+
metadata.push_back(
229+
Dictionary()
230+
.insert("name", "year")
231+
.insert("label", "year")
232+
.insert("type", "integer")
233+
.insert("min",
234+
Dictionary()
235+
.insert("value", "-2000")
236+
.insert("type", "soft"))
237+
.insert("max",
238+
Dictionary()
239+
.insert("value", "6000")
240+
.insert("type", "soft"))
241+
.insert("use", "optional")
242+
.insert("default", "2020")
243+
.insert("help", "..."));
244+
245+
metadata.push_back(
246+
Dictionary()
247+
.insert("name", "month")
248+
.insert("label", "month ")
249+
.insert("type", "integer")
250+
.insert("min",
251+
Dictionary()
252+
.insert("value", "1")
253+
.insert("type", "hard"))
254+
.insert("max",
255+
Dictionary()
256+
.insert("value", "12")
257+
.insert("type", "hard"))
258+
.insert("use", "optional")
259+
.insert("default", "1")
260+
.insert("help", "..."));
261+
262+
metadata.push_back(
263+
Dictionary()
264+
.insert("name", "day")
265+
.insert("label", "day")
266+
.insert("type", "integer")
267+
.insert("min",
268+
Dictionary()
269+
.insert("value", "1")
270+
.insert("type", "hard"))
271+
.insert("max",
272+
Dictionary()
273+
.insert("value", "31")
274+
.insert("type", "hard"))
275+
.insert("use", "optional")
276+
.insert("default", "1")
277+
.insert("help", "..."));
278+
279+
metadata.push_back(
280+
Dictionary()
281+
.insert("name", "longitude")
282+
.insert("label", "longitude")
283+
.insert("type", "numeric")
284+
.insert("min",
285+
Dictionary()
286+
.insert("value", "-180.0")
287+
.insert("type", "hard"))
288+
.insert("max",
289+
Dictionary()
290+
.insert("value", "180.0")
291+
.insert("type", "hard"))
292+
.insert("use", "optional")
293+
.insert("default", "0.0")
294+
.insert("help", "..."));
295+
296+
metadata.push_back(
297+
Dictionary()
298+
.insert("name", "latitude")
299+
.insert("label", "latitude")
300+
.insert("type", "numeric")
301+
.insert("min",
302+
Dictionary()
303+
.insert("value", "-90.0")
304+
.insert("type", "hard"))
305+
.insert("max",
306+
Dictionary()
307+
.insert("value", "90.0")
308+
.insert("type", "hard"))
309+
.insert("use", "optional")
310+
.insert("default", "0")
311+
.insert("help", "..."));
176312
}
177313

178314
} // namespace renderer

0 commit comments

Comments
 (0)