diff --git a/data/scene/newhorizons/jupiter/callisto/callisto.mod b/data/scene/newhorizons/jupiter/callisto/callisto.mod index 6eccc2d280..44bae2484b 100644 --- a/data/scene/newhorizons/jupiter/callisto/callisto.mod +++ b/data/scene/newhorizons/jupiter/callisto/callisto.mod @@ -22,6 +22,7 @@ return { Observer = "NEW HORIZONS", Target = "CALLISTO", Aberration = "NONE", + AspectRatio = 2 }, Instrument = { Name = "NH_LORRI", diff --git a/data/scene/newhorizons/jupiter/europa/europa.mod b/data/scene/newhorizons/jupiter/europa/europa.mod index c3b7e2951b..a3e9b4a882 100644 --- a/data/scene/newhorizons/jupiter/europa/europa.mod +++ b/data/scene/newhorizons/jupiter/europa/europa.mod @@ -22,6 +22,7 @@ return { Observer = "NEW HORIZONS", Target = "EUROPA", Aberration = "NONE", + AspectRatio = 2 }, Instrument = { Name = "NH_LORRI", diff --git a/data/scene/newhorizons/jupiter/ganymede/ganymede.mod b/data/scene/newhorizons/jupiter/ganymede/ganymede.mod index 37fb4d5252..11fcfe432b 100644 --- a/data/scene/newhorizons/jupiter/ganymede/ganymede.mod +++ b/data/scene/newhorizons/jupiter/ganymede/ganymede.mod @@ -22,6 +22,7 @@ return { Observer = "NEW HORIZONS", Target = "GANYMEDE", Aberration = "NONE", + AspectRatio = 2 }, Instrument = { Name = "NH_LORRI", diff --git a/data/scene/newhorizons/jupiter/io/io.mod b/data/scene/newhorizons/jupiter/io/io.mod index f98deb8d8a..76615815b8 100644 --- a/data/scene/newhorizons/jupiter/io/io.mod +++ b/data/scene/newhorizons/jupiter/io/io.mod @@ -22,6 +22,7 @@ return { Observer = "NEW HORIZONS", Target = "IO", Aberration = "NONE", + AspectRatio = 2 }, Instrument = { Name = "NH_LORRI", diff --git a/data/scene/newhorizons/jupiter/jupiter/jupiter.mod b/data/scene/newhorizons/jupiter/jupiter/jupiter.mod index 8b6af8e568..fd8222df3b 100644 --- a/data/scene/newhorizons/jupiter/jupiter/jupiter.mod +++ b/data/scene/newhorizons/jupiter/jupiter/jupiter.mod @@ -41,6 +41,7 @@ return { Observer = "NEW HORIZONS", Target = "JUPITER", Aberration = "NONE", + AspectRatio = 2 }, DataInputTranslation = { Instrument = { diff --git a/data/scene/newhorizons/pluto/charon/charon.mod b/data/scene/newhorizons/pluto/charon/charon.mod index 5f63bc524d..8fbe1de3e5 100644 --- a/data/scene/newhorizons/pluto/charon/charon.mod +++ b/data/scene/newhorizons/pluto/charon/charon.mod @@ -40,6 +40,7 @@ return { Observer = "NEW HORIZONS", Target = "CHARON", Aberration = "NONE", + AspectRatio = 2 }, Instrument = { Name = "NH_LORRI", diff --git a/data/scene/newhorizons/pluto/pluto/pluto.mod b/data/scene/newhorizons/pluto/pluto/pluto.mod index a34e52aa7b..59fe90b53b 100644 --- a/data/scene/newhorizons/pluto/pluto/pluto.mod +++ b/data/scene/newhorizons/pluto/pluto/pluto.mod @@ -67,6 +67,7 @@ return { Observer = "NEW HORIZONS", Target = "PLUTO", Aberration = "NONE", + AspectRatio = 2 }, DataInputTranslation = { Instrument = { diff --git a/data/scene/osirisrex/bennu/bennu.mod b/data/scene/osirisrex/bennu/bennu.mod index 7c558e16f8..414778e72d 100644 --- a/data/scene/osirisrex/bennu/bennu.mod +++ b/data/scene/osirisrex/bennu/bennu.mod @@ -51,6 +51,7 @@ return { Observer = "SUN", Target = BENNU_BODY, Aberration = "NONE", + AspectRatio = 2 }, DataInputTranslation = { Instruments = { diff --git a/modules/newhorizons/util/projectioncomponent.cpp b/modules/newhorizons/util/projectioncomponent.cpp index 313fcc17a7..f2e9fd7fc6 100644 --- a/modules/newhorizons/util/projectioncomponent.cpp +++ b/modules/newhorizons/util/projectioncomponent.cpp @@ -52,6 +52,7 @@ namespace { const std::string keyTranslation = "DataInputTranslation"; const std::string keyNeedsTextureMapDilation = "Projection.TextureMap"; + const std::string keyTextureMapAspectRatio = "Projection.AspectRatio"; const std::string sequenceTypeImage = "image-sequence"; const std::string sequenceTypePlaybook = "playbook"; @@ -196,6 +197,12 @@ bool ProjectionComponent::initializeProjectionSettings(const Dictionary& diction _needsTextureMapDilation = dictionary.value(keyNeedsTextureMapDilation); } + _projectionTextureAspectRatio = 1.f; + if (dictionary.hasKeyAndValue(keyTextureMapAspectRatio)) { + _projectionTextureAspectRatio = + static_cast(dictionary.value(keyTextureMapAspectRatio)); + } + return completeSuccess; } @@ -579,11 +586,22 @@ std::shared_ptr ProjectionComponent::loadProjectionTextu bool ProjectionComponent::generateProjectionLayerTexture() { int maxSize = OpenGLCap.max2DTextureSize() / 2; + glm::ivec2 size; + if (_projectionTextureAspectRatio > 1.f) { + size.x = maxSize; + size.y = static_cast(maxSize / _projectionTextureAspectRatio); + } + else { + size.x = static_cast(maxSize * _projectionTextureAspectRatio); + size.y = maxSize; + } + + LINFO( - "Creating projection texture of size '" << maxSize << ", " << maxSize / 2 << "'" + "Creating projection texture of size '" << size.x << ", " << size.y << "'" ); _projectionTexture = std::make_unique ( - glm::uvec3(maxSize, maxSize / 2, 1), + glm::uvec3(size, 1), ghoul::opengl::Texture::Format::RGBA ); if (_projectionTexture) { @@ -593,7 +611,7 @@ bool ProjectionComponent::generateProjectionLayerTexture() { if (_needsTextureMapDilation) { _dilation.texture = std::make_unique( - glm::uvec3(maxSize, maxSize / 2, 1), + glm::uvec3(size, 1), ghoul::opengl::Texture::Format::RGBA ); @@ -603,7 +621,7 @@ bool ProjectionComponent::generateProjectionLayerTexture() { } _dilation.stencilTexture = std::make_unique( - glm::uvec3(maxSize, maxSize / 2, 1), + glm::uvec3(size, 1), ghoul::opengl::Texture::Format::Red, ghoul::opengl::Texture::Format::Red ); @@ -622,12 +640,23 @@ bool ProjectionComponent::generateProjectionLayerTexture() { bool ProjectionComponent::generateDepthTexture() { int maxSize = OpenGLCap.max2DTextureSize() / 2; + glm::ivec2 size; + + if (_projectionTextureAspectRatio > 1.f) { + size.x = maxSize; + size.y = static_cast(maxSize / _projectionTextureAspectRatio); + } + else { + size.x = static_cast(maxSize * _projectionTextureAspectRatio); + size.y = maxSize; + } + LINFO( - "Creating depth texture of size '" << maxSize / 2 << ", " << maxSize / 2 << "'" + "Creating depth texture of size '" << size.x << ", " << size.y << "'" ); _depthTexture = std::make_unique( - glm::uvec3(maxSize / 2, maxSize / 2, 1), + glm::uvec3(size, 1), ghoul::opengl::Texture::Format::DepthComponent, GL_DEPTH_COMPONENT32F ); diff --git a/modules/newhorizons/util/projectioncomponent.h b/modules/newhorizons/util/projectioncomponent.h index cf061f85e1..a2f680b142 100644 --- a/modules/newhorizons/util/projectioncomponent.h +++ b/modules/newhorizons/util/projectioncomponent.h @@ -108,6 +108,8 @@ protected: std::unique_ptr _depthTexture; std::shared_ptr _placeholderTexture; + float _projectionTextureAspectRatio; + std::string _instrumentID; std::string _projectorID; std::string _projecteeID;