Moved the volume.asset from customization to scene/milkyway/milkyway/volume.asset

Make the Galaxy volume a default
Small changes here and there
This commit is contained in:
Alexander Bock
2019-08-23 16:36:43 +02:00
parent b453f93feb
commit 157c653afc
5 changed files with 87 additions and 43 deletions

View File

@@ -15,6 +15,7 @@ asset.require('scene/solarsystem/planets')
asset.require('scene/solarsystem/planets/mars/moons/phobos')
asset.require('scene/solarsystem/planets/mars/moons/deimos')
asset.require('scene/solarsystem/dwarf_planets/pluto/system')
asset.request('scene/milkyway/milkyway/volume')
assetHelper.requestAll(asset, 'scene/digitaluniverse')
@@ -26,7 +27,6 @@ asset.require('util/default_joystick')
-- Load web gui
asset.require('util/webgui')
asset.request('customization/globebrowsing')
asset.request('customization/volumes')
-- Keybindings that are specific for this scene

View File

@@ -16,22 +16,22 @@ local MilkyWayVolumeGalaxy = {
Renderable = {
Type = "RenderableGalaxy",
StepSize = 0.01,
AbsorptionMultiply = 75,
EmissionMultiply = 200,
Translation = {0.2, 0, 0},
AbsorptionMultiply = 75,
EmissionMultiply = 200,
Translation = {0.2, 0, 0},
Rotation = {3.1415926, 3.1248, 4.45741},
Volume = {
Type = "Volume",
Filename = data .. "/MilkyWayRGBAVolume1024x1024x128.raw",
Dimensions = {1024, 1024, 128},
Size = {1.2E21, 1.2E21, 0.15E21}
},
Points = {
Type = "Points",
Filename = data .. "/MilkyWayPoints.off",
EnabledPointsRatio = 0.3,
Texture = data .. "/halo.png"
}
Type = "Volume",
Filename = data .. "/MilkyWayRGBAVolume1024x1024x128.raw",
Dimensions = {1024, 1024, 128},
Size = {1.2E21, 1.2E21, 0.15E21}
},
Points = {
Type = "Points",
Filename = data .. "/MilkyWayPoints.off",
EnabledPointsRatio = 0.3,
Texture = data .. "/halo.png"
}
},
GUI = {
Path = "/Milky Way"

View File

@@ -84,7 +84,7 @@ Fragment getFragment() {
frag.color.rgb = diffuseAlbedo;
}
frag.color.a = opacity;
frag.color.a = opacity;
frag.depth = vs_screenSpaceDepth;
frag.gPosition = vs_positionCameraSpace;
frag.gNormal = vec4(vs_normalViewSpace, 0.0);

View File

@@ -1,3 +1,5 @@
set(DEFAULT_MODULE ON)
set (OPENSPACE_DEPENDENCIES
volume
space

View File

@@ -108,7 +108,8 @@ namespace {
constexpr openspace::properties::Property::PropertyInfo StarRenderingMethodInfo = {
"StarRenderingMethod",
"Star Rendering Method",
"This value determines which rendering method is used for visualization of the stars."
"This value determines which rendering method is used for visualization of the "
"stars."
};
constexpr openspace::properties::Property::PropertyInfo EnabledPointsRatioInfo = {
@@ -127,7 +128,10 @@ namespace openspace {
, _stepSize(StepSizeInfo, 0.01f, 0.0005f, 0.05f, 0.001f)
, _absorptionMultiply(AbsorptionMultiplyInfo, 40.f, 0.0f, 100.0f)
, _emissionMultiply(EmissionMultiplyInfo, 400.f, 0.0f, 1000.0f)
, _starRenderingMethod(StarRenderingMethodInfo, properties::OptionProperty::DisplayType::Dropdown)
, _starRenderingMethod(
StarRenderingMethodInfo,
properties::OptionProperty::DisplayType::Dropdown
)
, _enabledPointsRatio(EnabledPointsRatioInfo, 0.5f, 0.01f, 1.0f)
, _translation(TranslationInfo, glm::vec3(0.f), glm::vec3(0.f), glm::vec3(1.f))
, _rotation(RotationInfo, glm::vec3(0.f), glm::vec3(0.f), glm::vec3(6.28f))
@@ -143,7 +147,9 @@ namespace openspace {
dictionary.getValue("Rotation", _rotation);
if (dictionary.hasKeyAndValue<bool>(VolumeRenderingEnabledInfo.identifier)) {
_volumeRenderingEnabled = dictionary.value<bool>(VolumeRenderingEnabledInfo.identifier);
_volumeRenderingEnabled = dictionary.value<bool>(
VolumeRenderingEnabledInfo.identifier
);
}
if (dictionary.hasKeyAndValue<bool>(StarRenderingEnabledInfo.identifier)) {
@@ -155,21 +161,25 @@ namespace openspace {
}
if (dictionary.hasKeyAndValue<double>(AbsorptionMultiplyInfo.identifier)) {
_absorptionMultiply = static_cast<float>(dictionary.value<double>(AbsorptionMultiplyInfo.identifier));
_absorptionMultiply = static_cast<float>(
dictionary.value<double>(AbsorptionMultiplyInfo.identifier)
);
}
if (dictionary.hasKeyAndValue<double>(EmissionMultiplyInfo.identifier)) {
_emissionMultiply = static_cast<float>(dictionary.value<double>(EmissionMultiplyInfo.identifier));
_emissionMultiply = static_cast<float>(
dictionary.value<double>(EmissionMultiplyInfo.identifier)
);
}
_starRenderingMethod.addOptions({
{ 0, "Points" },
{ 1, "Billboards" }
});
{ 0, "Points" },
{ 1, "Billboards" }
});
if (dictionary.hasKey(StarRenderingMethodInfo.identifier)) {
const std::string starRenderingMethod = dictionary.value<std::string>(
StarRenderingMethodInfo.identifier
);
);
if (starRenderingMethod == "Points") {
_starRenderingMethod = 0;
}
@@ -195,13 +205,15 @@ namespace openspace {
std::string volumeFilename;
if (volumeDictionary.getValue("Filename", volumeFilename)) {
_volumeFilename = absPath(volumeFilename);
} else {
}
else {
LERROR("No volume filename specified.");
}
glm::vec3 volumeDimensions;
if (volumeDictionary.getValue("Dimensions", volumeDimensions)) {
_volumeDimensions = static_cast<glm::ivec3>(volumeDimensions);
} else {
}
else {
LERROR("No volume dimensions specified.");
}
glm::vec3 volumeSize;
@@ -220,18 +232,23 @@ namespace openspace {
std::string pointsFilename;
if (pointsDictionary.getValue("Filename", pointsFilename)) {
_pointsFilename = absPath(pointsFilename);
} else {
}
else {
LERROR("No points filename specified.");
}
if (pointsDictionary.hasKeyAndValue<double>(EnabledPointsRatioInfo.identifier)) {
_enabledPointsRatio = static_cast<float>(pointsDictionary.value<double>(EnabledPointsRatioInfo.identifier));
_enabledPointsRatio = static_cast<float>(
pointsDictionary.value<double>(EnabledPointsRatioInfo.identifier)
);
}
std::string pointSpreadFunctionTexturePath;
if (pointsDictionary.getValue("Texture", pointSpreadFunctionTexturePath)) {
_pointSpreadFunctionTexturePath = absPath(pointSpreadFunctionTexturePath);
_pointSpreadFunctionFile = std::make_unique<ghoul::filesystem::File>(_pointSpreadFunctionTexturePath);
_pointSpreadFunctionFile = std::make_unique<ghoul::filesystem::File>(
_pointSpreadFunctionTexturePath
);
}
else {
LERROR("No points filename specified.");
@@ -326,8 +343,16 @@ void RenderableGalaxy::initializeGL() {
);
}
ghoul::opengl::updateUniformLocations(*_pointsProgram, _uniformCachePoints, UniformNamesPoints);
ghoul::opengl::updateUniformLocations(*_billboardsProgram, _uniformCacheBillboards, UniformNamesBillboards);
ghoul::opengl::updateUniformLocations(
*_pointsProgram,
_uniformCachePoints,
UniformNamesPoints
);
ghoul::opengl::updateUniformLocations(
*_billboardsProgram,
_uniformCacheBillboards,
UniformNamesBillboards
);
_pointsProgram->setIgnoreUniformLocationError(
ghoul::opengl::ProgramObject::IgnoreError::Yes
@@ -357,7 +382,10 @@ void RenderableGalaxy::initializeGL() {
// Read points
float x, y, z, r, g, b, a;
for (size_t i = 0; i < static_cast<size_t>(_nPoints * _enabledPointsRatio.maxValue()) + 1; ++i) {
for (size_t i = 0;
i < static_cast<size_t>(_nPoints * _enabledPointsRatio.maxValue()) + 1;
++i)
{
std::getline(pointFile, line);
std::istringstream issp(line);
issp >> x >> y >> z >> r >> g >> b >> a;
@@ -472,7 +500,8 @@ void RenderableGalaxy::render(const RenderData& data, RendererTasks& tasks) {
if (length < lowerRampStart) {
opacityCoefficient = 0.f; // camera really close
} else if (length < lowerRampEnd) {
opacityCoefficient = (length - lowerRampStart) / (lowerRampEnd - lowerRampStart);
opacityCoefficient = (length - lowerRampStart) /
(lowerRampEnd - lowerRampStart);
} else if (length < upperRampStart) {
opacityCoefficient = 1.f; // sweet spot (max)
} else if (length < upperRampEnd) {
@@ -530,9 +559,13 @@ void RenderableGalaxy::renderPoints(const RenderData& data) {
_pointsProgram->activate();
glm::dmat4 rotMatrix = glm::rotate(glm::dmat4(1.0), 3.1415926, glm::dvec3(1.0, 0.0, 0.0)) *
glm::rotate(glm::dmat4(1.0), 3.1248, glm::dvec3(0.0, 1.0, 0.0)) *
glm::rotate(glm::dmat4(1.0), 4.45741, glm::dvec3(0.0, 0.0, 1.0));
glm::dmat4 rotMatrix = glm::rotate(
glm::dmat4(1.0),
glm::pi<double>(),
glm::dvec3(1.0, 0.0, 0.0)) *
glm::rotate(glm::dmat4(1.0), 3.1248, glm::dvec3(0.0, 1.0, 0.0)) *
glm::rotate(glm::dmat4(1.0), 4.45741, glm::dvec3(0.0, 0.0, 1.0)
);
glm::dmat4 modelMatrix =
glm::translate(glm::dmat4(1.0), data.modelTransform.translation) *
@@ -551,10 +584,14 @@ void RenderableGalaxy::renderPoints(const RenderData& data) {
);
glm::dvec3 eyePosition = glm::dvec3(
glm::inverse(data.camera.combinedViewMatrix()) * glm::dvec4(0.0, 0.0, 0.0, 1.0)
glm::inverse(data.camera.combinedViewMatrix()) *
glm::dvec4(0.0, 0.0, 0.0, 1.0)
);
_pointsProgram->setUniform(_uniformCachePoints.eyePosition, eyePosition);
_pointsProgram->setUniform(_uniformCachePoints.opacityCoefficient, _opacityCoefficient);
_pointsProgram->setUniform(
_uniformCachePoints.opacityCoefficient,
_opacityCoefficient
);
glBindVertexArray(_pointsVao);
glDrawArrays(GL_POINTS, 0, static_cast<GLsizei>(_nPoints * _enabledPointsRatio));
@@ -600,9 +637,13 @@ void RenderableGalaxy::renderBillboards(const RenderData& data) {
_billboardsProgram->activate();
glm::dmat4 rotMatrix = glm::rotate(glm::dmat4(1.0), 3.1415926, glm::dvec3(1.0, 0.0, 0.0)) *
glm::rotate(glm::dmat4(1.0), 3.1248, glm::dvec3(0.0, 1.0, 0.0)) *
glm::rotate(glm::dmat4(1.0), 4.45741, glm::dvec3(0.0, 0.0, 1.0));
glm::dmat4 rotMatrix = glm::rotate(
glm::dmat4(1.0),
glm::pi<double>(),
glm::dvec3(1.0, 0.0, 0.0)) *
glm::rotate(glm::dmat4(1.0), 3.1248, glm::dvec3(0.0, 1.0, 0.0)) *
glm::rotate(glm::dmat4(1.0), 4.45741, glm::dvec3(0.0, 0.0, 1.0)
);
glm::dmat4 modelMatrix =
glm::translate(glm::dmat4(1.0), data.modelTransform.translation) *
@@ -621,7 +662,8 @@ void RenderableGalaxy::renderBillboards(const RenderData& data) {
);
glm::dvec3 eyePosition = glm::dvec3(
glm::inverse(data.camera.combinedViewMatrix()) * glm::dvec4(0.0, 0.0, 0.0, 1.0)
glm::inverse(data.camera.combinedViewMatrix()) *
glm::dvec4(0.0, 0.0, 0.0, 1.0)
);
_billboardsProgram->setUniform(_uniformCacheBillboards.eyePosition, eyePosition);