mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-04 09:59:44 -05:00
Update renderable path to fade away with distance
This commit is contained in:
@@ -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