From f57feb01d3b9853ef337b0cbe3477261c8660083 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Mon, 21 Aug 2017 13:53:05 -0400 Subject: [PATCH] Fix meridian shift issue on Pluto Easier configuration of Pluto image textures from within the scene file --- .../newhorizons/pluto/charon/charon.mod | 12 +- .../newhorizons/pluto/pluto/pluto.data | 2 +- .../newhorizons/pluto/pluto/pluto.mod | 13 +-- data/scene/newhorizons.scene | 103 ++++++++++-------- .../rendering/renderableplanetprojection.cpp | 25 ++++- .../rendering/renderableplanetprojection.h | 1 + .../shaders/renderablePlanet_fs.glsl | 4 +- .../shaders/renderablePlanet_vs.glsl | 8 +- 8 files changed, 103 insertions(+), 65 deletions(-) diff --git a/data/scene/missions/newhorizons/pluto/charon/charon.mod b/data/scene/missions/newhorizons/pluto/charon/charon.mod index a02d63a997..89931718fc 100644 --- a/data/scene/missions/newhorizons/pluto/charon/charon.mod +++ b/data/scene/missions/newhorizons/pluto/charon/charon.mod @@ -5,12 +5,6 @@ local NewHorizonsKernels = { "${SPICE}/new_horizons/spk/NavPE_de433_od122.bsp", } --- Loading the smaller version for higher compatability --- if we have a good way to measure GPU memory, we can make this dynamic -local ColorTexture = "textures/NH_Charon_mosaic_8192.png" -local HeightTexture = "textures/NH_Charon_DTM_8192.png" - - return { -- CharonProjection module { @@ -22,10 +16,10 @@ return { Geometry = { Type = "SimpleSphere", Radius = charon_radius, - Segments = 100 + Segments = 350 }, - ColorTexture = ColorTexture, - HeightTexture = HeightTexture, + ColorTexture = charon_image, + HeightTexture = charon_height, Projection = { Observer = "NEW HORIZONS", Target = "CHARON", diff --git a/data/scene/missions/newhorizons/pluto/pluto/pluto.data b/data/scene/missions/newhorizons/pluto/pluto/pluto.data index 13ab280e5a..2513483a9b 100644 --- a/data/scene/missions/newhorizons/pluto/pluto/pluto.data +++ b/data/scene/missions/newhorizons/pluto/pluto/pluto.data @@ -2,7 +2,7 @@ return { FileRequest = { { Identifier = "newhorizons_plutoencounter_pluto_assets", Destination = "assets", Version = 1 }, { Identifier = "newhorizons_plutoencounter_pluto_textures", Destination = "textures", Version = 4 }, - { Identifier = "pluto_textures", Destination = "textures", Version = 4 }, + { Identifier = "pluto_textures", Destination = "textures", Version = 5 }, { Identifier = "newhorizons_plutoencounter_pluto_images", Destination = "images", Version = 1 } }, } \ No newline at end of file diff --git a/data/scene/missions/newhorizons/pluto/pluto/pluto.mod b/data/scene/missions/newhorizons/pluto/pluto/pluto.mod index 3981f50f66..c2cc00c9f3 100644 --- a/data/scene/missions/newhorizons/pluto/pluto/pluto.mod +++ b/data/scene/missions/newhorizons/pluto/pluto/pluto.mod @@ -5,10 +5,6 @@ local NewHorizonsKernels = { "${SPICE}/new_horizons/spk/NavSE_plu047_od122.bsp" } -local ColorTexture = "textures/pluto.jpg" --- local ColorTexture = "textures/NH_Pluto_mosaic_16384.png" -local HeightTexture = "textures/NH_Pluto_DTM_16384.png" - return { -- Pluto barycenter module { @@ -33,14 +29,15 @@ return { Geometry = { Type = "SimpleSphere", Radius = pluto_radius, - Segments = 100 + Segments = 400 }, - ColorTexture = ColorTexture, - HeightTexture = HeightTexture, + ColorTexture = pluto_image, + HeightTexture = pluto_height, + MeridianShift = true, Projection = { Sequence = "${OPENSPACE_DATA}/scene/missions/newhorizons/pluto/pluto/images", EventFile = "${OPENSPACE_DATA}/scene/missions/newhorizons/pluto/pluto/assets/core_v9h_obs_getmets_v8_time_fix_nofrcd_mld.txt", - SequenceType = "hybrid", + SequenceType = "image-sequence", Observer = "NEW HORIZONS", Target = "PLUTO", Aberration = "NONE", diff --git a/data/scene/newhorizons.scene b/data/scene/newhorizons.scene index 267a88e5d5..6458344746 100644 --- a/data/scene/newhorizons.scene +++ b/data/scene/newhorizons.scene @@ -1,7 +1,23 @@ -UseAccurateNewHorizonsKernels = false --- TextureResolution = "low" -TextureResolution = "med" --- TextureResolution = "high" +-- These values specify the textures that are used for Pluto and Charon +-- The paths are relative to data/scene/missions/newhorizons/pluto/pluto and +-- data/scene/missions/newhorizons/pluto/charon respectively + +-- Each image is provided at a lower resolution for lower spec systems + +-- pluto_image = "textures/NH_Pluto_mosaic_8192.png" +-- pluto_image = "textures/NH_Pluto_mosaic_16384.png" +pluto_image = "textures/pmap_cyl_k201.jpg" +-- pluto_image = "textures/pmap_cyl_k201_4096.jpg" + +-- pluto_height = "textures/NH_Pluto_DTM_8192.png" +pluto_height = "textures/NH_Pluto_DTM_16384.png" + + +charon_image = "textures/NH_Charon_mosaic.png" +-- charon_image = "textures/NH_Charon_mosaic_8192.png" + +charon_height = "textures/NH_Charon_DTM.png" +-- charon_height = "textures/NH_Charon_DTM_8192.png" function preInitialization() --[[ @@ -14,7 +30,7 @@ function preInitialization() openspace.spice.loadKernel("${SPICE}/naif0012.tls") openspace.spice.loadKernel("${SPICE}/pck00010.tpc") - openspace.time.setTime("2015-07-14T10:05:00.00") + openspace.time.setTime("2015-07-14T08:00:00.00") -- Load the common helper functions dofile(openspace.absPath('${SCRIPTS}/common.lua')) @@ -28,79 +44,79 @@ function preInitialization() openspace.bindKey( "a", - "openspace.setPropertyValue('Interaction.origin', 'NewHorizons')", + "openspace.setPropertyValue('NavigationHandler.Origin', 'NewHorizons')", "Sets the focus of the camera on 'NewHorizons'." ) openspace.bindKey( "s", - "openspace.setPropertyValue('Interaction.origin', 'Pluto')", + "openspace.setPropertyValue('NavigationHandler.Origin', 'Pluto')", "Sets the focus of the camera on 'Pluto'" ) openspace.bindKey( "d", - "openspace.setPropertyValue('Interaction.origin', 'Charon')", + "openspace.setPropertyValue('NavigationHandler.Origin', 'Charon')", "Sets the focus of the camera on 'Charon'." ) openspace.bindKey( "z", - "openspace.setPropertyValue('Interaction.origin', 'JupiterProjection')", + "openspace.setPropertyValue('NavigationHandler.Origin', 'JupiterProjection')", "Sets the focus of the camera on 'Jupiter'." ) openspace.bindKey( "x", - "openspace.setPropertyValue('Interaction.origin', 'Europa')", + "openspace.setPropertyValue('NavigationHandler.Origin', 'Europa')", "Sets the focus of the camera on 'Europa'." ) openspace.bindKey( "F8", - "openspace.setPropertyValue('Pluto.renderable.ProjectionComponent.clearAllProjections', true);" .. - "openspace.setPropertyValue('Charon.renderable.ProjectionComponent.clearAllProjections', true);", + "openspace.setPropertyValue('Pluto.renderable.ProjectionComponent.ClearAllProjections', true);" .. + "openspace.setPropertyValue('Charon.renderable.ProjectionComponent.ClearAllProjections', true);", "Removes all image projections from Pluto and Charon." ) openspace.bindKey( "F9", "openspace.time.setTime('2015-07-14T09:00:00.00');" .. - "openspace.setPropertyValue('Pluto.renderable.clearAllProjections', true);" .. - "openspace.setPropertyValue('Charon.renderable.clearAllProjections', true);", + "openspace.setPropertyValue('Pluto.renderable.ClearAllProjections', true);" .. + "openspace.setPropertyValue('Charon.renderable.ClearAllProjections', true);", "Jumps to the 14th of July 2015 at 0900 UTC and clears all projections." ) openspace.bindKey( "KP_8", - helper.property.increment('Pluto.renderable.heightExaggeration', 0.1), + helper.property.increment('Pluto.renderable.HeightExaggeration', 5000000), "Increases the height map exaggeration on Pluto." ) openspace.bindKey( "KP_2", - helper.property.decrement('Pluto.renderable.heightExaggeration', 0.1), + helper.property.decrement('Pluto.renderable.HeightExaggeration', 5000000), "Decreases the height map exaggeration on Pluto." ) openspace.bindKey( "KP_9", - helper.property.increment('Charon.renderable.heightExaggeration', 2), + helper.property.increment('Charon.renderable.HeightExaggeration', 5000000), "Increases the height map exaggeration on Charon." ) openspace.bindKey( "KP_3", - helper.property.decrement('Charon.renderable.heightExaggeration', 2), + helper.property.decrement('Charon.renderable.HeightExaggeration', 5000000), "Decreases the height map exaggeration on Charon." ) openspace.bindKey( "q", - helper.property.invert('SunMarker.renderable.enabled'), + helper.property.invert('SunMarker.renderable.Enabled'), "Toggles the visibility of the text marking the location of the Sun." ) openspace.bindKey( "e", - helper.property.invert('EarthMarker.renderable.enabled'), + helper.property.invert('EarthMarker.renderable.Enabled'), "Toggles the visibility of the text marking the location of the Earth." ) openspace.bindKey( "o", - helper.property.invert('PlutoTrail.renderable.enabled'), + helper.property.invert('PlutoTrail.renderable.Enabled'), "Toggles the visibility of the trail behind Pluto." ) @@ -119,17 +135,17 @@ function preInitialization() ) openspace.bindKey("m", - helper.property.invert('NH_LORRI.renderable.solidDraw') .. - helper.property.invert('NH_RALPH_LEISA.renderable.solidDraw') .. - helper.property.invert('NH_RALPH_MVIC_PAN1.renderable.solidDraw') .. - helper.property.invert('NH_RALPH_MVIC_PAN2.renderable.solidDraw') .. - helper.property.invert('NH_RALPH_MVIC_RED.renderable.solidDraw') .. - helper.property.invert('NH_RALPH_MVIC_BLUE.renderable.solidDraw') .. - helper.property.invert('NH_RALPH_MVIC_FT.renderable.solidDraw') .. - helper.property.invert('NH_RALPH_MVIC_METHANE.renderable.solidDraw') .. - helper.property.invert('NH_RALPH_MVIC_NIR.renderable.solidDraw') .. - helper.property.invert('NH_ALICE_AIRGLOW.renderable.solidDraw') .. - helper.property.invert('NH_ALICE_SOC.renderable.solidDraw'), + helper.property.invert('NH_LORRI.renderable.SolidDraw') .. + helper.property.invert('NH_RALPH_LEISA.renderable.SolidDraw') .. + helper.property.invert('NH_RALPH_MVIC_PAN1.renderable.SolidDraw') .. + helper.property.invert('NH_RALPH_MVIC_PAN2.renderable.SolidDraw') .. + helper.property.invert('NH_RALPH_MVIC_RED.renderable.SolidDraw') .. + helper.property.invert('NH_RALPH_MVIC_BLUE.renderable.SolidDraw') .. + helper.property.invert('NH_RALPH_MVIC_FT.renderable.SolidDraw') .. + helper.property.invert('NH_RALPH_MVIC_METHANE.renderable.SolidDraw') .. + helper.property.invert('NH_RALPH_MVIC_NIR.renderable.SolidDraw') .. + helper.property.invert('NH_ALICE_AIRGLOW.renderable.SolidDraw') .. + helper.property.invert('NH_ALICE_SOC.renderable.SolidDraw'), "Draws the instrument field of views in a solid color or as lines." ) @@ -139,16 +155,16 @@ function preInitialization() "Toggles the visibility of the shadow visualization of Pluto and Charon." ) - openspace.bindKey("p", - helper.property.invert('JupiterProjection.renderable.performProjection') .. - helper.property.invert('Io.renderable.performProjection') .. - helper.property.invert('Ganymede.renderable.performProjection') .. - helper.property.invert('Europa.renderable.performProjection') .. - helper.property.invert('Callisto.renderable.performProjection') .. - helper.property.invert('Pluto.renderable.performProjection') .. - helper.property.invert('Charon.renderable.performProjection'), - "Enables or disables the image projection on the different available objects." - ) + -- openspace.bindKey("p", + -- helper.property.invert('JupiterProjection.renderable.PerformProjection') .. + -- helper.property.invert('Io.renderable.PerformProjection') .. + -- helper.property.invert('Ganymede.renderable.PerformProjection') .. + -- helper.property.invert('Europa.renderable.PerformProjection') .. + -- helper.property.invert('Callisto.renderable.PerformProjection') .. + -- helper.property.invert('Pluto.renderable.PerformProjection') .. + -- helper.property.invert('Charon.renderable.PerformProjection'), + -- "Enables or disables the image projection on the different available objects." + -- ) end function postInitialization() @@ -185,6 +201,7 @@ return { "venus", "earth", "mars", + "jupiter/jupiter", "saturn/saturn", "uranus", "neptune", @@ -193,7 +210,7 @@ return { "milkyway/digitaluniverse", --"milkyway/eso", "missions/newhorizons/pluto", - "missions/newhorizons/jupiter", + -- "missions/newhorizons/jupiter", "missions/newhorizons/newhorizons", "missions/newhorizons/newhorizonsfov" } diff --git a/modules/spacecraftinstruments/rendering/renderableplanetprojection.cpp b/modules/spacecraftinstruments/rendering/renderableplanetprojection.cpp index cf2763309f..cd5a6fcf97 100644 --- a/modules/spacecraftinstruments/rendering/renderableplanetprojection.cpp +++ b/modules/spacecraftinstruments/rendering/renderableplanetprojection.cpp @@ -82,6 +82,15 @@ namespace { "potential height field. A value of '0' inhibits the height field, whereas a " "value of '1' uses the measured height field." }; + + static const openspace::properties::Property::PropertyInfo MeridianShiftInfo = { + "MeridianShift", + "Meridian Shift", + "If this value is enabled, a shift of the meridian by 180 degrees is performed. " + "This is a fix especially for Pluto height maps, where the definition of the " + "meridian has changed through the New Horizons mission and this requires this " + "shift." + }; } // namespace namespace openspace { @@ -127,6 +136,12 @@ documentation::Documentation RenderablePlanetProjection::Documentation() { new DoubleVerifier, Optional::Yes, HeightExaggerationInfo.description + }, + { + MeridianShiftInfo.identifier, + new BoolVerifier, + Optional::Yes, + MeridianShiftInfo.description } } }; @@ -141,6 +156,7 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary& , _baseTexture(nullptr) , _heightMapTexture(nullptr) , _heightExaggeration(HeightExaggerationInfo, 1.f, 0.f, 100.f) + , _meridianShift(MeridianShiftInfo, false) , _capture(false) { documentation::testSpecificationAndThrow( @@ -177,6 +193,10 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary& _heightMapTexturePath = absPath(heightMapPath); } + if (dictionary.hasKeyAndValue(MeridianShiftInfo.identifier)) { + _meridianShift = dictionary.value(MeridianShiftInfo.identifier); + } + float radius = std::pow(10.f, 9.f); dictionary.getValue(KeyRadius, radius); setBoundingSphere(radius); @@ -197,6 +217,8 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary& } addProperty(_heightExaggeration); + + addProperty(_meridianShift); } RenderablePlanetProjection::~RenderablePlanetProjection() {} @@ -429,6 +451,7 @@ void RenderablePlanetProjection::render(const RenderData& data, RendererTasks&) _programObject->setUniform("_hasHeightMap", _heightMapTexture != nullptr); _programObject->setUniform("_heightExaggeration", _heightExaggeration); + _programObject->setUniform("_meridianShift", _meridianShift); _programObject->setUniform("_projectionFading", _projectionComponent.projectionFading()); //_programObject->setUniform("debug_projectionTextureRotation", glm::radians(_debugProjectionTextureRotation.value())); @@ -491,8 +514,8 @@ bool RenderablePlanetProjection::loadTextures() { ); if (_baseTexture) { ghoul::opengl::convertTextureFormat(*_baseTexture, Texture::Format::RGB); - _baseTexture->uploadTexture(); _baseTexture->setFilter(Texture::FilterMode::Linear); + _baseTexture->uploadTexture(); } } diff --git a/modules/spacecraftinstruments/rendering/renderableplanetprojection.h b/modules/spacecraftinstruments/rendering/renderableplanetprojection.h index a672032c20..855d1e834a 100644 --- a/modules/spacecraftinstruments/rendering/renderableplanetprojection.h +++ b/modules/spacecraftinstruments/rendering/renderableplanetprojection.h @@ -74,6 +74,7 @@ private: std::unique_ptr _heightMapTexture; properties::FloatProperty _heightExaggeration; + properties::BoolProperty _meridianShift; std::unique_ptr _geometry; diff --git a/modules/spacecraftinstruments/shaders/renderablePlanet_fs.glsl b/modules/spacecraftinstruments/shaders/renderablePlanet_fs.glsl index 049b1deb8e..62d375f2f8 100644 --- a/modules/spacecraftinstruments/shaders/renderablePlanet_fs.glsl +++ b/modules/spacecraftinstruments/shaders/renderablePlanet_fs.glsl @@ -31,7 +31,7 @@ in vec2 vs_st; uniform sampler2D baseTexture; uniform sampler2D projectionTexture; -uniform bool shiftMeridian; +uniform bool _meridianShift; uniform float _projectionFading; @@ -41,7 +41,7 @@ uniform vec3 sun_pos; Fragment getFragment() { vec2 st = vs_st; - if (shiftMeridian) { + if (_meridianShift) { st.s += 0.5; } diff --git a/modules/spacecraftinstruments/shaders/renderablePlanet_vs.glsl b/modules/spacecraftinstruments/shaders/renderablePlanet_vs.glsl index 1ef4e23d9b..75d463162b 100644 --- a/modules/spacecraftinstruments/shaders/renderablePlanet_vs.glsl +++ b/modules/spacecraftinstruments/shaders/renderablePlanet_vs.glsl @@ -41,6 +41,8 @@ uniform bool _hasHeightMap; uniform float _heightExaggeration; uniform sampler2D heightTexture; +uniform bool _meridianShift; + void main() { vs_st = in_st; @@ -52,7 +54,11 @@ void main() { if (_hasHeightMap) { - float height = texture(heightTexture, in_st).s; + vec2 st = vs_st; + if (_meridianShift) { + st += vec2(0.5, 0.0); + } + float height = texture(heightTexture, st).s; vec3 displacementDirection = (normalize(tmp.xyz)); float displacementFactor = height * _heightExaggeration / 750.0; tmp.xyz += displacementDirection * displacementFactor;