diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..3d83bf4 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,17 @@ +# 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). + +## 1.1.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 + +- First official release 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. 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") 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 3a77b47..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,20 +372,24 @@ vec2 cartesianToPolar(vec3 direction) mat3 getRotationMatrix(void) { - // Orientation of crystal C-axis - mat3 orientationMat; + if (crystalProperties.tiltDistribution == DISTRIBUTION_UNIFORM && crystalProperties.rotationDistribution == DISTRIBUTION_UNIFORM) + { + return getUniformRandomRotationMatrix(); + } + + // Tilt of the crystal C-axis + mat3 tiltMat; // Rotation around crystal C-axis mat3 rotationMat; - if (crystalProperties.polarAngleDistribution == DISTRIBUTION_UNIFORM) { - orientationMat = getUniformRandomRotationMatrix(); + 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); - mat3 polarTiltMat = rotateAroundZ(polarAngle); - orientationMat = rotateAroundY(rand() * 2.0 * PI) * polarTiltMat; + float angleAverage = crystalProperties.tiltAverage; + float angleStd = crystalProperties.tiltStd; + float tiltAngle = radians(angleAverage + angleStd * randn().x); + tiltMat = rotateAroundZ(tiltAngle); } if (crystalProperties.rotationDistribution == DISTRIBUTION_UNIFORM) @@ -398,7 +402,7 @@ mat3 getRotationMatrix(void) rotationMat = rotateAroundY(rotationAngle); } - return orientationMat * 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;