Implement class RenderableTrailNew and use it for osiris rex. Higher precision than the old one.

This commit is contained in:
Kalle Bladin
2016-08-23 17:29:51 -04:00
parent 6875e8c1c7
commit 57d47cd856
10 changed files with 740 additions and 69 deletions
+4
View File
@@ -38,6 +38,7 @@ set(HEADER_FILES
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablesphericalgrid.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablestars.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderabletrail.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderabletrailnew.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/simplespheregeometry.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/screenspaceframebuffer.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/screenspaceimage.h
@@ -63,6 +64,7 @@ set(SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablesphericalgrid.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablestars.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderabletrail.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderabletrailnew.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/simplespheregeometry.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/screenspaceframebuffer.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/screenspaceimage.cpp
@@ -79,6 +81,8 @@ set(SHADER_FILES
${CMAKE_CURRENT_SOURCE_DIR}/shaders/constellationbounds_vs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/ephemeris_fs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/ephemeris_vs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/renderabletrailnew_fs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/renderabletrailnew_vs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/imageplane_fs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/imageplane_vs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/model_fs.glsl
+2
View File
@@ -34,6 +34,7 @@
#include <modules/base/rendering/renderableconstellationbounds.h>
#include <modules/base/rendering/renderablestars.h>
#include <modules/base/rendering/renderabletrail.h>
#include <modules/base/rendering/renderabletrailnew.h>
#include <modules/base/rendering/renderablepath.h>
#include <modules/base/rendering/renderablerings.h>
#include <modules/base/rendering/renderablesphere.h>
@@ -90,6 +91,7 @@ void BaseModule::internalInitialize() {
fRenderable->registerClass<RenderableSphericalGrid>("RenderableSphericalGrid");
fRenderable->registerClass<RenderableStars>("RenderableStars");
fRenderable->registerClass<RenderableTrail>("RenderableTrail");
fRenderable->registerClass<RenderableTrailNew>("RenderableTrailNew");
auto fEphemeris = FactoryManager::ref().factory<Ephemeris>();
ghoul_assert(fEphemeris, "Ephemeris factory was not created");
+3 -1
View File
@@ -166,7 +166,9 @@ void RenderableTrail::render(const RenderData& data) {
// Model transform and view transform needs to be in double precision
glm::dmat4 modelTransform =
glm::translate(glm::dmat4(1.0), bodyPosition); // Only care about translation
glm::translate(glm::dmat4(1.0), bodyPosition) *
glm::dmat4(data.modelTransform.rotation) * // Spice rotation
glm::dmat4(glm::scale(glm::dmat4(1.0), glm::dvec3(data.modelTransform.scale)));
glm::dmat4 modelViewTransform = data.camera.combinedViewMatrix() * modelTransform;
_programObject->setUniform("modelViewTransform", glm::mat4(modelViewTransform));
@@ -0,0 +1,418 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2016 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <modules/base/rendering/renderabletrailnew.h>
#include <openspace/util/time.h>
#include <openspace/util/spicemanager.h>
#include <openspace/util/updatestructures.h>
#include <openspace/util/timerange.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/rendering/renderengine.h>
#include <openspace/interaction/interactionhandler.h>
#include <ghoul/opengl/programobject.h>
#include <limits>
#include <stdint.h>
namespace {
const std::string _loggerCat = "RenderableTrailNew";
// Spice
const std::string keyBody = "Body";
const std::string keyFrame = "Frame";
const std::string keyObserver = "Observer";
// Rendering properties
const std::string keyLineColor = "LineColor";
const std::string keyPointColor = "PointColor";
const std::string keyLineFade = "LineFade";
const std::string keyLineWidth = "LineWidth";
const std::string keyRenderPart = "RenderPart";
const std::string keyShowTimeStamps = "ShowTimeStamps";
const std::string keyRenderFullTrail = "RenderFullTrail";
// Time interval
const std::string keyTimeRange = "TimeRange";
const std::string keySampleDeltaTime = "SampleDeltaTime";
const std::string keySubSamples = "SubSamples";
// Static Constants
static const glm::vec3 DEFAULT_COLOR = glm::vec3(1.0f);
static const float DEFAULT_LINE_FADE = 0.5f;
static const float DEFAULT_LINE_WIDTH = 2.0f;
static const int DEFAULT_POINT_STEPS = 1;
static const int DEFAULT_RENDER_PART = 1;
static const bool DEFAULT_SHOW_TIME_STAMPS = false;
static const bool DEFAULT_RENDER_FULL_TRAIL = false;
}
namespace openspace {
RenderableTrailNew::RenderableTrailNew(const ghoul::Dictionary& dictionary)
: Renderable(dictionary)
// Properties
, _lineColor("lineColor", "Line Color", DEFAULT_COLOR, glm::vec3(0), glm::vec3(1))
, _pointColor("pointColor", "Point Color", DEFAULT_COLOR, glm::vec3(0), glm::vec3(1))
, _lineFade("lineFade", "Line Fade", DEFAULT_LINE_FADE, 0, 1)
, _lineWidth("lineWidth", "Line Width", DEFAULT_LINE_WIDTH, 1, 10)
, _renderPart("renderPart", "Render Part", DEFAULT_RENDER_PART, 0, DEFAULT_RENDER_PART)
, _showTimeStamps("showTimeStamps", "Show TimeStamps", DEFAULT_SHOW_TIME_STAMPS)
, _renderFullTrail("renderFullTrail", "Render Full Trail", DEFAULT_RENDER_FULL_TRAIL)
// OpenGL
, _vaoGlobalID(0)
, _vBufferGlobalID(0)
, _vaoLocalID(0)
, _vBufferLocalID(0)
// Other
, _programObject(nullptr)
, _successfullDictionaryFetch(true)
, _currentTimeClamped(0)
, _subSamples(0)
{
ghoul::Dictionary timeRangeDict;
// Values that needs to be set
_successfullDictionaryFetch &= dictionary.getValue(keyBody, _body);
_successfullDictionaryFetch &= dictionary.getValue(keyObserver, _observer);
_successfullDictionaryFetch &= dictionary.getValue(keyFrame, _frame);
_successfullDictionaryFetch &= dictionary.getValue(keySampleDeltaTime, _sampleDeltaTime);
_successfullDictionaryFetch &= dictionary.getValue(keyTimeRange, timeRangeDict);
_successfullDictionaryFetch &= TimeRange::initializeFromDictionary(
timeRangeDict, _timeRange);
// Validate
_successfullDictionaryFetch &= _sampleDeltaTime > 0;
// Initialize optional values
glm::vec3 lineColor = glm::vec3(DEFAULT_COLOR);
glm::vec3 pointColor = glm::vec3(DEFAULT_COLOR);
float lineFade = DEFAULT_LINE_FADE;
float lineWidth = DEFAULT_LINE_WIDTH;
float pointSteps = DEFAULT_POINT_STEPS;
double renderPart = DEFAULT_RENDER_PART;
bool showTimeStamps = DEFAULT_SHOW_TIME_STAMPS;
bool renderFullTrail = DEFAULT_RENDER_FULL_TRAIL;
// Fetch from dictionary
dictionary.getValue(keyLineColor, lineColor);
dictionary.getValue(keyPointColor, pointColor);
dictionary.getValue(keyLineFade, lineFade);
dictionary.getValue(keyLineWidth, lineWidth);
dictionary.getValue(keyRenderPart, renderPart);
dictionary.getValue(keyShowTimeStamps, showTimeStamps);
dictionary.getValue(keyRenderFullTrail, renderFullTrail);
float fSubSamples; // ghoul can not read ints from dictionaries...
if (dictionary.getValue(keySubSamples, fSubSamples))
_subSamples = fSubSamples;
// Set property values
_lineColor = lineColor;
_pointColor = pointColor;
_lineFade = lineFade;
_lineWidth = lineWidth;
_renderPart = renderPart;
_showTimeStamps = showTimeStamps;
_renderFullTrail = renderFullTrail;
// Add all properties and set view options
addProperty(_lineColor);
addProperty(_pointColor);
addProperty(_lineFade);
addProperty(_lineWidth);
addProperty(_renderPart);
addProperty(_showTimeStamps);
addProperty(_renderFullTrail);
_lineColor.setViewOption(properties::Property::ViewOptions::Color);
_pointColor.setViewOption(properties::Property::ViewOptions::Color);
}
bool RenderableTrailNew::initialize() {
if (!_successfullDictionaryFetch) {
LERROR("The following keys need to be set in the Dictionary. Cannot initialize!");
LERROR(keyBody << ": " << _body);
LERROR(keyObserver << ": " << _observer);
LERROR(keyFrame << ": " << _frame);
LERROR(keyTimeRange);
return false;
}
if (_subSamples < 0)
LERROR("SubSamples must not be less than 0: " << _subSamples);
RenderEngine& renderEngine = OsEng.renderEngine();
_programObject = renderEngine.buildRenderProgram("RenderableTrailNewProgram",
"${MODULE_BASE}/shaders/renderabletrailnew_vs.glsl",
"${MODULE_BASE}/shaders/renderabletrailnew_fs.glsl");
if (!_programObject)
return false;
sweepTimeRange();
initializeGlobalOpenGLPathData();
initializeLocalOpenGLPathData();
return true;
}
void RenderableTrailNew::initializeGlobalOpenGLPathData() {
glGenVertexArrays(1, &_vaoGlobalID);
glGenBuffers(1, &_vBufferGlobalID);
glBindVertexArray(_vaoGlobalID);
glBindBuffer(GL_ARRAY_BUFFER, _vBufferGlobalID);
// No need to update the trail several times, no need for stream draw.
glBufferData(
GL_ARRAY_BUFFER,
_vertexPositionArray.size() * sizeof(glm::vec3),
&_vertexPositionArray[0],
GL_STATIC_DRAW);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
glBindVertexArray(0);
}
void RenderableTrailNew::initializeLocalOpenGLPathData() {
glGenVertexArrays(1, &_vaoLocalID);
glGenBuffers(1, &_vBufferLocalID);
glBindVertexArray(_vaoLocalID);
glBindBuffer(GL_ARRAY_BUFFER, _vBufferLocalID);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
glBindVertexArray(0);
}
void RenderableTrailNew::deInitializeGlobalOpenGLPathData() {
glDeleteVertexArrays(1, &_vaoGlobalID);
glDeleteBuffers(1, &_vBufferGlobalID);
}
void RenderableTrailNew::deInitializeLocalOpenGLPathData() {
glDeleteVertexArrays(1, &_vaoLocalID);
glDeleteBuffers(1, &_vBufferLocalID);
}
bool RenderableTrailNew::deinitialize() {
deInitializeGlobalOpenGLPathData();
deInitializeLocalOpenGLPathData();
RenderEngine& renderEngine = OsEng.renderEngine();
if (_programObject) {
renderEngine.removeRenderProgram(_programObject);
_programObject = nullptr;
}
return true;
}
void RenderableTrailNew::sweepTimeRange() {
double lightTime = 0.0;
double subDeltaTime = _sampleDeltaTime / (1 + _subSamples);
glm::dvec3 bodyPosition;
// Loop through all points from time range start to end
for (double t = _timeRange.start; t < _timeRange.end; t += subDeltaTime) {
try {
bodyPosition = SpiceManager::ref().targetPosition(
_body, _observer, _frame, {}, t, lightTime);
}
catch (const SpiceManager::SpiceException& e) {
LERROR(e.what());
break;
}
// Convert from km used by SPICE to meters used by OpenSpace
bodyPosition *= 1000;
_vertexPositionArray.push_back(glm::vec3(bodyPosition));
}
// Last point
bodyPosition = SpiceManager::ref().targetPosition(
_body, _observer, _frame, {}, _timeRange.end, lightTime);
_vertexPositionArray.push_back(glm::vec3(bodyPosition));
}
bool RenderableTrailNew::isReady() const {
return (_programObject != nullptr) && _successfullDictionaryFetch;
}
void RenderableTrailNew::render(const RenderData& data) {
_programObject->activate();
if (_renderFullTrail.value() == true) {
preRender(_vertexPositionArray.size());
preRenderSubPathGlobally(data);
// Easy but not beautiful solution to render all vertices with max alpha
_programObject->setUniform(
"vertexIDPadding", static_cast<int>(_vertexPositionArray.size()));
renderLines(_vaoGlobalID, _vertexPositionArray.size() - 1);
if (_showTimeStamps) {
renderPoints(_vaoGlobalID, _vertexPositionArray.size() - 1);
}
}
else { // Only render the trail up to the point of the object body
int nVerticesToDraw = glm::ceil(_vertexPositionArray.size() *
(_currentTimeClamped - _timeRange.start) / (_timeRange.end - _timeRange.start));
nVerticesToDraw = glm::min(
nVerticesToDraw, static_cast<int>(_vertexPositionArray.size())) - 1;
if (nVerticesToDraw > 1) {
preRender(nVerticesToDraw);
// Perform rendering of the bulk of the trail in single floating point precision
preRenderSubPathGlobally(data);
// The last vertex is drawn with higher precision after this
// Hence we subtract one vertex from the ones to draw globally
int nVerticesToDrawGlobally = nVerticesToDraw - 1;
renderLines(_vaoGlobalID, nVerticesToDrawGlobally);
if (_showTimeStamps) {
renderPoints(_vaoGlobalID, nVerticesToDrawGlobally);
}
// The last line segment is rendered relative to body to achieve high precision
preRenderSubPathLocally(data, nVerticesToDraw);
renderLines(_vaoLocalID, 2);
if (_showTimeStamps) {
renderPoints(_vaoLocalID, 2);
}
}
else if (_currentTimeClamped > _timeRange.start) {
preRenderSubPathLocally(data, 2);
renderLines(_vaoLocalID, 2);
}
}
_programObject->deactivate();
}
void RenderableTrailNew::preRender(int totalNumVerticesToDraw) {
// Upload uniforms that are the same for global and local rendering to the program
_programObject->setUniform("lineFade", _lineFade.value());
_programObject->setUniform("subSamples", _subSamples);
_programObject->setUniform("maxNumVertices",
static_cast<int>(_renderPart.value() * _vertexPositionArray.size()));
_programObject->setUniform("numVertices", totalNumVerticesToDraw);
}
void RenderableTrailNew::preRenderSubPathGlobally(const RenderData& data) {
// Model transform and view transform needs to be in double precision
glm::dmat4 modelViewTransform = data.camera.combinedViewMatrix() * _modelTransform;
glm::mat4 modelViewProjectionTransform =
data.camera.projectionMatrix() * glm::mat4(modelViewTransform);
// Upload uniforms that are specific to global rendering to the shader program
_programObject->setUniform(
"modelViewProjectionTransform", modelViewProjectionTransform);
_programObject->setUniform("vertexIDPadding", 0);
}
void RenderableTrailNew::preRenderSubPathLocally(
const RenderData& data, int totalNumVerticesToDraw) {
glm::dvec3 v0; // Vertex that connects to the global part of the trail
glm::dvec3 v1; // last vertex of the trail is in the position of the body
v0 = _vertexPositionArray[totalNumVerticesToDraw - 2];
v1 = _clampedBodyPosition;
// Define positions relative to body (v1) which gives the high precision
glm::vec3 vertexData[2] = {glm::vec3(v0 - v1), glm::vec3(0)};
// Translation translates from the position of body so vertices should
// be defined relative to body (hence the added v1 in translation part of model matrix)
glm::dmat4 localTranslation = glm::translate(glm::dmat4(1.0), v1);
glm::dmat4 modelTransformLocal = _modelTransform * localTranslation;
glm::dmat4 modelViewTransform = data.camera.combinedViewMatrix() * modelTransformLocal;
glm::mat4 modelViewProjectionTransform =
data.camera.projectionMatrix() * glm::mat4(modelViewTransform);
// Upload the new MVP matrix to the shader program
_programObject->setUniform(
"modelViewProjectionTransform", modelViewProjectionTransform);
_programObject->setUniform("vertexIDPadding", totalNumVerticesToDraw - 2);
// Update the attribute data on the GPU
glBindBuffer(GL_ARRAY_BUFFER, _vBufferLocalID);
glBufferData(
GL_ARRAY_BUFFER,
2 * sizeof(glm::vec3), // Only two vertices for this part of the trail
vertexData, // Two vertices
GL_DYNAMIC_DRAW); // This part of the path is rendered dynamically
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
}
void RenderableTrailNew::renderLines(GLuint vao, int numberOfVertices) {
glLineWidth(_lineWidth);
_programObject->setUniform("color", _lineColor.value());
glBindVertexArray(vao);
glDrawArrays(GL_LINE_STRIP, 0, static_cast<GLsizei>(numberOfVertices));
glBindVertexArray(0);
glLineWidth(1.f);
}
void RenderableTrailNew::renderPoints(GLuint vao, int numberOfVertices) {
glEnable(GL_PROGRAM_POINT_SIZE);
_programObject->setUniform("color", _pointColor.value());
_programObject->setUniform("pointSize", static_cast<float>(_lineWidth * 3));
glBindVertexArray(vao);
glDrawArrays(GL_POINTS, 0, static_cast<GLsizei>(numberOfVertices));
glBindVertexArray(0);
glDisable(GL_PROGRAM_POINT_SIZE);
}
void RenderableTrailNew::update(const UpdateData& data) {
_currentTimeClamped = glm::clamp(data.time, _timeRange.start, _timeRange.end);
_modelTransform =
glm::translate(glm::dmat4(1.0), data.modelTransform.translation) *
glm::dmat4(data.modelTransform.rotation) *
glm::dmat4(glm::scale(glm::dmat4(1.0), glm::dvec3(data.modelTransform.scale)));
// Fetch the body position using SPICE
double lightTime = 0.0;
try {
_clampedBodyPosition = SpiceManager::ref().targetPosition(
_body, _observer, _frame, {}, _currentTimeClamped, lightTime);
}
catch (const SpiceManager::SpiceException& e) {
try {
_clampedBodyPosition = SpiceManager::ref().targetPosition(
_body, _observer, _frame, {}, _currentTimeClamped, _timeRange.end);
}
catch (const SpiceManager::SpiceException& e) {
return;
}
}
// Convert from km used by SPICE to meters used by OpenSpace
_clampedBodyPosition *= 1000;
}
} // namespace openspace
+113
View File
@@ -0,0 +1,113 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2016 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __RENDERABLETRAILNEW_H__
#define __RENDERABLETRAILNEW_H__
#include <openspace/rendering/renderable.h>
#include <openspace/properties/stringproperty.h>
#include <openspace/properties/vectorproperty.h>
#include <openspace/util/timerange.h>
#include <ghoul/opengl/ghoul_gl.h>
namespace ghoul {
namespace opengl {
class ProgramObject;
class Texture;
}
}
namespace openspace {
/**
* This class currently has a temporary name until it is merged
* with or replaces RenderableTrail.
*/
class RenderableTrailNew : public Renderable {
public:
explicit RenderableTrailNew(const ghoul::Dictionary& dictionary);
bool initialize() override;
bool deinitialize() override;
bool isReady() const override;
void render(const RenderData& data) override;
void update(const UpdateData& data) override;
private:
void sweepTimeRange();
void initializeGlobalOpenGLPathData();
void initializeLocalOpenGLPathData();
void deInitializeGlobalOpenGLPathData();
void deInitializeLocalOpenGLPathData();
void preRender(int totalNumVerticesToDraw);
void preRenderSubPathGlobally(const RenderData& renderData);
void preRenderSubPathLocally(const RenderData& renderData, int totalNumVerticesToDraw);
void renderLines(GLuint vao, int numberOfVertices);
void renderPoints(GLuint vao, int numberOfVertices);
// Spice
std::string _body;
std::string _observer;
std::string _frame;
// Properties
properties::Vec3Property _lineColor;
properties::Vec3Property _pointColor;
properties::FloatProperty _lineFade;
properties::FloatProperty _lineWidth;
properties::FloatProperty _renderPart;
properties::BoolProperty _showTimeStamps;
properties::BoolProperty _renderFullTrail;
// OpenGL
GLuint _vaoGlobalID;
GLuint _vBufferGlobalID;
GLuint _vaoLocalID;
GLuint _vBufferLocalID;
// Other
bool _successfullDictionaryFetch;
TimeRange _timeRange;
double _sampleDeltaTime;
int _subSamples;
std::unique_ptr<ghoul::opengl::ProgramObject> _programObject;
std::vector<glm::vec3> _vertexPositionArray;
double _currentTimeClamped; // Time clamped to time range
glm::dmat4 _modelTransform;
glm::dvec3 _clampedBodyPosition; // Position of body clamped to time range
};
} // namespace openspace
#endif // __RENDERABLETRAILNEW_H__
@@ -0,0 +1,46 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2016 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
// Inputs
in vec4 vs_positionScreenSpace;
in float vs_alpha;
// Uniforms
uniform float forceFade;
uniform vec3 color;
#include "PowerScaling/powerScaling_fs.hglsl"
#include "fragment.glsl"
Fragment getFragment() {
if (vs_alpha < 0.01)
discard;
vec4 c = vec4(color, vs_alpha);
Fragment frag;
frag.color = c;
frag.depth = vs_positionScreenSpace.w;
return frag;
}
@@ -0,0 +1,58 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2016 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#version __CONTEXT__
// Attributes
layout(location = 0) in vec3 in_position;
// Uniforms
uniform mat4 modelViewProjectionTransform;
uniform int numVertices;
uniform int maxNumVertices;
uniform int subSamples;
uniform float lineFade;
uniform int vertexIDPadding;
uniform float pointSize;
// Outputs
out vec4 vs_positionScreenSpace;
out float vs_alpha;
#include "PowerScaling/powerScaling_vs.hglsl"
void main() {
int vertexID = gl_VertexID + vertexIDPadding;
int threshHold = int(lineFade * numVertices);
int nVisibleVertices = min((int(numVertices) - threshHold), maxNumVertices);
vs_alpha = clamp((vertexID - (int(numVertices) - nVisibleVertices))
/ float(nVisibleVertices), 0, 1);
vec4 positionClipSpace = modelViewProjectionTransform * vec4(in_position, 1);
vs_positionScreenSpace = z_normalization(positionClipSpace);
gl_PointSize = (subSamples == 0 || vertexID % subSamples == 0) ? pointSize : pointSize / 2;
gl_Position = vs_positionScreenSpace;
}