From fb7104fbed07afdbcae859fa0df8f66d87fae607 Mon Sep 17 00:00:00 2001 From: Kalle Bladin Date: Mon, 15 Aug 2016 20:20:36 -0400 Subject: [PATCH] Add renderable fov to OSIRIS-REx polycam and increse precision in rendering of view frustum (fov) --- data/scene/osirisrex/bennu/bennu.mod | 21 +---- data/scene/osirisrex/osirisrex/osirisrex.mod | 78 ++++++++++++++++++- .../newhorizons/rendering/renderablefov.cpp | 17 +++- modules/newhorizons/shaders/fov_fs.glsl | 22 +++--- modules/newhorizons/shaders/fov_vs.glsl | 26 ++++--- 5 files changed, 118 insertions(+), 46 deletions(-) diff --git a/data/scene/osirisrex/bennu/bennu.mod b/data/scene/osirisrex/bennu/bennu.mod index 748523794a..be5b79ff2a 100644 --- a/data/scene/osirisrex/bennu/bennu.mod +++ b/data/scene/osirisrex/bennu/bennu.mod @@ -60,26 +60,7 @@ return { }, }, Target = { - Body = BENNU_BODY, - --[[ - Read = { - "TARGET_NAME", - "INSTRUMENT_HOST_NAME", - "INSTRUMENT_ID", - "START_TIME", - "STOP_TIME", - }, - Convert = { - CHURYUMOV = {"CHURYUMOV-GERASIMENKO"}, - ROSETTA = {"ROSETTA" }, - --NAVCAM = {"NAVCAM"}, - ["ROSETTA-ORBITER"] = {"ROSETTA" }, - CHURYUMOVGERASIMENKO11969R1 = {"CHURYUMOV-GERASIMENKO"}, - CHURYUMOVGERASIMENKO = {"CHURYUMOV-GERASIMENKO"}, - ["CHURYUMOV-GERASIMENKO1(1969R1)"] = {"CHURYUMOV-GERASIMENKO"}, - --NAVIGATIONCAMERA = {"NAVCAM" }, - }, - ]] + Body = BENNU_BODY, -- Do we need this? }, }, diff --git a/data/scene/osirisrex/osirisrex/osirisrex.mod b/data/scene/osirisrex/osirisrex/osirisrex.mod index d854294416..d3979c3bf6 100644 --- a/data/scene/osirisrex/osirisrex/osirisrex.mod +++ b/data/scene/osirisrex/osirisrex/osirisrex.mod @@ -69,7 +69,7 @@ return { Destination = "ORX_SPACECRAFT" }, Transform = { - Translation = {0,0,0}, -- Translation relative to parent + Translation = {1,0,0}, -- Translation relative to parent --Rotation = {0,0,0}, -- Euler angles relative to parent (not implemented) --Scale = {1,1,1}, -- Scale relative to parent (not implemented) }, @@ -77,6 +77,82 @@ return { GuiName = "/Solar/ORX_OCAMS_POLYCAM" }, + + --[[ + { + Name = "ORX_OCAMS_POLYCAM FOV", + Parent = "ORX_OCAMS_POLYCAM", + Renderable = { + Type = "RenderableFov", + Body = "OSIRIS-REX", + Frame = "GALACTIC", + RGB = { 0.8, 0.7, 0.7 }, + Textures = { + Type = "simple", + Color = "textures/glare_blue.png", + -- need to add different texture + }, + Instrument = { + Name = "ORX_OCAMS_POLYCAM", + Method = "ELLIPSOID", + Aberration = "NONE", + }, + PotentialTargets = { + "Bennu2", + } + }, + GuiName = "/Solar/ORX_OCAMS_POLYCAM" + }, +]] + + + + + { + Name = "POLYCAM", + Parent = "ORX_OCAMS_POLYCAM", + Renderable = { + Type = "RenderableFov", + Body = "OSIRIS-REX", + Frame = "ORX_OCAMS_POLYCAM", + RGB = { 0.8, 0.7, 0.7 }, + Textures = { + Type = "simple", + Color = "textures/glare_blue.png", + -- need to add different texture + }, + Instrument = { + Name = "ORX_OCAMS_POLYCAM", + Method = "ELLIPSOID", + Aberration = "NONE", + }, + PotentialTargets = { + BENNU_BODY -- Bennu + } + }, + GuiName = "/Solar/POLYCAM" + }, + -- Latest image taken by POLYCAM + --[[ + { + Name = "ImagePlaneOsirisRex", + Parent = "OsirisRex", + Renderable = { + Type = "RenderablePlaneProjection", + Frame = "IAU_BENNU", + DefaultTarget = BENNU_BODY, + Spacecraft = "OSIRIS-REX", + Instrument = "ORX_OCAMS_POLYCAM", + Moving = false, + Texture = "textures/defaultProj.png", + }, + Ephemeris = { + Type = "Static", + Position = {0, 0, 0, 1} + }, + }, + ]] + { Name = "OsirisRexPathSolar", Parent = "SolarSystemBarycenter", diff --git a/modules/newhorizons/rendering/renderablefov.cpp b/modules/newhorizons/rendering/renderablefov.cpp index 8e7ebe8f94..589cc38684 100644 --- a/modules/newhorizons/rendering/renderablefov.cpp +++ b/modules/newhorizons/rendering/renderablefov.cpp @@ -549,10 +549,21 @@ void RenderableFov::render(const RenderData& data) { _drawFOV = false; // setup the data to the shader - _programObject->setUniform("ViewProjection", data.camera.viewProjectionMatrix()); - _programObject->setUniform("ModelTransform", glm::mat4(1)); - setPscUniforms(*_programObject.get(), data.camera, data.position); + //_programObject->setUniform("ViewProjection", data.camera.viewProjectionMatrix()); + //_programObject->setUniform("ModelTransform", glm::translate(glm::mat4(1), glm::vec3(data.positionVec3)) ); + //setPscUniforms(*_programObject.get(), data.camera, data.position); + // Model transform and view transform needs to be in double precision + glm::dmat4 modelTransform = + glm::translate(glm::dmat4(1.0), data.positionVec3) * // Translation + glm::dmat4(data.rotation); + glm::mat4 modelViewProjectionTransform = + data.camera.projectionMatrix() * + glm::mat4(data.camera.combinedViewMatrix() * + modelTransform); + + _programObject->setUniform("modelViewProjectionTransform", modelViewProjectionTransform); + if (openspace::ImageSequencer::ref().isReady()) { _drawFOV = ImageSequencer::ref().instrumentActive(_instrumentID); } diff --git a/modules/newhorizons/shaders/fov_fs.glsl b/modules/newhorizons/shaders/fov_fs.glsl index 8df343f683..fcd3bd2c65 100644 --- a/modules/newhorizons/shaders/fov_fs.glsl +++ b/modules/newhorizons/shaders/fov_fs.glsl @@ -22,11 +22,17 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ +/* uniform mat4 ViewProjection; uniform mat4 ModelTransform; in vec4 vs_point_position; in vec4 vs_point_velocity; +*/ + +//out vec4 vs_point_position; +in vec4 vs_point_velocity; +in vec4 vs_positionScreenSpace; //out vec4 diffuse; @@ -35,19 +41,9 @@ in vec4 vs_point_velocity; #include "fragment.glsl" Fragment getFragment() { - - vec4 position = vs_point_position; - float depth = pscDepth(position); - - // set the depth - //gl_FragDepth = depth; - - //float l = length(vs_point_velocity); - - vec4 diffuse = vs_point_velocity; - Fragment frag; - frag.color = diffuse; - frag.depth = depth; + frag.color = vs_point_velocity; + frag.depth = vs_positionScreenSpace.w; + return frag; } diff --git a/modules/newhorizons/shaders/fov_vs.glsl b/modules/newhorizons/shaders/fov_vs.glsl index 31841d408e..757b7dc336 100644 --- a/modules/newhorizons/shaders/fov_vs.glsl +++ b/modules/newhorizons/shaders/fov_vs.glsl @@ -24,30 +24,38 @@ #version __CONTEXT__ -uniform mat4 ViewProjection; -uniform mat4 ModelTransform; +//uniform mat4 ViewProjection; +//uniform mat4 ModelTransform; //uniform vec4 etColor; -uniform vec4 objectVelocity; +//uniform vec4 objectVelocity; layout(location = 0) in vec4 in_point_position; layout(location = 1) in vec4 in_point_velocity; layout(location = 2) in vec2 in_point_timeindex; -out vec4 vs_point_position; +//out vec4 vs_point_position; out vec4 vs_point_velocity; +// Uniforms +uniform mat4 modelViewProjectionTransform; + +// Outputs +out vec4 vs_positionScreenSpace; + #include "PowerScaling/powerScaling_vs.hglsl" void main() { + vec4 position = vec4(in_point_position.xyz * pow(10, in_point_position.w), 1); + vec4 positionClipSpace = modelViewProjectionTransform * position; + + // Write output + vs_positionScreenSpace = z_normalization(positionClipSpace); + gl_Position = vs_positionScreenSpace; + vs_point_velocity = in_point_velocity; - vec4 tmp = in_point_position; - vec4 position = pscTransform(tmp, ModelTransform); - vs_point_position = tmp; - position = ViewProjection * position; - gl_Position = z_normalization(position); /* //vs_point_position = objpos;