mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-06 19:39:56 -05:00
made the flow segment size dependant on light travel time. Also renamed 'signal speed' to 'flow speed'
This commit is contained in:
@@ -43,7 +43,7 @@ namespace {
|
||||
|
||||
constexpr const std::array <const char*, openspace::RenderableSignals::uniformCacheSize> UniformNames = {
|
||||
"modelViewStation","modelViewSpacecraft", "projectionTransform", "baseOpacity",
|
||||
"signalSpeedFactor", "segmentSizeFactor", "spacingSizeFactor", "fadeFactor"
|
||||
"flowSpeedFactor", "segmentSizeFactor", "spacingSizeFactor", "fadeFactor"
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo SiteColorsInfo = {
|
||||
@@ -65,10 +65,10 @@ namespace {
|
||||
"This value specifies the base opacity of all the signal transmissions "
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo SignalSpeedInfo = {
|
||||
"SignalSpeed",
|
||||
"Signal Speed",
|
||||
"Speed of signal transmission segments "
|
||||
constexpr openspace::properties::Property::PropertyInfo FlowSpeedInfo = {
|
||||
"FlowSpeed",
|
||||
"Flow Speed",
|
||||
"Speed of signal transmission flow effect, i.e. the segments within the transmission "
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo SegmentSizeInfo = {
|
||||
@@ -131,10 +131,10 @@ documentation::Documentation RenderableSignals::Documentation() {
|
||||
BaseOpacityInfo.description
|
||||
},
|
||||
{
|
||||
SignalSpeedInfo.identifier,
|
||||
FlowSpeedInfo.identifier,
|
||||
new DoubleVerifier,
|
||||
Optional::Yes,
|
||||
SignalSpeedInfo.description
|
||||
FlowSpeedInfo.description
|
||||
},
|
||||
{
|
||||
SegmentSizeInfo.identifier,
|
||||
@@ -162,9 +162,9 @@ RenderableSignals::RenderableSignals(const ghoul::Dictionary& dictionary)
|
||||
: Renderable(dictionary)
|
||||
, _lineWidth(LineWidthInfo, 2.5f, 1.f, 10.f)
|
||||
, _baseOpacity(BaseOpacityInfo, 0.3f, 0.0f, 1.0f)
|
||||
, _signalSpeedFactor(SignalSpeedInfo, 2.0f, 1.0f, 10.0f)
|
||||
, _segmentSizeFactor(SegmentSizeInfo, 10.0f, 1.0f, 100.0f)
|
||||
, _spacingSizeFactor(SpacingSizeInfo, 0.0f, 0.0f, 10.0f)
|
||||
, _flowSpeedFactor(FlowSpeedInfo, 2.0f, 1.0f, 100.0f)
|
||||
, _segmentSizeFactor(SegmentSizeInfo, 0.6f, 0.0f, 1.0f)
|
||||
, _spacingSizeFactor(SpacingSizeInfo, 0.2f, 0.0f, 5.0f)
|
||||
, _fadeFactor(FadeFactorInfo, 0.5f, 0.1f, 0.5f)
|
||||
{
|
||||
documentation::testSpecificationAndThrow(
|
||||
@@ -229,7 +229,7 @@ RenderableSignals::RenderableSignals(const ghoul::Dictionary& dictionary)
|
||||
}
|
||||
addProperty(_baseOpacity);
|
||||
|
||||
addProperty(_signalSpeedFactor);
|
||||
addProperty(_flowSpeedFactor);
|
||||
addProperty(_segmentSizeFactor);
|
||||
addProperty(_spacingSizeFactor);
|
||||
addProperty(_fadeFactor);
|
||||
@@ -318,6 +318,13 @@ void RenderableSignals::updateVertexAttributes() {
|
||||
sizeof(FloatsVBOLayout),
|
||||
(void*)(sizeof(PositionVBOLayout) + sizeof(ColorVBOLayout) + 2 * sizeof(float)));
|
||||
glEnableVertexAttribArray(_vaLocTransmissionTime);
|
||||
// light travel time attribute
|
||||
glVertexAttribPointer(_vaLocLightTravelTime, _sizeOneVal, GL_FLOAT, GL_FALSE,
|
||||
sizeof(ColorVBOLayout) + sizeof(PositionVBOLayout) +
|
||||
sizeof(FloatsVBOLayout),
|
||||
(void*)(sizeof(PositionVBOLayout) + sizeof(ColorVBOLayout) + 3 * sizeof(float)));
|
||||
glEnableVertexAttribArray(_vaLocLightTravelTime);
|
||||
|
||||
};
|
||||
|
||||
void RenderableSignals::render(const RenderData& data, RendererTasks&) {
|
||||
@@ -335,7 +342,7 @@ void RenderableSignals::render(const RenderData& data, RendererTasks&) {
|
||||
_programObject->setUniform(_uniformCache.projection, data.camera.sgctInternal.projectionMatrix());
|
||||
|
||||
_programObject->setUniform(_uniformCache.baseOpacity, _baseOpacity);
|
||||
_programObject->setUniform(_uniformCache.signalSpeedFactor, _signalSpeedFactor);
|
||||
_programObject->setUniform(_uniformCache.flowSpeedFactor, _flowSpeedFactor);
|
||||
_programObject->setUniform(_uniformCache.segmentSizeFactor, _segmentSizeFactor);
|
||||
_programObject->setUniform(_uniformCache.spacingSizeFactor, _spacingSizeFactor);
|
||||
_programObject->setUniform(_uniformCache.fadeFactor, _fadeFactor);
|
||||
@@ -427,7 +434,7 @@ void RenderableSignals::update(const UpdateData& data) {
|
||||
|
||||
// Update the number of lines to render
|
||||
_lineRenderInformation.countLines = static_cast<GLsizei>(_vertexArray.size() /
|
||||
(_sizeThreeVal + _sizeFourVal + 3 *_sizeOneVal));
|
||||
(_sizeThreeVal + _sizeFourVal + _floatsVBOSize * _sizeOneVal));
|
||||
|
||||
//unbind vertexArray
|
||||
unbindGL();
|
||||
@@ -462,8 +469,11 @@ void RenderableSignals::pushSignalDataToVertexArray(SignalManager::Signal signal
|
||||
glm::dvec3 posSpacecraft = getSuitablePrecisionPositionForSceneGraphNode(signal.spacecraft.c_str());
|
||||
double distance = getDistance(signal.dishName, signal.spacecraft);
|
||||
double timeSinceStart = signal.timeSinceStart;
|
||||
double lightTravelTime = signal.lightTravelTime;
|
||||
|
||||
//fill the render array
|
||||
// fill the render array
|
||||
|
||||
// first with station position and its vertex attributes
|
||||
_vertexArray.push_back(posStation.x);
|
||||
_vertexArray.push_back(posStation.y);
|
||||
_vertexArray.push_back(posStation.z);
|
||||
@@ -481,7 +491,10 @@ void RenderableSignals::pushSignalDataToVertexArray(SignalManager::Signal signal
|
||||
}
|
||||
_vertexArray.push_back(timeSinceStart);
|
||||
_vertexArray.push_back(signal.endTransmission-signal.startTransmission);
|
||||
_vertexArray.push_back(lightTravelTime);
|
||||
|
||||
|
||||
// then with spacecraft position and its vertex attributes
|
||||
_vertexArray.push_back(posSpacecraft.x);
|
||||
_vertexArray.push_back(posSpacecraft.y);
|
||||
_vertexArray.push_back(posSpacecraft.z);
|
||||
@@ -499,6 +512,7 @@ void RenderableSignals::pushSignalDataToVertexArray(SignalManager::Signal signal
|
||||
}
|
||||
_vertexArray.push_back(timeSinceStart);
|
||||
_vertexArray.push_back(signal.endTransmission - signal.startTransmission);
|
||||
_vertexArray.push_back(lightTravelTime);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -95,19 +95,6 @@ namespace openspace {
|
||||
/* Returns a distance between two scenegraphnodes */
|
||||
double getDistance(std::string nodeIdA, std::string nodeIdB);
|
||||
|
||||
/* The VBO layout of the vertex position */
|
||||
struct PositionVBOLayout {
|
||||
float x, y, z;
|
||||
};
|
||||
/* The VBO layout of the color */
|
||||
struct ColorVBOLayout {
|
||||
float r, g, b, a;
|
||||
};
|
||||
/* The summated VBO layout of all the one value float attributes */
|
||||
struct FloatsVBOLayout {
|
||||
float distance, timeSinceStart, transmissionTime;
|
||||
};
|
||||
|
||||
/// Number of variables in _uniformCache
|
||||
static const GLuint uniformCacheSize = 8;
|
||||
|
||||
@@ -176,6 +163,9 @@ namespace openspace {
|
||||
/// The vertex attribute location for total transmission time
|
||||
/// must correlate to layout location in vertex shader
|
||||
const GLuint _vaLocTransmissionTime = 4;
|
||||
/// The vertex attribute location for signal light travle time
|
||||
/// must correlate to layout location in vertex shader
|
||||
const GLuint _vaLocLightTravelTime = 5;
|
||||
|
||||
/// Specifies the number of components per generic vertex attribute
|
||||
const GLuint _sizeFourVal = 4;
|
||||
@@ -186,12 +176,30 @@ namespace openspace {
|
||||
|
||||
private:
|
||||
|
||||
/* The VBO layout of the vertex position */
|
||||
struct PositionVBOLayout {
|
||||
float x, y, z;
|
||||
};
|
||||
/* The VBO layout of the color */
|
||||
struct ColorVBOLayout {
|
||||
float r, g, b, a;
|
||||
};
|
||||
/* The summated VBO layout of all the one value float attributes */
|
||||
struct FloatsVBOLayout {
|
||||
float distance, timeSinceStart, transmissionTime, lightTravelTime;
|
||||
};
|
||||
|
||||
/// Number of variables in FloatsVBOLayout
|
||||
static const int _floatsVBOSize = 4;
|
||||
/// Size buffer for signal vector
|
||||
int _signalSizeBuffer = 10;
|
||||
|
||||
/// Line width for the line rendering part
|
||||
properties::FloatProperty _lineWidth;
|
||||
/// Opacity for the base line
|
||||
properties::FloatProperty _baseOpacity;
|
||||
/// Speed factor for segments within the transmission time
|
||||
properties::FloatProperty _signalSpeedFactor;
|
||||
properties::FloatProperty _flowSpeedFactor;
|
||||
/// Size factor for segments within the transmission time
|
||||
properties::FloatProperty _segmentSizeFactor;
|
||||
/// Size factor for the spacing between segments within the transmission time
|
||||
@@ -203,14 +211,11 @@ namespace openspace {
|
||||
ghoul::opengl::ProgramObject* _programObject = nullptr;
|
||||
/// Cache for uniform variables, update _uniformCacheSize accordingly
|
||||
UniformCache(modelViewStation, modelViewSpacecraft, projection, baseOpacity,
|
||||
signalSpeedFactor, segmentSizeFactor, spacingSizeFactor, fadeFactor) _uniformCache;
|
||||
flowSpeedFactor, segmentSizeFactor, spacingSizeFactor, fadeFactor) _uniformCache;
|
||||
|
||||
/*Checks if the current time is within a signal's start and endtime*/
|
||||
bool isSignalActive(double currentTime, SignalManager::Signal signal);
|
||||
|
||||
/// Size buffer for signal vector
|
||||
int _signalSizeBuffer = 10;
|
||||
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -31,10 +31,15 @@ in vec4 vs_color;
|
||||
in float distanceFromStart;
|
||||
in float timeSinceStart;
|
||||
in float transmissionTime;
|
||||
in float lightTravelTime;
|
||||
|
||||
float lightSpeed = 299792458.0; // expressed in m/s
|
||||
// light speed expressed in m/s
|
||||
float lightSpeed = 299792458.0;
|
||||
|
||||
uniform float signalSpeedFactor;
|
||||
// the maximum number of segments to be drawn
|
||||
int maxNumSegments = 10000; //int(ceil(lightTravelTime* 10.0f));
|
||||
|
||||
uniform float flowSpeedFactor;
|
||||
uniform float segmentSizeFactor;
|
||||
uniform float spacingSizeFactor;
|
||||
uniform float fadeFactor;
|
||||
@@ -46,16 +51,13 @@ float getSegmentOpacity(const float segmentSize,
|
||||
|
||||
float fadeLength = segmentSize * fadeFactor;
|
||||
|
||||
// if fadeLength is zero, the smoothtep does not work, return straight away
|
||||
// if fadeLength is zero, the smoothstep does not work, return straight away
|
||||
if(fadeFactor < 0.001f)
|
||||
{
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
// the maximum number of segments to be drawn
|
||||
int MAXNUMSEGMENTS = 1000; // int(ceil(1000.0f/segmentSizeFactor));
|
||||
|
||||
for(int i = 0; i < MAXNUMSEGMENTS; i++ )
|
||||
for(int i = 0; i < maxNumSegments; i++ )
|
||||
{
|
||||
|
||||
float segmentStart = distSignTravelStart-i*(segmentSize+spacing);
|
||||
@@ -95,16 +97,15 @@ Fragment getFragment() {
|
||||
// the distance the last signal transmission has travelled
|
||||
float distLightTravelEnd = lightSpeed * (timeSinceStart-transmissionTime);
|
||||
float signalSize = distLightTravelStart-distLightTravelEnd;
|
||||
|
||||
float signalSegmentSize = 100.f * segmentSizeFactor * lightSpeed;
|
||||
float signalSegmentSize = pow(lightTravelTime,segmentSizeFactor) * lightSpeed;
|
||||
|
||||
float alpha = 0.0f;
|
||||
// if within the transmission time, change the opacity
|
||||
if(distanceFromStart < distLightTravelStart && distanceFromStart > distLightTravelEnd){
|
||||
// calculate how fast the signal segments travel within transmission
|
||||
float distSignTravelStart = distLightTravelStart * signalSpeedFactor;
|
||||
float spacing = 1000.f * lightSpeed * spacingSizeFactor;
|
||||
|
||||
float distSignTravelStart = distLightTravelStart * flowSpeedFactor;
|
||||
// make the spacing dependent on the segment size
|
||||
float spacing = signalSegmentSize * spacingSizeFactor;
|
||||
alpha = getSegmentOpacity(signalSegmentSize,spacing, distSignTravelStart);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ layout(location = 1) in vec4 in_color;
|
||||
layout(location = 2) in float in_dist_from_start;
|
||||
layout(location = 3) in float in_time_since_start;
|
||||
layout(location = 4) in float in_transmission_time;
|
||||
layout(location = 5) in float in_light_travel_time;
|
||||
|
||||
in int gl_VertexID;
|
||||
|
||||
@@ -39,6 +40,7 @@ out vec4 vs_color;
|
||||
out float distanceFromStart;
|
||||
out float timeSinceStart;
|
||||
out float transmissionTime;
|
||||
out float lightTravelTime;
|
||||
|
||||
uniform dmat4 modelViewStation;
|
||||
uniform dmat4 modelViewSpacecraft;
|
||||
@@ -61,6 +63,7 @@ void main() {
|
||||
gl_Position.z = 0.f;
|
||||
|
||||
// pass variables with no calculations directly to fragment
|
||||
lightTravelTime = in_light_travel_time;
|
||||
timeSinceStart = in_time_since_start;
|
||||
transmissionTime = in_transmission_time;
|
||||
distanceFromStart = in_dist_from_start;
|
||||
|
||||
Reference in New Issue
Block a user