mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-06 11:29:55 -05:00
Update renderable path to fade away with distance
This commit is contained in:
@@ -235,32 +235,8 @@ return {
|
||||
},
|
||||
GuiName = "/Solar/OsirisRexPathSolar"
|
||||
},
|
||||
{
|
||||
Name = "OsirisRexPathLocal",
|
||||
Parent = "Bennu2",
|
||||
Renderable = {
|
||||
Type = "RenderablePath",
|
||||
Body = "OSIRIS-REX",
|
||||
Frame = "GALACTIC",
|
||||
Observer = BENNU_BODY,
|
||||
RGB = { 0.8, 0.0, 0.5},
|
||||
TimeSteps = 900,
|
||||
PointSteps = 4, -- Every fourth point is marked differently to show hours
|
||||
Textures = {
|
||||
Type = "simple",
|
||||
Color = "textures/glare_blue.png",
|
||||
-- need to add different texture
|
||||
},
|
||||
DrawLine = true,
|
||||
|
||||
StartTime = "2016 SEP 8 12:00:00",
|
||||
EndTime = "2023 SEP 24 12:00:00"
|
||||
},
|
||||
GuiName = "/Solar/OsirisRexPathLocal"
|
||||
},
|
||||
]]
|
||||
|
||||
-- Asteroid Dance trail
|
||||
]]
|
||||
-- Trail relative to Bennu
|
||||
{
|
||||
Name = "OsirisRexTrailLocal",
|
||||
Parent = "Bennu2",
|
||||
|
||||
@@ -59,7 +59,6 @@ namespace openspace {
|
||||
|
||||
RenderablePath::RenderablePath(const ghoul::Dictionary& dictionary)
|
||||
: Renderable(dictionary)
|
||||
, _lineFade("lineFade", "Line Fade", 0.75f, 0.f, 1.f)
|
||||
, _lineWidth("lineWidth", "Line Width", 2.f, 1.f, 20.f)
|
||||
, _drawLine("drawline", "Draw Line", false)
|
||||
, _programObject(nullptr)
|
||||
@@ -90,7 +89,6 @@ RenderablePath::RenderablePath(const ghoul::Dictionary& dictionary)
|
||||
dictionary.getValue(keyDrawLine, drawLine);
|
||||
_drawLine = drawLine;
|
||||
addProperty(_drawLine);
|
||||
addProperty(_lineFade);
|
||||
addProperty(_lineWidth);
|
||||
_distanceFade = 1.0;
|
||||
}
|
||||
@@ -164,8 +162,6 @@ void RenderablePath::render(const RenderData& data) {
|
||||
_programObject->setUniform("projectionTransform", data.camera.projectionMatrix());
|
||||
_programObject->setUniform("pointSteps", _pointSteps);
|
||||
_programObject->setUniform("color", _lineColor);
|
||||
_programObject->setUniform("lineFade", _lineFade);
|
||||
_programObject->setUniform("numVertices", nPointsToDraw);
|
||||
|
||||
if (_drawLine) {
|
||||
glLineWidth(_lineWidth);
|
||||
|
||||
@@ -64,7 +64,6 @@ private:
|
||||
|
||||
glm::vec3 _lineColor;
|
||||
glm::vec4 _lastPosition;
|
||||
properties::FloatProperty _lineFade;
|
||||
properties::FloatProperty _lineWidth;
|
||||
properties::BoolProperty _drawLine;
|
||||
|
||||
|
||||
@@ -30,6 +30,8 @@ in vec4 vs_pointColor;
|
||||
|
||||
Fragment getFragment() {
|
||||
|
||||
if (vs_pointColor.a < 0.01)
|
||||
discard;
|
||||
Fragment frag;
|
||||
frag.color = vs_pointColor;
|
||||
frag.depth = vs_positionScreenSpace.w;
|
||||
|
||||
@@ -30,8 +30,6 @@ uniform vec3 color;
|
||||
uniform mat4 modelViewTransform;
|
||||
uniform mat4 projectionTransform;
|
||||
uniform int pointSteps;
|
||||
uniform float lineFade;
|
||||
uniform int numVertices;
|
||||
|
||||
out vec4 vs_positionScreenSpace;
|
||||
out vec4 vs_pointColor;
|
||||
@@ -39,24 +37,26 @@ out vec4 vs_pointColor;
|
||||
#include "PowerScaling/powerScaling_vs.hglsl"
|
||||
|
||||
void main() {
|
||||
vec4 positionClipSpace = projectionTransform * modelViewTransform * in_point_position;
|
||||
vec4 positionCameraSpace = modelViewTransform * in_point_position;
|
||||
vec4 positionClipSpace = projectionTransform * positionCameraSpace;
|
||||
vs_positionScreenSpace = z_normalization(positionClipSpace);
|
||||
|
||||
gl_Position = vs_positionScreenSpace;
|
||||
|
||||
if(mod(gl_VertexID, pointSteps) == 0) {
|
||||
vs_pointColor.rgb = color;
|
||||
gl_PointSize = 10.0f;
|
||||
gl_PointSize = 5.0f;
|
||||
}
|
||||
else {
|
||||
vs_pointColor.rgb = (color + vec3(0.6f, 0.6f, 0.6f)) / 2;
|
||||
gl_PointSize = 5.f;
|
||||
}
|
||||
if (lineFade == 0)
|
||||
vs_pointColor.a = 1.0;
|
||||
else
|
||||
{
|
||||
int threshHold = int(lineFade * numVertices);
|
||||
vs_pointColor.a = float(gl_VertexID - threshHold) / (numVertices - threshHold);
|
||||
gl_PointSize = 2.f;
|
||||
}
|
||||
|
||||
// I don't like this random variable k defined in powerScalingMath.hglsl.
|
||||
// Will ignore it and use 10 in protest of psc dependencies. /KB
|
||||
// float maximumDistance = pow(k, 10);
|
||||
float maximumDistance = pow(10, 10);
|
||||
float distanceToCamera = length(positionCameraSpace.xyz);
|
||||
|
||||
vs_pointColor.a = maximumDistance / (distanceToCamera/100);
|
||||
}
|
||||
Reference in New Issue
Block a user