From ed9bd5f70b8f5d06a77ea6804a58cbdd676f2fb0 Mon Sep 17 00:00:00 2001 From: Samuli Vuorinen Date: Sun, 16 Jun 2019 22:21:44 +0300 Subject: [PATCH 1/7] Fix typo in README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8d0b4a8..41a7967 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # HaloRay HaloRay simulates the reflection and refraction of sun light inside hexagonal ice crystals present -in high altitude clouds in the atmosphere. These ice crystal produce various optical phenomena +in high altitude clouds in the atmosphere. These ice crystals produce various optical phenomena in the sky, including bright spots, circles and arcs. HaloRay employs GPGPU to massively accelerate simulations. Brunt of the work happens in OpenGL compute shaders. From 3e9dc4f2cff44fbf92cf26a4872c4b58af843f4d Mon Sep 17 00:00:00 2001 From: Samuli Vuorinen Date: Mon, 17 Jun 2019 13:16:38 +0300 Subject: [PATCH 2/7] Create CHANGELOG.md --- CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..63fe943 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,10 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] +### Added +### Changed +### Removed From a676bbf768036008abd1ea9f38b94a073b1bd4cf Mon Sep 17 00:00:00 2001 From: Samuli Vuorinen Date: Mon, 17 Jun 2019 13:17:33 +0300 Subject: [PATCH 3/7] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 63fe943..fa9f93b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [Unreleased] +## Unreleased ### Added ### Changed ### Removed From 68ae0c513242951f3cfa8e40210f53d8da5a9411 Mon Sep 17 00:00:00 2001 From: Samuli Vuorinen Date: Mon, 17 Jun 2019 19:13:51 +0300 Subject: [PATCH 4/7] Fix bug in uniform C-axis orientation If C-axis orientation was set to uniform random distribution and rotation around the C-axis was set to Gaussian, the orientation would mess with the rotation, giving wrong results. This commit fixes the problem. --- CHANGELOG.md | 6 ++++++ src/simulation/shaders/raytrace.glsl | 14 +++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa9f93b..73a34c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,16 @@ # Changelog + All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## Unreleased + ### Added + ### Changed + +- Fixed bug where uniform C-axis orientation was messing with C-axis rotation + ### Removed diff --git a/src/simulation/shaders/raytrace.glsl b/src/simulation/shaders/raytrace.glsl index 3a77b47..f6d21d6 100644 --- a/src/simulation/shaders/raytrace.glsl +++ b/src/simulation/shaders/raytrace.glsl @@ -372,20 +372,24 @@ vec2 cartesianToPolar(vec3 direction) mat3 getRotationMatrix(void) { + if (crystalProperties.polarAngleDistribution == DISTRIBUTION_UNIFORM && crystalProperties.rotationDistribution == DISTRIBUTION_UNIFORM) + { + return getUniformRandomRotationMatrix(); + } + // Orientation of crystal C-axis - mat3 orientationMat; + mat3 polarTiltMat; // Rotation around crystal C-axis mat3 rotationMat; if (crystalProperties.polarAngleDistribution == DISTRIBUTION_UNIFORM) { - orientationMat = getUniformRandomRotationMatrix(); + polarTiltMat = rotateAroundZ(rand() * 2.0 * PI); } else { float angleAverage = crystalProperties.polarAngleAverage; float angleStd = crystalProperties.polarAngleStd; float polarAngle = radians(angleAverage + angleStd * randn().x); - mat3 polarTiltMat = rotateAroundZ(polarAngle); - orientationMat = rotateAroundY(rand() * 2.0 * PI) * polarTiltMat; + polarTiltMat = rotateAroundZ(polarAngle); } if (crystalProperties.rotationDistribution == DISTRIBUTION_UNIFORM) @@ -398,7 +402,7 @@ mat3 getRotationMatrix(void) rotationMat = rotateAroundY(rotationAngle); } - return orientationMat * rotationMat; + return rotateAroundY(rand() * 2.0 * PI) * polarTiltMat * rotationMat; } float daylightEstimate(float wavelength) From 00716fd52b23f5b493780b18354970a82c0836b9 Mon Sep 17 00:00:00 2001 From: Samuli Vuorinen Date: Mon, 17 Jun 2019 20:22:48 +0300 Subject: [PATCH 5/7] Clean up changelog --- CHANGELOG.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 73a34c9..fac21d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,10 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased -### Added - ### Changed - Fixed bug where uniform C-axis orientation was messing with C-axis rotation -### Removed +## 1.0.0 + +- First official release From d65225101d2860db9caa00b51203590a12b0b6de Mon Sep 17 00:00:00 2001 From: Samuli Vuorinen Date: Mon, 17 Jun 2019 20:44:03 +0300 Subject: [PATCH 6/7] Rename C-axis orientation to simply tilt --- CHANGELOG.md | 1 + src/gui/gui.cpp | 15 ++++++++------- src/main.cpp | 6 +++--- src/simulation/shaders/raytrace.glsl | 26 +++++++++++++------------- src/simulation/simulationEngine.cpp | 6 +++--- src/simulation/simulationEngine.h | 12 ++++++------ 6 files changed, 34 insertions(+), 32 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fac21d1..439f56e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Fixed bug where uniform C-axis orientation was messing with C-axis rotation +- Renamed C-axis orientation to simply C-axis tilt ## 1.0.0 diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index ce08b64..9fd3703 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -12,7 +12,8 @@ #include "nuklear/nuklear.h" #include "../simulation/simulationEngine.h" -namespace GUI { +namespace GUI +{ const nk_flags WINDOW_FLAGS = NK_WINDOW_BORDER | NK_WINDOW_MOVABLE | NK_WINDOW_SCALABLE | NK_WINDOW_MINIMIZABLE | NK_WINDOW_TITLE; const nk_flags GROUP_FLAGS = NK_WINDOW_BORDER | NK_WINDOW_TITLE; @@ -82,15 +83,15 @@ void renderCrystalSettingsWindow(struct nk_context *ctx, const char *distributions[] = {"Uniform", "Gaussian"}; nk_layout_row_dynamic(ctx, 120, 1); - if (nk_group_begin(ctx, "C axis orientation", GROUP_FLAGS)) + if (nk_group_begin(ctx, "C axis tilt", GROUP_FLAGS)) { nk_layout_row_dynamic(ctx, 30, 1); - nk_combobox(ctx, distributions, NK_LEN(distributions), &(population.polarAngleDistribution), 30, nk_vec2(nk_layout_widget_bounds(ctx).w, 90)); - if (population.polarAngleDistribution == 1) + nk_combobox(ctx, distributions, NK_LEN(distributions), &(population.tiltDistribution), 30, nk_vec2(nk_layout_widget_bounds(ctx).w, 90)); + if (population.tiltDistribution == 1) { nk_layout_row_dynamic(ctx, 30, 2); - nk_property_float(ctx, "#Average rotation:", 0.0f, &(population.polarAngleAverage), 360.0f, 0.1f, 0.5f); - nk_property_float(ctx, "#Rotation std:", 0.0f, &(population.polarAngleStd), 360.0f, 0.1f, 0.5f); + nk_property_float(ctx, "#Average tilt:", 0.0f, &(population.tiltAverage), 360.0f, 0.1f, 0.5f); + nk_property_float(ctx, "#Tilt std:", 0.0f, &(population.tiltStd), 360.0f, 0.1f, 0.5f); } nk_group_end(ctx); } @@ -151,4 +152,4 @@ void renderViewSettingsWindow(struct nk_context *ctx, nk_end(ctx); } -} +} // namespace GUI diff --git a/src/main.cpp b/src/main.cpp index 8c4520c..d277c25 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -133,9 +133,9 @@ void runMainLoop(GLFWwindow *window, crystalProperties.caRatioAverage = 0.3f; crystalProperties.caRatioStd = 0.0f; - crystalProperties.polarAngleDistribution = 1; - crystalProperties.polarAngleAverage = 0.0f; - crystalProperties.polarAngleStd = 40.0f; + crystalProperties.tiltDistribution = 1; + crystalProperties.tiltAverage = 0.0f; + crystalProperties.tiltStd = 40.0f; crystalProperties.rotationDistribution = 1; crystalProperties.rotationAverage = 0.0f; diff --git a/src/simulation/shaders/raytrace.glsl b/src/simulation/shaders/raytrace.glsl index f6d21d6..7317b70 100644 --- a/src/simulation/shaders/raytrace.glsl +++ b/src/simulation/shaders/raytrace.glsl @@ -27,9 +27,9 @@ uniform struct crystalProperties_t float caRatioAverage; float caRatioStd; - int polarAngleDistribution; - float polarAngleAverage; - float polarAngleStd; + int tiltDistribution; + float tiltAverage; + float tiltStd; int rotationDistribution; float rotationAverage; @@ -372,24 +372,24 @@ vec2 cartesianToPolar(vec3 direction) mat3 getRotationMatrix(void) { - if (crystalProperties.polarAngleDistribution == DISTRIBUTION_UNIFORM && crystalProperties.rotationDistribution == DISTRIBUTION_UNIFORM) + if (crystalProperties.tiltDistribution == DISTRIBUTION_UNIFORM && crystalProperties.rotationDistribution == DISTRIBUTION_UNIFORM) { return getUniformRandomRotationMatrix(); } - // Orientation of crystal C-axis - mat3 polarTiltMat; + // Tilt of the crystal C-axis + mat3 tiltMat; // Rotation around crystal C-axis mat3 rotationMat; - if (crystalProperties.polarAngleDistribution == DISTRIBUTION_UNIFORM) { - polarTiltMat = rotateAroundZ(rand() * 2.0 * PI); + if (crystalProperties.tiltDistribution == DISTRIBUTION_UNIFORM) { + tiltMat = rotateAroundZ(rand() * 2.0 * PI); } else { - float angleAverage = crystalProperties.polarAngleAverage; - float angleStd = crystalProperties.polarAngleStd; - float polarAngle = radians(angleAverage + angleStd * randn().x); - polarTiltMat = rotateAroundZ(polarAngle); + float angleAverage = crystalProperties.tiltAverage; + float angleStd = crystalProperties.tiltStd; + float tiltAngle = radians(angleAverage + angleStd * randn().x); + tiltMat = rotateAroundZ(tiltAngle); } if (crystalProperties.rotationDistribution == DISTRIBUTION_UNIFORM) @@ -402,7 +402,7 @@ mat3 getRotationMatrix(void) rotationMat = rotateAroundY(rotationAngle); } - return rotateAroundY(rand() * 2.0 * PI) * polarTiltMat * rotationMat; + return rotateAroundY(rand() * 2.0 * PI) * tiltMat * rotationMat; } float daylightEstimate(float wavelength) diff --git a/src/simulation/simulationEngine.cpp b/src/simulation/simulationEngine.cpp index ea53498..aac83fc 100644 --- a/src/simulation/simulationEngine.cpp +++ b/src/simulation/simulationEngine.cpp @@ -78,9 +78,9 @@ void SimulationEngine::Run(unsigned int numRays) glUniform1f(glGetUniformLocation(shaderHandle, "crystalProperties.caRatioAverage"), mCrystals.caRatioAverage); glUniform1f(glGetUniformLocation(shaderHandle, "crystalProperties.caRatioStd"), mCrystals.caRatioStd); - glUniform1i(glGetUniformLocation(shaderHandle, "crystalProperties.polarAngleDistribution"), mCrystals.polarAngleDistribution); - glUniform1f(glGetUniformLocation(shaderHandle, "crystalProperties.polarAngleAverage"), mCrystals.polarAngleAverage); - glUniform1f(glGetUniformLocation(shaderHandle, "crystalProperties.polarAngleStd"), mCrystals.polarAngleStd); + glUniform1i(glGetUniformLocation(shaderHandle, "crystalProperties.tiltDistribution"), mCrystals.tiltDistribution); + glUniform1f(glGetUniformLocation(shaderHandle, "crystalProperties.tiltAverage"), mCrystals.tiltAverage); + glUniform1f(glGetUniformLocation(shaderHandle, "crystalProperties.tiltStd"), mCrystals.tiltStd); glUniform1i(glGetUniformLocation(shaderHandle, "crystalProperties.rotationDistribution"), mCrystals.rotationDistribution); glUniform1f(glGetUniformLocation(shaderHandle, "crystalProperties.rotationAverage"), mCrystals.rotationAverage); diff --git a/src/simulation/simulationEngine.h b/src/simulation/simulationEngine.h index 385deff..b66de24 100644 --- a/src/simulation/simulationEngine.h +++ b/src/simulation/simulationEngine.h @@ -13,9 +13,9 @@ struct CrystalPopulation float caRatioAverage; float caRatioStd; - int polarAngleDistribution; - float polarAngleAverage; - float polarAngleStd; + int tiltDistribution; + float tiltAverage; + float tiltStd; int rotationDistribution; float rotationAverage; @@ -25,9 +25,9 @@ struct CrystalPopulation { return caRatioAverage == other.caRatioAverage && caRatioStd == other.caRatioStd && - polarAngleDistribution == other.polarAngleDistribution && - polarAngleAverage == other.polarAngleAverage && - polarAngleStd == other.polarAngleStd && + tiltDistribution == other.tiltDistribution && + tiltAverage == other.tiltAverage && + tiltStd == other.tiltStd && rotationDistribution == other.rotationDistribution && rotationAverage == other.rotationAverage && rotationStd == other.rotationStd; From 81d87b2136364a4f1d97368f777806997644db6a Mon Sep 17 00:00:00 2001 From: Samuli Vuorinen Date: Mon, 17 Jun 2019 20:51:19 +0300 Subject: [PATCH 7/7] Bump version number to 1.1.0 --- CHANGELOG.md | 2 +- src/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 439f56e..3d83bf4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## Unreleased +## 1.1.0 ### Changed diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b476534..4872366 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,5 +1,5 @@ set (HaloRay_VERSION_MAJOR 1) -set (HaloRay_VERSION_MINOR 0) +set (HaloRay_VERSION_MINOR 1) set (HaloRay_VERSION_PATCH 0) configure_file("${CMAKE_CURRENT_SOURCE_DIR}/version.h.in" "${CMAKE_CURRENT_SOURCE_DIR}/version.h")