Fix for a lot of trail related stuff (#3193)

Fixes following issues: #625 , #1067 , #1212 , #1472 , #2072 , #2235, #2964
- Trails in `renderableTrailTrajectory` now goes through the spacecraft when using `AccurateTrailPositions`.
- Trail fading controls have been improved for classes using the `renderableTrail` class.
-  `renderableOrbitalKepler` (asteroids/satellites) can now be rendered as both trails and points (or both at once). Solution implements similar functionality/controls as `renderablePointCloud`.
- Default setting for SweepChunking has been changed from `true` to `false` (iterative calculations of `renderableTrailTrajectory`).
- Some fixes related to missing points or off-by-one errors related to trail rendering
This commit is contained in:
Adam Rohdin
2024-04-19 16:51:17 +02:00
committed by GitHub
parent f4bdb294f8
commit 392a521423
81 changed files with 1238 additions and 288 deletions

View File

@@ -21,7 +21,8 @@ local AmateurSatellites = {
Format = "OMM",
SegmentQuality = 3,
Color = { 0.75, 0.75, 0.35 },
Fade = 1.5,
TrailFade = 15.0,
PointSizeExponent = 5.0,
RenderBinMode = "PostDeferredTransparent"
},
Tag = { "earth_satellites" },

View File

@@ -21,7 +21,8 @@ local ExperimentalSatellites = {
Format = "OMM",
SegmentQuality = 3,
Color = { 0.75, 0.75, 0.35 },
Fade = 1.5,
TrailFade = 15,
PointSizeExponent = 5.0,
RenderBinMode = "PostDeferredTransparent"
},
Tag = { "earth_satellites" },

View File

@@ -21,7 +21,8 @@ local GeoStationarySatellites = {
Format = "OMM",
SegmentQuality = 3,
Color = { 0.9, 0.9, 0.0 },
Fade = 1.5,
TrailFade = 5,
PointSizeExponent = 5.2,
RenderBinMode = "PostDeferredTransparent"
},
Tag = { "earth_satellites" },

View File

@@ -21,7 +21,8 @@ local GlobalStarSatellites = {
Format = "OMM",
SegmentQuality = 3,
Color = { 0.75, 0.75, 0.35 },
Fade = 1.5,
TrailFade = 15,
PointSizeExponent = 5.0,
RenderBinMode = "PostDeferredTransparent"
},
Tag = { "earth_satellites" },

View File

@@ -21,7 +21,8 @@ local GorizontSatellites = {
Format = "OMM",
SegmentQuality = 3,
Color = { 0.75, 0.75, 0.35 },
Fade = 1.5,
TrailFade = 5,
PointSizeExponent = 5.0,
RenderBinMode = "PostDeferredTransparent"
},
Tag = { "earth_satellites" },

View File

@@ -21,7 +21,8 @@ local IntelsatSatellites = {
Format = "OMM",
SegmentQuality = 3,
Color = { 0.75, 0.75, 0.35 },
Fade = 1.5,
TrailFade = 5,
PointSizeExponent = 5.0,
RenderBinMode = "PostDeferredTransparent"
},
Tag = { "earth_satellites" },

View File

@@ -21,7 +21,8 @@ local IridiumSatellites = {
Format = "OMM",
SegmentQuality = 3,
Color = { 0.75, 0.75, 0.35 },
Fade = 1.5,
TrailFade = 15,
PointSizeExponent = 5.0,
RenderBinMode = "PostDeferredTransparent"
},
Tag = { "earth_satellites" },

View File

@@ -21,7 +21,8 @@ local IridiumNextSatellites = {
Format = "OMM",
SegmentQuality = 3,
Color = { 0.75, 0.75, 0.35 },
Fade = 1.5,
TrailFade = 15,
PointSizeExponent = 5.0,
RenderBinMode = "PostDeferredTransparent"
},
Tag = { "earth_satellites" },

View File

@@ -21,7 +21,8 @@ local MolniyaSatellites = {
Format = "OMM",
SegmentQuality = 3,
Color = { 0.75, 0.75, 0.35 },
Fade = 1.5,
TrailFade = 15,
PointSizeExponent = 5.0,
RenderBinMode = "PostDeferredTransparent"
},
Tag = { "earth_satellites" },

View File

@@ -21,7 +21,8 @@ local OrbcommSatellites = {
Format = "OMM",
SegmentQuality = 3,
Color = { 0.75, 0.75, 0.35 },
Fade = 1.5,
TrailFade = 15,
PointSizeExponent = 5.0,
RenderBinMode = "PostDeferredTransparent"
},
Tag = { "earth_satellites" },

View File

@@ -21,7 +21,8 @@ local OtherCommunicationSatellites = {
Format = "OMM",
SegmentQuality = 3,
Color = { 0.75, 0.75, 0.35 },
Fade = 1.5,
TrailFade = 15,
PointSizeExponent = 5.0,
RenderBinMode = "PostDeferredTransparent"
},
Tag = { "earth_satellites" },

View File

@@ -21,7 +21,8 @@ local RadugaSatellites = {
Format = "OMM",
SegmentQuality = 3,
Color = { 0.75, 0.75, 0.35 },
Fade = 1.5,
TrailFade = 5,
PointSizeExponent = 5.0,
RenderBinMode = "PostDeferredTransparent"
},
Tag = { "earth_satellites" },

View File

@@ -21,7 +21,8 @@ local SesSatellites = {
Format = "OMM",
SegmentQuality = 3,
Color = { 0.75, 0.75, 0.35 },
Fade = 1.5,
TrailFade = 10,
PointSizeExponent = 5.0,
RenderBinMode = "PostDeferredTransparent"
},
Tag = { "earth_satellites" },

View File

@@ -21,7 +21,8 @@ local StarlinkSatellites = {
Format = "OMM",
SegmentQuality = 3,
Color = { 0.65, 0.55, 0.55 },
Fade = 1.5,
TrailFade = 5,
PointSizeExponent = 5.0,
RenderBinMode = "PostDeferredTransparent"
},
Tag = { "earth_satellites" },

View File

@@ -21,7 +21,8 @@ local DebrisAsat = {
Format = "OMM",
SegmentQuality = 3,
Color = { 0.25, 0.35, 0.45 },
Fade = 1.5,
TrailFade = 15,
PointSizeExponent = 5.0,
RenderBinMode = "PostDeferredTransparent"
},
Tag = { "earth_satellites" },

View File

@@ -21,7 +21,8 @@ local DebrisBreezem = {
Format = "OMM",
SegmentQuality = 3,
Color = { 0.25, 0.35, 0.45 },
Fade = 1.5,
TrailFade = 15,
PointSizeExponent = 5.0,
RenderBinMode = "PostDeferredTransparent"
},
Tag = { "earth_satellites" },

View File

@@ -21,7 +21,8 @@ local DebrisFengyun = {
Format = "OMM",
SegmentQuality = 3,
Color = { 0.784, 1.0, 0.737 },
Fade = 1.5,
TrailFade = 1.5,
PointSizeExponent = 5.0,
RenderBinMode = "PostDeferredTransparent"
},
Tag = { "earth_satellites" },

View File

@@ -21,7 +21,8 @@ local DebrisIridium = {
Format = "OMM",
SegmentQuality = 3,
Color = { 0.8, 0.0, 0.3 },
Fade = 1.5,
TrailFade = 5,
PointSizeExponent = 5.0,
RenderBinMode = "PostDeferredTransparent"
},
Tag = { "earth_satellites" },

View File

@@ -21,7 +21,7 @@ local DebrisCosmos = {
Format = "OMM",
SegmentQuality = 3,
Color = { 0.66, 0.8, 0.5 },
Fade = 1.5,
TrailFade = 1.5,
RenderBinMode = "PostDeferredTransparent"
},
Tag = { "earth_satellites" },

View File

@@ -21,7 +21,8 @@ local ActiveSatellites = {
Format = "OMM",
SegmentQuality = 3,
Color = { 0.45, 0.25, 0.45 },
Fade = 1.5,
TrailFade = 5,
PointSizeExponent = 5.0,
RenderBinMode = "PostDeferredTransparent"
},
Tag = { "earth_satellites" },

View File

@@ -21,7 +21,8 @@ local BrightestSatellites = {
Format = "OMM",
SegmentQuality = 3,
Color = { 0.55, 0.25, 0.65 },
Fade = 1.5,
TrailFade = 15,
PointSizeExponent = 5.0,
RenderBinMode = "PostDeferredTransparent"
},
Tag = { "earth_satellites" },

View File

@@ -21,7 +21,8 @@ local Cubesats = {
Format = "OMM",
SegmentQuality = 3,
Color = { 0.75, 0.75, 0.35 },
Fade = 1.5,
TrailFade = 15,
PointSizeExponent = 5.0,
RenderBinMode = "PostDeferredTransparent"
},
Tag = { "earth_satellites" },

View File

@@ -21,7 +21,8 @@ local MilitarySatellites = {
Format = "OMM",
SegmentQuality = 3,
Color = { 0.75, 0.75, 0.35 },
Fade = 1.5,
TrailFade = 20,
PointSizeExponent = 5.0,
RenderBinMode = "PostDeferredTransparent"
},
Tag = { "earth_satellites" },

View File

@@ -21,7 +21,8 @@ local OtherSatellites = {
Format = "OMM",
SegmentQuality = 3,
Color = { 0.75, 0.75, 0.35 },
Fade = 1.5,
TrailFade = 15,
PointSizeExponent = 5.0,
RenderBinMode = "PostDeferredTransparent"
},
Tag = { "earth_satellites" },

View File

@@ -21,7 +21,8 @@ local RadarSatellites = {
Format = "OMM",
SegmentQuality = 3,
Color = { 0.75, 0.75, 0.35 },
Fade = 1.5,
TrailFade = 15,
PointSizeExponent = 5.0,
RenderBinMode = "PostDeferredTransparent"
},
Tag = { "earth_satellites" },

View File

@@ -21,7 +21,8 @@ local SpaceStations = {
Format = "OMM",
SegmentQuality = 3,
Color = { 0.9, 0.1, 0.0 },
Fade = 1.5,
TrailFade = 20,
PointSizeExponent = 5.0,
RenderBinMode = "PostDeferredTransparent"
},
Tag = { "earth_satellites" },

View File

@@ -21,7 +21,8 @@ local Last30DaysSatellites = {
Format = "OMM",
SegmentQuality = 3,
Color = { 0.65, 0.25, 0.45 },
Fade = 1.5,
TrailFade = 15,
PointSizeExponent = 5.0,
RenderBinMode = "PostDeferredTransparent"
},
Tag = { "earth_satellites" },

View File

@@ -21,7 +21,8 @@ local BeidouSatellites = {
Format = "OMM",
SegmentQuality = 3,
Color = { 0.75, 0.75, 0.35 },
Fade = 1.5,
TrailFade = 15,
PointSizeExponent = 5.0,
RenderBinMode = "PostDeferredTransparent"
},
Tag = { "earth_satellites" },

View File

@@ -21,7 +21,8 @@ local GalileoSatellites = {
Format = "OMM",
SegmentQuality = 3,
Color = { 0.75, 0.75, 0.35 },
Fade = 1.5,
TrailFade = 15,
PointSizeExponent = 5.0,
RenderBinMode = "PostDeferredTransparent"
},
Tag = { "earth_satellites" },

View File

@@ -21,7 +21,8 @@ local GlosnassSatellites = {
Format = "OMM",
SegmentQuality = 3,
Color = { 0.75, 0.75, 0.35 },
Fade = 1.5,
TrailFade = 15,
PointSizeExponent = 5.0,
RenderBinMode = "PostDeferredTransparent"
},
Tag = { "earth_satellites" },

View File

@@ -21,7 +21,8 @@ local GpsSatellites = {
Format = "OMM",
SegmentQuality = 3,
Color = { 0.9, 0.5, 0.0 },
Fade = 1.5,
TrailFade = 15,
PointSizeExponent = 5.5,
RenderBinMode = "PostDeferredTransparent"
},
Tag = { "earth_satellites" },

View File

@@ -21,7 +21,8 @@ local MussonSatellites = {
Format = "OMM",
SegmentQuality = 3,
Color = { 0.75, 0.75, 0.35 },
Fade = 1.5,
TrailFade = 15,
PointSizeExponent = 5.0,
RenderBinMode = "PostDeferredTransparent"
},
Tag = { "earth_satellites" },

View File

@@ -21,7 +21,8 @@ local NavyNavigationSatellites = {
Format = "OMM",
SegmentQuality = 3,
Color = { 0.75, 0.75, 0.35 },
Fade = 1.5,
TrailFade = 17,
PointSizeExponent = 5.0,
RenderBinMode = "PostDeferredTransparent"
},
Tag = { "earth_satellites" },

View File

@@ -21,7 +21,8 @@ local SatelliteBasedAugmentationSatellites = {
Format = "OMM",
SegmentQuality = 3,
Color = { 0.75, 0.75, 0.35 },
Fade = 1.5,
TrailFade = 15,
PointSizeExponent = 5.0,
RenderBinMode = "PostDeferredTransparent"
},
Tag = { "earth_satellites" },

View File

@@ -21,7 +21,8 @@ local EducationSatellites = {
Format = "OMM",
SegmentQuality = 3,
Color = { 0.75, 0.75, 0.35 },
Fade = 1.5,
TrailFade = 20,
PointSizeExponent = 5.0,
RenderBinMode = "PostDeferredTransparent"
},
Tag = { "earth_satellites" },

View File

@@ -21,7 +21,8 @@ local EngineeringSatellites = {
Format = "OMM",
SegmentQuality = 3,
Color = { 0.75, 0.75, 0.35 },
Fade = 1.5,
TrailFade = 17,
PointSizeExponent = 5.0,
RenderBinMode = "PostDeferredTransparent"
},
Tag = { "earth_satellites" },

View File

@@ -21,7 +21,8 @@ local GeodeticSatellites = {
Format = "OMM",
SegmentQuality = 3,
Color = { 0.75, 0.75, 0.35 },
Fade = 1.5,
TrailFade = 20,
PointSizeExponent = 5.0,
RenderBinMode = "PostDeferredTransparent"
},
Tag = { "earth_satellites" },

View File

@@ -21,7 +21,8 @@ local ScienceSatellites = {
Format = "OMM",
SegmentQuality = 3,
Color = { 0.75, 0.75, 0.35 },
Fade = 1.5,
TrailFade = 17,
PointSizeExponent = 5.0,
RenderBinMode = "PostDeferredTransparent"
},
Tag = { "earth_satellites" },

View File

@@ -21,7 +21,8 @@ local Argos = {
Format = "OMM",
SegmentQuality = 3,
Color = { 0.75, 0.75, 0.35 },
Fade = 1.5,
TrailFade = 17,
PointSizeExponent = 5.0,
RenderBinMode = "PostDeferredTransparent"
},
Tag = { "earth_satellites" },

View File

@@ -21,7 +21,8 @@ local DisasterMonitoringConstellation = {
Format = "OMM",
SegmentQuality = 3,
Color = { 0.75, 0.75, 0.35 },
Fade = 1.5,
TrailFade = 17,
PointSizeExponent = 5.0,
RenderBinMode = "PostDeferredTransparent"
},
Tag = { "earth_satellites" },

View File

@@ -21,7 +21,8 @@ local ResourceSatellites = {
Format = "OMM",
SegmentQuality = 3,
Color = { 0.75, 0.75, 0.35 },
Fade = 1.5,
TrailFade = 15,
PointSizeExponent = 5.0,
RenderBinMode = "PostDeferredTransparent"
},
Tag = { "earth_satellites" },

View File

@@ -21,7 +21,8 @@ local GoesSatellites = {
Format = "OMM",
SegmentQuality = 3,
Color = { 0.75, 0.75, 0.35 },
Fade = 1.5,
TrailFade = 15,
PointSizeExponent = 5.0,
RenderBinMode = "PostDeferredTransparent"
},
Tag = { "earth_satellites" },

View File

@@ -21,7 +21,8 @@ local NoaaSatellites = {
Format = "OMM",
SegmentQuality = 3,
Color = { 0.75, 0.75, 0.35 },
Fade = 1.5,
TrailFade = 17,
PointSizeExponent = 5.0,
RenderBinMode = "PostDeferredTransparent"
},
Tag = { "earth_satellites" },

View File

@@ -21,7 +21,8 @@ local PlanetSatellites = {
Format = "OMM",
SegmentQuality = 3,
Color = { 0.75, 0.75, 0.35 },
Fade = 1.5,
TrailFade = 15,
PointSizeExponent = 5.0,
RenderBinMode = "PostDeferredTransparent"
},
Tag = { "earth_satellites" },

View File

@@ -21,7 +21,8 @@ local SarSatellites = {
Format = "OMM",
SegmentQuality = 3,
Color = { 0.75, 0.75, 0.35 },
Fade = 1.5,
TrailFade = 10,
PointSizeExponent = 5.0,
RenderBinMode = "PostDeferredTransparent"
},
Tag = { "earth_satellites" },

View File

@@ -21,7 +21,8 @@ local SpireSatellites = {
Format = "OMM",
SegmentQuality = 3,
Color = { 0.75, 0.75, 0.35 },
Fade = 1.5,
TrailFade = 15,
PointSizeExponent = 5.0,
RenderBinMode = "PostDeferredTransparent"
},
Tag = { "earth_satellites" },

View File

@@ -21,7 +21,8 @@ local TrackingDataRelaySatellites = {
Format = "OMM",
SegmentQuality = 3,
Color = { 0.75, 0.75, 0.35 },
Fade = 1.5,
TrailFade = 17,
PointSizeExponent = 5.0,
RenderBinMode = "PostDeferredTransparent"
},
Tag = { "earth_satellites" },

View File

@@ -21,7 +21,8 @@ local WeatherSatellites = {
Format = "OMM",
SegmentQuality = 3,
Color = { 0.75, 0.75, 0.35 },
Fade = 1.5,
TrailFade = 15,
PointSizeExponent = 5.0,
RenderBinMode = "PostDeferredTransparent"
},
Tag = { "earth_satellites" },

View File

@@ -20,7 +20,8 @@ local Object = {
Segments = 200,
SegmentQuality = 4,
Color = { 1.0, 1.0, 1.0 },
TrailFade = 11
TrailFade = 11,
PointSizeExponent = 9.2
},
GUI = {
Name = "Amor Asteroids",

View File

@@ -20,7 +20,8 @@ local Object = {
Segments = 200,
SegmentQuality = 6,
Color = { 0.7, 0.7, 1.0 },
TrailFade = 10
TrailFade = 10,
PointSizeExponent = 9.2
},
GUI = {
Name = "Apollo Asteroids",

View File

@@ -20,7 +20,8 @@ local Object = {
Segments = 200,
SegmentQuality = 2,
Color = { 0.15, 0.15, 1.0 },
TrailFade = 18
TrailFade = 18,
PointSizeExponent = 9.2
},
GUI = {
Name = "Aten Asteroids",

View File

@@ -20,7 +20,8 @@ local Object = {
Segments = 200,
SegmentQuality = 2,
Color = { 0.5, 0.8, 1.0 },
TrailFade = 25
TrailFade = 25,
PointSizeExponent = 9.2
},
GUI = {
Name = "Atira Asteroids",

View File

@@ -20,7 +20,8 @@ local Object = {
Segments = 200,
SegmentQuality = 6,
Color = { 0.94, 0.96, 0.94 },
TrailFade = 18
TrailFade = 18,
PointSizeExponent = 10.2
},
GUI = {
Name = "Centaur Asteroids",

View File

@@ -20,7 +20,8 @@ local Object = {
Segments = 200,
SegmentQuality = 10,
Color = { 0.15, 0.1, 1.0 },
TrailFade = 25
TrailFade = 25,
PointSizeExponent = 10.5
},
GUI = {
Name = "Chiron-type Comets",

View File

@@ -20,7 +20,8 @@ local Object = {
Segments = 200,
SegmentQuality = 2,
Color = { 0.8, 0.34, 1.0 },
TrailFade = 23
TrailFade = 23,
PointSizeExponent = 10.0
},
GUI = {
Name = "Encke-type Comets",

View File

@@ -20,7 +20,8 @@ local Object = {
Segments = 200,
SegmentQuality = 9,
Color = { 0.66, 0.66, 0.66 },
TrailFade = 18
TrailFade = 18,
PointSizeExponent = 10.6
},
GUI = {
Name = "Halley-type Comets",

View File

@@ -20,7 +20,8 @@ local Object = {
Segments = 200,
SegmentQuality = 1,
Color = { 1.0, 1.0, 0.0 },
TrailFade = 0.5
TrailFade = 0.5,
PointSizeExponent = 9.2
},
GUI = {
Name = "Inner Main Asteroid Belt",

View File

@@ -20,7 +20,8 @@ local Object = {
Segments = 200,
SegmentQuality = 10,
Color = { 0.2, 0.8, 0.2 },
TrailFade = 28
TrailFade = 28,
PointSizeExponent = 10.5
},
GUI = {
Name = "Jupiter-family Comets",

View File

@@ -20,7 +20,8 @@ local Object = {
Segments = 200,
SegmentQuality = 1,
Color = { 0.5, 0.8, 0.5 },
TrailFade = 5
TrailFade = 5,
PointSizeExponent = 9.2
},
GUI = {
Name = "Jupiter Trojan Asteroids",

View File

@@ -21,6 +21,7 @@ local Object = {
SegmentQuality = 1,
Color = { 0.0, 0.5, 0.0 },
TrailFade = 0.1,
PointSizeExponent = 9.2,
RenderSize = 50000
},
GUI = {

View File

@@ -20,7 +20,8 @@ local Object = {
Segments = 200,
SegmentQuality = 1,
Color = { 0.814, 0.305, 0.22 },
TrailFade = 13
TrailFade = 13,
PointSizeExponent = 9.2
},
GUI = {
Name = "Mars-crossing Asteroids",

View File

@@ -20,7 +20,8 @@ local Object = {
Segments = 200,
SegmentQuality = 1,
Color = { 0.4, 0.4, 1.0 },
TrailFade = 2
TrailFade = 2,
PointSizeExponent = 9.2
},
GUI = {
Name = "Outer Main Asteroid Belt",

View File

@@ -20,7 +20,8 @@ local Object = {
Segments = 200,
SegmentQuality = 3,
Color = { 0.98, 0.09, 0.06 },
TrailFade = 17
TrailFade = 17,
PointSizeExponent = 9.2
},
GUI = {
Name = "Potentially Hazardous Asteroids",

View File

@@ -20,7 +20,8 @@ local Object = {
Segments = 200,
SegmentQuality = 8,
Color = { 0.56, 0.64, 0.95 },
TrailFade = 10
TrailFade = 10,
PointSizeExponent = 10.3
},
GUI = {
Name = "Transneptunian Object Asteroids",

View File

@@ -40,16 +40,18 @@
namespace {
#ifdef __APPLE__
constexpr std::array<const char*, 12> UniformNames = {
constexpr std::array<const char*, 16> UniformNames = {
"opacity", "modelViewTransform", "projectionTransform", "color", "useLineFade",
"lineFade", "vertexSortingMethod", "idOffset", "nVertices", "stride", "pointSize",
"renderPhase"
"lineLength", "lineFadeAmount", "vertexSortingMethod", "idOffset", "nVertices",
"stride", "pointSize", "renderPhase", "useSplitRenderMode", "floatingOffset",
"numberOfUniqueVertices"
};
#else
constexpr std::array<const char*, 14> UniformNames = {
constexpr std::array<const char*, 18> UniformNames = {
"opacity", "modelViewTransform", "projectionTransform", "color", "useLineFade",
"lineFade", "vertexSortingMethod", "idOffset", "nVertices", "stride", "pointSize",
"renderPhase", "viewport", "lineWidth"
"lineLength", "lineFadeAmount", "vertexSortingMethod", "idOffset", "nVertices",
"stride", "pointSize", "renderPhase", "viewport", "lineWidth", "floatingOffset",
"useSplitRenderMode", "numberOfUniqueVertices"
};
#endif
@@ -86,12 +88,28 @@ namespace {
openspace::properties::Property::Visibility::NoviceUser
};
constexpr openspace::properties::Property::PropertyInfo LineFadeInfo = {
"LineFade",
"Line fade",
"The fading factor that is applied to the trail if the 'EnableFade' value is "
"'true'. If it is 'false', this setting has no effect. The higher the number, "
"the less fading is applied",
constexpr openspace::properties::Property::PropertyInfo LineLengthInfo = {
"LineLength",
"Line Length",
"The extent of the rendered trail. A value of 0 will result in no trail and a "
"value of 1 will result in a trail that covers the entire extent. The setting "
"only applies if 'EnableFade' is 'true'. If it is 'false', this setting has "
"no effect.",
// @VISIBILITY(2.5)
openspace::properties::Property::Visibility::User
};
constexpr openspace::properties::Property::PropertyInfo LineFadeAmountInfo = {
"LineFadeAmount",
"Line Fade Amount",
"The amount of the trail that should be faded. If the value is 0 then the "
"trail will have no fading applied. A value of 0.6 will result in a trail "
"where 60% of the extent of the trail will have fading applied to it. In other"
"words, the 40% closest to the head of the trail will be solid and the rest "
"will fade until completely transparent at the end of the trail. A value of 1 "
"will result in a trail that starts fading immediately, becoming fully "
"transparent by the end of the trail. This setting only applies if the "
"'EnableFade' value is 'true'. If it is 'false', this setting has no effect.",
// @VISIBILITY(2.5)
openspace::properties::Property::Visibility::User
};
@@ -120,15 +138,15 @@ namespace {
constexpr openspace::properties::Property::PropertyInfo RenderingModeInfo = {
"Rendering",
"Rendering Mode",
"Determines how the trail should be rendered to the screen. If 'Lines' is "
"Determines how the trail should be rendered. If 'Lines' is "
"selected, only the line part is visible, if 'Points' is selected, only the "
"corresponding points (and subpoints) are shown. 'Lines+Points' shows both parts",
openspace::properties::Property::Visibility::AdvancedUser
};
struct [[codegen::Dictionary(RenderableTrail)]] Parameters {
// This object is used to compute locations along the path. Any Translation object
// can be used here
// This object is used to compute locations along the path. Any Translation
// object can be used here
ghoul::Dictionary translation
[[codegen::reference("core_transform_translation")]];
@@ -138,8 +156,11 @@ namespace {
// [[codegen::verbatim(EnableFadeInfo.description)]]
std::optional<bool> enableFade;
// [[codegen::verbatim(LineFadeInfo.description)]]
std::optional<float> lineFade;
// [[codegen::verbatim(LineLengthInfo.description)]]
std::optional<float> lineLength;
// [[codegen::verbatim(LineFadeAmountInfo.description)]]
std::optional<float> lineFadeAmount;
// [[codegen::verbatim(LineWidthInfo.description)]]
std::optional<float> lineWidth;
@@ -173,7 +194,8 @@ RenderableTrail::Appearance::Appearance()
})
, lineColor(LineColorInfo, glm::vec3(1.f), glm::vec3(0.f), glm::vec3(1.f))
, useLineFade(EnableFadeInfo, true)
, lineFade(LineFadeInfo, 1.f, 0.f, 30.f)
, lineLength(LineLengthInfo, 1.f, 0.f, 1.f)
, lineFadeAmount(LineFadeAmountInfo, 1.f, 0.f, 1.f)
, lineWidth(LineWidthInfo, 10.f, 1.f, 20.f)
, pointSize(PointSizeInfo, 1, 1, 64)
, renderingModes(
@@ -189,11 +211,12 @@ RenderableTrail::Appearance::Appearance()
lineColor.setViewOption(properties::Property::ViewOptions::Color);
addProperty(lineColor);
addProperty(useLineFade);
addProperty(lineFade);
addProperty(lineWidth);
addProperty(pointSize);
addProperty(renderingModes);
addProperty(useLineFade);
addProperty(lineLength);
addProperty(lineFadeAmount);
}
RenderableTrail::RenderableTrail(const ghoul::Dictionary& dictionary)
@@ -211,7 +234,7 @@ RenderableTrail::RenderableTrail(const ghoul::Dictionary& dictionary)
_appearance.lineColor = p.color;
_appearance.useLineFade = p.enableFade.value_or(_appearance.useLineFade);
_appearance.lineFade = p.lineFade.value_or(_appearance.lineFade);
_appearance.lineLength = p.lineLength.value_or(_appearance.lineLength);
_appearance.lineWidth = p.lineWidth.value_or(_appearance.lineWidth);
_appearance.pointSize = p.pointSize.value_or(_appearance.pointSize);
@@ -284,7 +307,9 @@ bool RenderableTrail::isReady() const {
void RenderableTrail::internalRender(bool renderLines, bool renderPoints,
const RenderData& data,
const glm::dmat4& modelTransform,
RenderInformation& info, int nVertices, int offset)
RenderInformation& info, int nVertices,
int ringOffset, bool useSplitRenderMode,
int numberOfUniqueVertices, int floatingOffset)
{
ZoneScoped;
@@ -312,9 +337,13 @@ void RenderableTrail::internalRender(bool renderLines, bool renderPoints,
// This value is subtracted from the vertex id in the case of a potential ring
// buffer (as used in RenderableTrailOrbit) to keep the first vertex at its
// brightest
_programObject->setUniform(_uniformCache.idOffset, offset);
_programObject->setUniform(_uniformCache.idOffset, ringOffset);
_programObject->setUniform(_uniformCache.nVertices, nVertices);
_programObject->setUniform(_uniformCache.floatingOffset, floatingOffset);
_programObject->setUniform(_uniformCache.useSplitRenderMode, useSplitRenderMode);
_programObject->setUniform(_uniformCache.numberOfUniqueVertices,
numberOfUniqueVertices);
#if !defined(__APPLE__)
std::array<GLint, 4> viewport;
@@ -399,7 +428,12 @@ void RenderableTrail::render(const RenderData& data, RendererTasks&) {
_programObject->setUniform(_uniformCache.color, _appearance.lineColor);
_programObject->setUniform(_uniformCache.useLineFade, _appearance.useLineFade);
if (_appearance.useLineFade) {
_programObject->setUniform(_uniformCache.lineFade, _appearance.lineFade);
const float startPoint = 1.f - _appearance.lineLength;
const float remainingRange = 1.f - startPoint;
const float delta = remainingRange * _appearance.lineFadeAmount;
const float endPoint = std::min(startPoint + delta, 1.f);
_programObject->setUniform(_uniformCache.lineLength, startPoint);
_programObject->setUniform(_uniformCache.lineFadeAmount, endPoint);
}
/*glm::ivec2 resolution = global::renderEngine.renderingResolution();
@@ -448,31 +482,82 @@ void RenderableTrail::render(const RenderData& data, RendererTasks&) {
// global::renderEngine->openglStateCache().resetDepthState();
// return;
//}
if (_useSplitRenderMode) {
// Splits the trail up into three parts for more accurate rendering
// of renderableTrailTrajectory trails
// Render the primary batch of vertices
internalRender(
renderLines,
renderPoints,
data,
modelTransform,
_primaryRenderInformation,
totalNumber,
primaryOffset
);
// The secondary batch is optional, so we need to check whether we have any data here
if (_floatingRenderInformation._vaoID != 0 && _floatingRenderInformation.count != 0) {
internalRender(
renderLines,
renderPoints,
data,
modelTransform,
_primaryRenderInformation,
_primaryRenderInformation.count,
_primaryRenderInformation.first,
_useSplitRenderMode,
_numberOfUniqueVertices
);
const int floatingOffset = std::max(0, _primaryRenderInformation.count - 1);
internalRender(
renderLines,
renderPoints,
data,
modelTransform,
_floatingRenderInformation,
totalNumber,
// -1 because we duplicate the penultimate point between the vertices
-(primaryOffset + _primaryRenderInformation.count - 1)
_floatingRenderInformation.count,
_floatingRenderInformation.first,
_useSplitRenderMode,
_numberOfUniqueVertices,
floatingOffset
);
const int offset = (_floatingRenderInformation.count > 0) ? 1 : 0;
internalRender(
renderLines,
renderPoints,
data,
modelTransform,
_secondaryRenderInformation,
_secondaryRenderInformation.count,
_secondaryRenderInformation.first,
_useSplitRenderMode,
_numberOfUniqueVertices,
offset
);
}
else {
// Render the primary batch of vertices
internalRender(
renderLines,
renderPoints,
data,
modelTransform,
_primaryRenderInformation,
totalNumber,
primaryOffset
);
// The secondary batch is optional. We need to check whether we have any data
if (_floatingRenderInformation._vaoID != 0 &&
_floatingRenderInformation.count != 0) {
internalRender(
renderLines,
renderPoints,
data,
modelTransform,
_floatingRenderInformation,
totalNumber,
// -1 because we duplicate the penultimate point between the vertices
-(primaryOffset + _primaryRenderInformation.count - 1)
);
}
}
if (renderPoints) {
glDisable(GL_PROGRAM_POINT_SIZE);

View File

@@ -32,7 +32,9 @@
#include <openspace/properties/scalar/floatproperty.h>
#include <openspace/properties/scalar/intproperty.h>
#include <openspace/properties/stringproperty.h>
#include <openspace/properties/vector/vec2property.h>
#include <openspace/properties/vector/vec3property.h>
#include <openspace/properties/vector/vec4property.h>
#include <ghoul/misc/managedmemoryuniqueptr.h>
#include <ghoul/opengl/ghoul_gl.h>
#include <ghoul/opengl/uniformcache.h>
@@ -80,14 +82,16 @@ public:
properties::Vec3Property lineColor;
/// Settings that enables or disables the line fading
properties::BoolProperty useLineFade;
/// Specifies a multiplicative factor that fades out the line
properties::FloatProperty lineFade;
/// Line width for the line rendering part
properties::FloatProperty lineWidth;
/// Point size for the point rendering part
properties::IntProperty pointSize;
/// The option determining which rendering method to use
properties::OptionProperty renderingModes;
/// Specifies how much of the orbit should have a trail
properties::FloatProperty lineLength;
/// Specifies how much of the trail should be faded
properties::FloatProperty lineFadeAmount;
};
virtual ~RenderableTrail() override = default;
@@ -112,16 +116,15 @@ protected:
static documentation::Documentation Documentation();
/**
* The layout of the VBOs.
*/
/// The layout of the VBOs (use float if sending as positions to shader)
template <typename T>
struct TrailVBOLayout {
float x, y, z;
T x, y, z;
};
/// The backend storage for the vertex buffer object containing all points for this
/// trail.
std::vector<TrailVBOLayout> _vertexArray;
std::vector<TrailVBOLayout<float>> _vertexArray;
/// The index array that is potentially used in the draw call. If this is empty, no
/// element draw call is used.
@@ -168,25 +171,37 @@ protected:
/// Optional render information that contains information about the last, floating
/// part of the trail
RenderInformation _floatingRenderInformation;
/// Render information that contains information about trail segments after the
/// object point (renderableTrailTrajectory)
RenderInformation _secondaryRenderInformation;
/// Flag used to determine if we use a split trail or not during rendering
bool _useSplitRenderMode = false;
/// Number of unique vertices used when rendering segmented trails
int _numberOfUniqueVertices = 0;
private:
void internalRender(bool renderLines, bool renderPoints,
const RenderData& data,
const glm::dmat4& modelTransform,
RenderInformation& info, int nVertices, int offset);
RenderInformation& info, int nVertices, int ringOffset,
bool useSplitRenderMode = false, int numberOfUniqueVertices = 0,
int floatingOffset = 0);
Appearance _appearance;
/// Program object used to render the data stored in RenderInformation
ghoul::opengl::ProgramObject* _programObject = nullptr;
#ifdef __APPLE__
UniformCache(opacity, modelView, projection, color, useLineFade,
lineFade, vertexSorting, idOffset, nVertices, stride,
pointSize, renderPhase) _uniformCache;
UniformCache(opacity, modelView, projection, color, useLineFade, lineLength,
lineFadeAmount, vertexSorting, idOffset, nVertices, stride, pointSize,
renderPhase, useSplitRenderMode, floatingOffset, numberOfUniqueVertices
) _uniformCache;
#else
UniformCache(opacity, modelView, projection, color, useLineFade, lineFade,
vertexSorting, idOffset, nVertices, stride, pointSize, renderPhase, viewport,
lineWidth) _uniformCache;
UniformCache(opacity, modelView, projection, color, useLineFade, lineLength,
lineFadeAmount, vertexSorting, idOffset, nVertices, stride, pointSize, renderPhase,
viewport, lineWidth, floatingOffset, useSplitRenderMode, numberOfUniqueVertices
) _uniformCache;
#endif
};

View File

@@ -229,8 +229,8 @@ void RenderableTrailOrbit::update(const UpdateData& data) {
// floating value
glBufferSubData(
GL_ARRAY_BUFFER,
_primaryRenderInformation.first * sizeof(TrailVBOLayout),
sizeof(TrailVBOLayout),
_primaryRenderInformation.first * sizeof(TrailVBOLayout<float>),
sizeof(TrailVBOLayout<float>),
_vertexArray.data() + _primaryRenderInformation.first
);
}
@@ -242,7 +242,7 @@ void RenderableTrailOrbit::update(const UpdateData& data) {
// array
glBufferData(
GL_ARRAY_BUFFER,
_vertexArray.size() * sizeof(TrailVBOLayout),
_vertexArray.size() * sizeof(TrailVBOLayout<float>),
_vertexArray.data(),
GL_STREAM_DRAW
);
@@ -269,8 +269,8 @@ void RenderableTrailOrbit::update(const UpdateData& data) {
auto upload = [this](int begin, int length) {
glBufferSubData(
GL_ARRAY_BUFFER,
begin * sizeof(TrailVBOLayout),
sizeof(TrailVBOLayout) * length,
begin * sizeof(TrailVBOLayout<float>),
sizeof(TrailVBOLayout<float>) * length,
_vertexArray.data() + begin
);
};
@@ -417,8 +417,8 @@ RenderableTrailOrbit::UpdateReport RenderableTrailOrbit::updateTrails(
else {
// See how many new points needs to be generated. Delta is negative, so we need
// to invert the ratio
const uint64_t nNewPoints =
-(static_cast<uint64_t>(floor(delta / secondsPerPoint)));
const int nNewPoints =
-(static_cast<int>(floor(delta / secondsPerPoint)));
// If we would need to generate more new points than there are total points in the
// array, it is faster to regenerate the entire array
@@ -494,7 +494,7 @@ void RenderableTrailOrbit::fullSweep(double time) {
glm::vec3 maxVertex(-std::numeric_limits<float>::max());
glm::vec3 minVertex(std::numeric_limits<float>::max());
auto setMax = [&maxVertex, &minVertex](const TrailVBOLayout& vertexData) {
auto setMax = [&maxVertex, &minVertex](const TrailVBOLayout<float>& vertexData) {
maxVertex.x = std::max(maxVertex.x, vertexData.x);
maxVertex.y = std::max(maxVertex.y, vertexData.y);
maxVertex.z = std::max(maxVertex.z, vertexData.z);

View File

@@ -95,7 +95,25 @@ namespace {
"The number of vertices that will be calculated each frame whenever the trail "
"needs to be recalculated. "
"A greater value will result in more calculations per frame.",
// @VISIBILITY(?)
openspace::properties::Property::Visibility::AdvancedUser
};
constexpr openspace::properties::Property::PropertyInfo EnableSweepChunkingInfo = {
"EnableSweepChunking",
"Use Sweep Chunking",
"Enable or Disable the use of iterative calculations (chunking) during full "
"sweep vertex calculations. When enabled, small part of the trail will be "
"calculated each frame instead of calculating the entire trail in one go. "
"The size of each 'chunk' can be altered by changing the sweep chunk size "
"property.",
openspace::properties::Property::Visibility::AdvancedUser
};
constexpr openspace::properties::Property::PropertyInfo AccurateTrailPositionsInfo = {
"AccurateTrailPositions",
"Number of Accurate Trail Points",
"The number of vertices, each side of the object, that will be recalculated "
"for greater accuracy. This also ensures that the object connects with the trail.",
openspace::properties::Property::Visibility::AdvancedUser
};
@@ -117,6 +135,12 @@ namespace {
// [[codegen::verbatim(SweepChunkSizeInfo.description)]]
std::optional<int> sweepChunkSize;
// [[codegen::verbatim(SweepChunkSizeInfo.description)]]
std::optional<int> enableSweepChunking;
// [[codegen::verbatim(AccurateTrailPositionsInfo.description)]]
std::optional<int> accurateTrailPositions;
};
#include "renderabletrailtrajectory_codegen.cpp"
} // namespace
@@ -139,11 +163,17 @@ RenderableTrailTrajectory::RenderableTrailTrajectory(const ghoul::Dictionary& di
, _renderFullTrail(RenderFullPathInfo, false)
, _maxVertex(glm::vec3(-std::numeric_limits<float>::max()))
, _minVertex(glm::vec3(std::numeric_limits<float>::max()))
, _sweepChunkSize(SweepChunkSizeInfo, 200, 50, 5000)
, _enableSweepChunking(EnableSweepChunkingInfo, false)
, _numberOfReplacementPoints(AccurateTrailPositionsInfo, 100, 0, 1000)
{
const Parameters p = codegen::bake<Parameters>(dictionary);
_translation->onParameterChange([this]() { reset(); });
_renderFullTrail = p.showFullTrail.value_or(_renderFullTrail);
addProperty(_renderFullTrail);
_startTime = p.startTime;
_startTime.onChange([this] { reset(); });
addProperty(_startTime);
@@ -161,13 +191,23 @@ RenderableTrailTrajectory::RenderableTrailTrajectory(const ghoul::Dictionary& di
_timeStampSubsamplingFactor.onChange([this] { _subsamplingIsDirty = true; });
addProperty(_timeStampSubsamplingFactor);
_renderFullTrail = p.showFullTrail.value_or(_renderFullTrail);
addProperty(_renderFullTrail);
_numberOfReplacementPoints = p.accurateTrailPositions.value_or(
_numberOfReplacementPoints
);
addProperty(_numberOfReplacementPoints);
_enableSweepChunking = p.enableSweepChunking.value_or(_enableSweepChunking);
addProperty(_enableSweepChunking);
_sweepChunkSize = p.sweepChunkSize.value_or(_sweepChunkSize);
addProperty(_sweepChunkSize);
// We store the vertices with ascending temporal order
_primaryRenderInformation.sorting = RenderInformation::VertexSorting::OldestFirst;
_secondaryRenderInformation.sorting = RenderInformation::VertexSorting::OldestFirst;
// Activate special render mode for renderableTrailTrajectory
_useSplitRenderMode = true;
}
void RenderableTrailTrajectory::initializeGL() {
@@ -182,6 +222,9 @@ void RenderableTrailTrajectory::initializeGL() {
glGenVertexArrays(1, &_floatingRenderInformation._vaoID);
glGenBuffers(1, &_floatingRenderInformation._vBufferID);
_floatingRenderInformation.sorting = RenderInformation::VertexSorting::OldestFirst;
_secondaryRenderInformation._vaoID = _primaryRenderInformation._vaoID;
_secondaryRenderInformation._vBufferID = _primaryRenderInformation._vBufferID;
}
void RenderableTrailTrajectory::deinitializeGL() {
@@ -230,26 +273,38 @@ void RenderableTrailTrajectory::update(const UpdateData& data) {
// Make space for the vertices
_vertexArray.clear();
_dVertexArray.clear();
_timeVector.clear();
_vertexArray.resize(_numberOfVertices + 1);
_dVertexArray.resize(_numberOfVertices + 1);
_timeVector.resize(_numberOfVertices + 1);
}
// Calculate sweeping range for this iteration
const unsigned int startIndex = _sweepIteration * _sweepChunkSize;
const unsigned int nextIndex = (_sweepIteration + 1) * _sweepChunkSize;
const unsigned int stopIndex = std::min(nextIndex, _numberOfVertices);
unsigned int stopIndex = std::min(nextIndex, _numberOfVertices);
// If iterative calculations are disabled
if (!_enableSweepChunking) {
stopIndex = _numberOfVertices;
}
// Calculate all vertex positions
for (unsigned int i = startIndex; i < stopIndex; i++) {
const glm::vec3 p = _translation->position({
const glm::dvec3 dp = _translation->position({
{},
Time(_start + i * _totalSampleInterval),
Time(0.0)
});
const glm::vec3 p(dp.x, dp.y, dp.z);
_vertexArray[i] = { p.x, p.y, p.z };
_timeVector[i] = Time(_start + i * _totalSampleInterval).j2000Seconds();
_dVertexArray[i] = {dp.x, dp.y, dp.z};
// Set max and min vertex for bounding sphere calculations
_maxVertex = glm::max(_maxVertex, p);
_minVertex = glm::min(_minVertex, p);
_maxVertex = glm::max(_maxVertex, dp);
_minVertex = glm::min(_minVertex, dp);
}
++_sweepIteration;
@@ -257,15 +312,18 @@ void RenderableTrailTrajectory::update(const UpdateData& data) {
// Adds the last point in time to the _vertexArray so that we
// ensure that points for _start and _end always exists
if (stopIndex == _numberOfVertices) {
const glm::vec3 p = _translation->position({
const glm::dvec3 dp = _translation->position({
{},
Time(_end),
Time(0.0)
});
});
const glm::vec3 p(dp.x, dp.y, dp.z);
_vertexArray[stopIndex] = { p.x, p.y, p.z };
_timeVector[stopIndex] = Time(_end).j2000Seconds();
_dVertexArray[stopIndex] = { dp.x, dp.y, dp.z };
_sweepIteration = 0;
setBoundingSphere(glm::distance(_maxVertex, _minVertex) / 2.f);
setBoundingSphere(glm::distance(_maxVertex, _minVertex) / 2.0);
}
else {
// Early return as we don't need to render if we are still
@@ -278,7 +336,7 @@ void RenderableTrailTrajectory::update(const UpdateData& data) {
glBindBuffer(GL_ARRAY_BUFFER, _primaryRenderInformation._vBufferID);
glBufferData(
GL_ARRAY_BUFFER,
_vertexArray.size() * sizeof(TrailVBOLayout),
_vertexArray.size() * sizeof(TrailVBOLayout<float>),
_vertexArray.data(),
GL_STATIC_DRAW
);
@@ -295,81 +353,192 @@ void RenderableTrailTrajectory::update(const UpdateData& data) {
}
// This has to be done every update step;
if (_renderFullTrail) {
// If the full trail should be rendered at all times, we can directly render the
// entire set
_primaryRenderInformation.first = 0;
_primaryRenderInformation.count = static_cast<GLsizei>(_vertexArray.size());
}
else {
// If only trail so far should be rendered, we need to find the corresponding time
// in the array and only render it until then
_primaryRenderInformation.first = 0;
const double t = std::max(
0.0,
(data.time.j2000Seconds() - _start) / (_end - _start)
const double j2k = data.time.j2000Seconds();
if (j2k >= _start && j2k < _end) {
_replacementPoints.clear();
// Calculates number of vertices for the first segment (start point to object)
_primaryRenderInformation.count = static_cast<GLsizei>(
std::distance(
_timeVector.begin(),
std::lower_bound(_timeVector.begin(), _timeVector.end(), j2k)
)
);
if (data.time.j2000Seconds() < _end) {
_primaryRenderInformation.count = static_cast<GLsizei>(
std::max(
1.0,
floor(_vertexArray.size() - 1) * t
)
);
if (_renderFullTrail) {
// Calculates number of vertices for the second segment (object to end point)
_secondaryRenderInformation.first = _primaryRenderInformation.count;
_secondaryRenderInformation.count = static_cast<GLsizei>(
_vertexArray.size() - (_primaryRenderInformation.count)
);
// Calculate number of vertices in the trail
_numberOfUniqueVertices = static_cast<GLsizei>(
std::distance(_timeVector.begin(), _timeVector.end())
);
}
else {
_primaryRenderInformation.count = static_cast<GLsizei>(_vertexArray.size());
// If we don't render full trail there's no trail after the object
_secondaryRenderInformation.first = 0;
_secondaryRenderInformation.count = 0;
// Set number of vertices in the trail
_numberOfUniqueVertices = _primaryRenderInformation.count;
}
}
// If we are inside the valid time, we additionally want to draw a line from the last
// correct point to the current location of the object
if (data.time.j2000Seconds() > _start &&
data.time.j2000Seconds() <= _end && !_renderFullTrail)
{
ghoul_assert(_primaryRenderInformation.count > 0, "No vertices available");
// Copy the last valid location
const glm::dvec3 v0 = glm::dvec3(
_vertexArray[_primaryRenderInformation.count - 1].x,
_vertexArray[_primaryRenderInformation.count - 1].y,
_vertexArray[_primaryRenderInformation.count - 1].z
// Determine the number of points to be recalculated
int prePaddingDelta = 0;
if (!_renderFullTrail && _numberOfReplacementPoints == 0) {
// Enables trail from last point to current position
// if we don't do any replacement points
prePaddingDelta = 1;
}
else {
prePaddingDelta = std::min(
static_cast<int>(_primaryRenderInformation.count),
static_cast<int>(_numberOfReplacementPoints)
);
}
int postPaddingDelta = std::min(
static_cast<int>(_secondaryRenderInformation.count),
static_cast<int>(_numberOfReplacementPoints)
);
// And get the current location of the object
// Get current position of the object
const glm::dvec3 p = _translation->position(data);
const glm::dvec3 v1 = glm::dvec3(p.x, p.y, p.z);
// Comptue the difference between the points in double precision
const glm::dvec3 p0 = v0 - v1;
_auxiliaryVboData[0] = {
static_cast<float>(p0.x),
static_cast<float>(p0.y),
static_cast<float>(p0.z)
};
_auxiliaryVboData[1] = { 0.f, 0.f, 0.f };
// Calculates all replacement points before the object
glm::dvec3 v = p;
for (int i = 0; i < prePaddingDelta; ++i) {
const int floatPointIndex =
_primaryRenderInformation.count - prePaddingDelta + i;
// Fill the render info with the data
glm::dvec3 fp = glm::dvec3(
_vertexArray[floatPointIndex].x,
_vertexArray[floatPointIndex].y,
_vertexArray[floatPointIndex].z
);
glm::dvec3 dp = glm::dvec3(
_dVertexArray[floatPointIndex].x,
_dVertexArray[floatPointIndex].y,
_dVertexArray[floatPointIndex].z
);
glm::dvec3 dv = fp - dp;
glm::dvec3 newPoint = dp - v;
// Scales position offset for smooth transition from '
// original points to accurate points
double mult = 0.0;
if (i == prePaddingDelta - 1) {
mult = (i == 0) ? 1.0 : 0.0;
}
else {
mult = (prePaddingDelta - i) / static_cast<double>(prePaddingDelta);
}
newPoint = newPoint + dv * mult;
_replacementPoints.push_back({
static_cast<float>(newPoint.x),
static_cast<float>(newPoint.y),
static_cast<float>(newPoint.z)
});
}
// Mid-point (model-space position for the object)
if (_numberOfReplacementPoints > 0 || !_renderFullTrail) {
_replacementPoints.push_back({ 0.f, 0.f, 0.f });
}
// Calculates all replacement points after the object
v = glm::dvec3(p.x, p.y, p.z);
for (int i = 0; i < postPaddingDelta; ++i) {
const int floatPointIndex = _secondaryRenderInformation.first + i;
glm::dvec3 fp = glm::dvec3(
_vertexArray[floatPointIndex].x,
_vertexArray[floatPointIndex].y,
_vertexArray[floatPointIndex].z
);
glm::dvec3 dp = glm::dvec3(
_dVertexArray[floatPointIndex].x,
_dVertexArray[floatPointIndex].y,
_dVertexArray[floatPointIndex].z
);
glm::dvec3 dv = fp - dp;
glm::dvec3 newPoint = dp - v;
// Scales position offset for smooth transition from '
// original points to accurate points
double mult = (i == postPaddingDelta - 1) ?
1.0 :
1.0 - (postPaddingDelta - i) / static_cast<double>(postPaddingDelta);
newPoint = newPoint + dv * mult;
_replacementPoints.push_back({
static_cast<float>(newPoint.x),
static_cast<float>(newPoint.y),
static_cast<float>(newPoint.z)
});
}
// Set variables for floating segments
_floatingRenderInformation.first = 0;
_floatingRenderInformation.count = 2;
_floatingRenderInformation.count =
static_cast<GLsizei>(_replacementPoints.size());
_floatingRenderInformation._localTransform = glm::translate(
glm::dmat4(1.0),
p
);
// Adjusts number of unique vertices if we have inserted a new mid point
if (_floatingRenderInformation.count > 0 && _renderFullTrail) {
_numberOfUniqueVertices++;
}
// Recalculate .count and .first based on the recalculated (floating) vertices
_primaryRenderInformation.count -= std::max(0, prePaddingDelta - 1);
_secondaryRenderInformation.first += std::max(0, postPaddingDelta - 1);
_secondaryRenderInformation.count -= std::max(0, postPaddingDelta - 1);
// Adjusts count such that it takes into account if we don't have any line
// connecting with the object
if (_renderFullTrail && _numberOfReplacementPoints == 0) {
_primaryRenderInformation.count += 1;
}
_floatingRenderInformation._localTransform = glm::translate(glm::dmat4(1.0), v1);
glBindVertexArray(_floatingRenderInformation._vaoID);
glBindBuffer(GL_ARRAY_BUFFER, _floatingRenderInformation._vBufferID);
glBufferData(
GL_ARRAY_BUFFER,
_auxiliaryVboData.size() * sizeof(TrailVBOLayout),
_auxiliaryVboData.data(),
_replacementPoints.size() * sizeof(TrailVBOLayout<float>),
_replacementPoints.data(),
GL_DYNAMIC_DRAW
);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, nullptr);
}
else if (j2k >= _end || (j2k < _start && _renderFullTrail)) {
// Renders the whole trail if time has passed the end time
_primaryRenderInformation.first = 0;
_primaryRenderInformation.count = static_cast<GLsizei>(_vertexArray.size());
_numberOfUniqueVertices = _primaryRenderInformation.count;
_secondaryRenderInformation.first = 0;
_secondaryRenderInformation.count = 0;
_floatingRenderInformation.first = 0;
_floatingRenderInformation.count = 0;
}
else {
// if we are outside of the valid range, we don't render anything
_primaryRenderInformation.first = 0;
_primaryRenderInformation.count = 0;
_secondaryRenderInformation.first = 0;
_secondaryRenderInformation.count = 0;
_floatingRenderInformation.first = 0;
_floatingRenderInformation.count = 0;
}
@@ -377,8 +546,11 @@ void RenderableTrailTrajectory::update(const UpdateData& data) {
if (_subsamplingIsDirty) {
// If the subsampling information has changed (either by a property change or by
// a request of a full sweep) we update it here
_primaryRenderInformation.stride = _timeStampSubsamplingFactor;
_secondaryRenderInformation.stride = _timeStampSubsamplingFactor;
_floatingRenderInformation.stride = _timeStampSubsamplingFactor;
_subsamplingIsDirty = false;
}

View File

@@ -67,7 +67,9 @@ private:
void reset();
/// The number of vertices that we calculate during each frame of the full sweep pass
unsigned int _sweepChunkSize = 200;
properties::IntProperty _sweepChunkSize;
/// Enables or disables iterative vertex calculations during a full sweep
properties::BoolProperty _enableSweepChunking;
/// The start time of the trail
properties::StringProperty _startTime;
@@ -80,6 +82,9 @@ private:
properties::IntProperty _timeStampSubsamplingFactor;
/// Determines whether the full trail should be rendered or the future trail removed
properties::BoolProperty _renderFullTrail;
/// Determines how many vertices around the object that will be
/// replaced during full trail rendering
properties::IntProperty _numberOfReplacementPoints;
/// Dirty flag that determines whether the full vertex buffer needs to be resampled
bool _needsFullSweep = true;
@@ -87,7 +92,7 @@ private:
/// Dirty flag to determine whether the stride information needs to be changed
bool _subsamplingIsDirty = true;
std::array<TrailVBOLayout, 2> _auxiliaryVboData = {};
std::array<TrailVBOLayout<float>, 2> _auxiliaryVboData = {};
/// The conversion of the _startTime into the internal time format
double _start = 0.0;
@@ -104,8 +109,17 @@ private:
double _totalSampleInterval = 0.0;
/// Max and min vertex used to calculate the bounding sphere
glm::vec3 _maxVertex;
glm::vec3 _minVertex;
glm::dvec3 _maxVertex;
glm::dvec3 _minVertex;
/// Contains all timestamps corresponding to the positions in _vertexArray
std::vector<double> _timeVector;
/// Keeps track of all double precision vertices of trails
std::vector<TrailVBOLayout<double>> _dVertexArray;
/// Contains all the points that we will render in model-space
std::vector<TrailVBOLayout<float>> _replacementPoints;
};
} // namespace openspace

View File

@@ -51,12 +51,7 @@ Fragment getFragment() {
vec2 circCoord = 2.0 * gl_PointCoord - 1.0;
//float circleClipping = 1.0 - smoothstep(1.0 - Delta, 1.0, dot(circCoord, circCoord));
float circleClipping = smoothstep(1.0, 1.0 - Delta, dot(circCoord, circCoord));
float transparencyCorrection = frag.color.a * circleClipping;
if (transparencyCorrection < 0.9) {
discard;
}
frag.color.a = transparencyCorrection;
frag.color.a *= circleClipping;
}
frag.gPosition = vs_gPosition;

View File

@@ -37,13 +37,18 @@ uniform mat4 projectionTransform;
uniform int idOffset;
uniform int nVertices;
uniform bool useLineFade;
uniform float lineFade;
uniform float lineLength;
uniform float lineFadeAmount;
uniform int vertexSortingMethod;
uniform int pointSize;
uniform int stride;
uniform ivec2 resolution;
uniform bool useSplitRenderMode;
uniform int numberOfUniqueVertices;
uniform int floatingOffset;
// Fragile! Keep in sync with RenderableTrail::render
#define VERTEX_SORTING_NEWESTFIRST 0
#define VERTEX_SORTING_OLDESTFIRST 1
@@ -54,20 +59,43 @@ void main() {
int modId = gl_VertexID;
if ((vertexSortingMethod != VERTEX_SORTING_NOSORTING) && useLineFade) {
// Account for a potential rolling buffer
modId = gl_VertexID - idOffset;
if (modId < 0) {
modId += nVertices;
}
float id = 0;
// Convert the index to a [0,1] ranger
float id = float(modId) / float(nVertices);
if (useSplitRenderMode) {
// Calculates id for when using split render mode (renderableTrailTrajectory)
id = float(floatingOffset + modId) / float(max(1, numberOfUniqueVertices - 1));
}
else {
// Account for a potential rolling buffer
modId = gl_VertexID - idOffset;
if (modId < 0) {
modId += nVertices;
}
// Convert the index to a [0,1] range
id = float(modId) / float(nVertices);
}
if (vertexSortingMethod == VERTEX_SORTING_NEWESTFIRST) {
id = 1.0 - id;
}
fade = clamp(id * lineFade, 0.0, 1.0);
float b0 = lineLength;
float b1 = lineFadeAmount;
float fadeValue = 0.0;
if (id <= b0) {
fadeValue = 0.0;
}
else if (id > b0 && id < b1) {
float delta = b1 - b0;
fadeValue = (id - b0) / delta;
}
else {
fadeValue = 1.0;
}
fade = clamp(fadeValue, 0.0, 1.0);
}
else {
fade = 1.0;

View File

@@ -54,12 +54,7 @@ Fragment getFragment() {
vec2 circCoord = 2.0 * gl_PointCoord - 1.0;
//float circleClipping = 1.0 - smoothstep(1.0 - Delta, 1.0, dot(circCoord, circCoord));
float circleClipping = smoothstep(1.0, 1.0 - Delta, dot(circCoord, circCoord));
float transparencyCorrection = frag.color.a * circleClipping;
if (transparencyCorrection < 0.9) {
discard;
}
frag.color.a = transparencyCorrection;
frag.color.a *= circleClipping;
}
// We can't expect a viewport of the form (0, 0, res.x, res.y) used to convert the

View File

@@ -38,13 +38,18 @@ uniform mat4 projectionTransform;
uniform int idOffset;
uniform int nVertices;
uniform bool useLineFade;
uniform float lineFade;
uniform float lineLength;
uniform float lineFadeAmount;
uniform int vertexSortingMethod;
uniform int pointSize;
uniform int stride;
uniform vec4 viewport;
uniform bool useSplitRenderMode;
uniform int numberOfUniqueVertices;
uniform int floatingOffset;
// Fragile! Keep in sync with RenderableTrail::render
#define VERTEX_SORTING_NEWESTFIRST 0
#define VERTEX_SORTING_OLDESTFIRST 1
@@ -55,20 +60,43 @@ void main() {
int modId = gl_VertexID;
if ((vertexSortingMethod != VERTEX_SORTING_NOSORTING) && useLineFade) {
// Account for a potential rolling buffer
modId = gl_VertexID - idOffset;
if (modId < 0) {
modId += nVertices;
}
float id = 0;
// Convert the index to a [0,1] ranger
float id = float(modId) / float(nVertices);
if (useSplitRenderMode) {
// Calculates id for when using split render mode (renderableTrailTrajectory)
id = float(floatingOffset + modId) / float(max(1, numberOfUniqueVertices - 1));
}
else {
// Account for a potential rolling buffer
modId = gl_VertexID - idOffset;
if (modId < 0) {
modId += nVertices;
}
// Convert the index to a [0,1] range
id = float(modId) / float(nVertices);
}
if (vertexSortingMethod == VERTEX_SORTING_NEWESTFIRST) {
id = 1.0 - id;
}
fade = clamp(id * lineFade, 0.0, 1.0);
float b0 = lineLength;
float b1 = lineFadeAmount;
float fadeValue = 0.0;
if (id <= b0) {
fadeValue = 0.0;
}
else if (id > b0 && id < b1) {
float delta = b1 - b0;
fadeValue = (id - b0) / delta;
}
else {
fadeValue = 1.0;
}
fade = clamp(fadeValue, 0.0, 1.0);
}
else {
fade = 1.0;

View File

@@ -72,8 +72,11 @@ set(SHADER_FILES
shaders/constellationbounds_vs.glsl
shaders/constellationlines_fs.glsl
shaders/constellationlines_vs.glsl
shaders/debrisViz_fs.glsl
shaders/debrisViz_vs.glsl
shaders/debrisVizPoints_fs.glsl
shaders/debrisVizPoints_gs.glsl
shaders/debrisVizPoints_vs.glsl
shaders/debrisVizTrails_fs.glsl
shaders/debrisVizTrails_vs.glsl
shaders/fluxnodes_fs.glsl
shaders/fluxnodes_vs.glsl
shaders/habitablezone_vs.glsl

View File

@@ -45,6 +45,14 @@
#include <vector>
namespace {
// The possible values for the _renderingModes property
enum RenderingMode {
RenderingModeTrail = 0,
RenderingModePoint,
RenderingModePointTrail
};
constexpr openspace::properties::Property::PropertyInfo PathInfo = {
"Path",
"Path",
@@ -63,30 +71,92 @@ namespace {
openspace::properties::Property::Visibility::User
};
constexpr openspace::properties::Property::PropertyInfo LineWidthInfo = {
"LineWidth",
"Line Width",
constexpr openspace::properties::Property::PropertyInfo TrailWidthInfo = {
"TrailWidth",
"Trail Width",
"This value specifies the line width of the trail if the selected rendering "
"method includes lines. If the rendering mode is set to Points, this value is "
"ignored",
openspace::properties::Property::Visibility::NoviceUser
};
constexpr openspace::properties::Property::PropertyInfo LineColorInfo = {
constexpr openspace::properties::Property::PropertyInfo PointSizeExponentInfo = {
"PointSizeExponent",
"Point Size Exponent",
"This value is used as in exponential scaling to set the absolute size of the "
"point.",
// @VISIBILITY(2.4)
openspace::properties::Property::Visibility::User
};
constexpr openspace::properties::Property::PropertyInfo EnableMaxSizeInfo = {
"EnableMaxSize",
"Enable Max Size",
"If true, the Max Size property will be used as an upper limit for the size of "
"the point. This reduces the size of the points when approaching them, so that "
"they stick to a maximum visual size depending on the Max Size value.",
openspace::properties::Property::Visibility::AdvancedUser
};
constexpr openspace::properties::Property::PropertyInfo MaxSizeInfo = {
"MaxSize",
"Max Size",
"This value controls the maximum allowed size for the points, when the max size "
"control feature is enabled. This limits the visual size of the points based on "
"the distance to the camera. The larger the value, the larger the points are "
"allowed to be. In the background, the computations are made to limit the size "
"of the angle between the CameraToPointMid and CameraToPointEdge vectors.",
openspace::properties::Property::Visibility::AdvancedUser
};
constexpr openspace::properties::Property::PropertyInfo RenderingModeInfo = {
"Rendering",
"Rendering Mode",
"Determines how the trail should be rendered. If 'Trail' is selected, "
"only the line part is visible, if 'Point' is selected, only the "
"current satellite/debris point is visible.",
openspace::properties::Property::Visibility::AdvancedUser
};
constexpr openspace::properties::Property::PropertyInfo ColorInfo = {
"Color",
"Color",
"This value determines the RGB main color for the lines and points of the trail",
"This value determines the RGB main color for the trails and points.",
openspace::properties::Property::Visibility::NoviceUser
};
constexpr openspace::properties::Property::PropertyInfo TrailFadeInfo = {
"TrailFade",
"Trail Fade",
"Trail Fade Factor",
"This value determines how fast the trail fades and is an appearance property.",
// @VISIBILITY(2.5)
openspace::properties::Property::Visibility::User
};
constexpr openspace::properties::Property::PropertyInfo EnableOutlineInfo = {
"EnableOutline",
"Enable Point Outline",
"This setting determines if each point should have an outline or not. An outline "
"is only applied when rendering as colored points (not when using textures).",
openspace::properties::Property::Visibility::User
};
constexpr openspace::properties::Property::PropertyInfo OutlineColorInfo = {
"OutlineColor",
"Outline Color",
"This value defines the color of the outline. Darker colors will be "
"less visible if Additive Blending is enabled.",
openspace::properties::Property::Visibility::User
};
constexpr openspace::properties::Property::PropertyInfo OutlineWeightInfo = {
"OutlineWeight",
"Outline Weight",
"This setting determines the thickness of the outline. A value of 0 will "
"not show any outline, while a value of 1 will cover the whole point.",
openspace::properties::Property::Visibility::AdvancedUser
};
constexpr openspace::properties::Property::PropertyInfo StartRenderIdxInfo = {
"StartRenderIdx",
"Contiguous Starting Index of Render",
@@ -130,15 +200,23 @@ namespace {
// [[codegen::verbatim(SegmentQualityInfo.description)]]
int segmentQuality;
// [[codegen::verbatim(LineWidthInfo.description)]]
std::optional<float> lineWidth;
// [[codegen::verbatim(TrailWidthInfo.description)]]
std::optional<float> trailWidth;
// [[codegen::verbatim(LineColorInfo.description)]]
// [[codegen::verbatim(ColorInfo.description)]]
glm::dvec3 color [[codegen::color()]];
// [[codegen::verbatim(TrailFadeInfo.description)]]
std::optional<float> trailFade;
enum class RenderingMode {
Trail,
Point,
PointsTrails
};
// [[codegen::verbatim(RenderingModeInfo.description)]]
std::optional<RenderingMode> renderingMode [[codegen::key("Rendering")]];
// [[codegen::verbatim(StartRenderIdxInfo.description)]]
std::optional<int> startRenderIdx;
@@ -147,6 +225,24 @@ namespace {
// [[codegen::verbatim(ContiguousModeInfo.description)]]
std::optional<bool> contiguousMode;
// [[codegen::verbatim(PointSizeExponentInfo.description)]]
std::optional<float> pointSizeExponent;
// [[codegen::verbatim(EnableMaxSizeInfo.description)]]
std::optional<bool> enableMaxSize;
// [[codegen::verbatim(MaxSizeInfo.description)]]
std::optional<float> maxSize;
// [[codegen::verbatim(EnableOutlineInfo.description)]]
std::optional<bool> enableOutline;
// [[codegen::verbatim(OutlineColorInfo.description)]]
std::optional<glm::vec3> outlineColor;
// [[codegen::verbatim(OutlineColorInfo.description)]]
std::optional<float> outlineWeight;
};
#include "renderableorbitalkepler_codegen.cpp"
} // namespace
@@ -157,6 +253,45 @@ documentation::Documentation RenderableOrbitalKepler::Documentation() {
return codegen::doc<Parameters>("space_renderableorbitalkepler");
}
RenderableOrbitalKepler::Appearance::Appearance()
: properties::PropertyOwner({
"Appearance",
"Appearance",
"Appearance of RenderableOrbitalKepler"
})
, color(ColorInfo, glm::vec3(1.f), glm::vec3(0.f), glm::vec3(1.f))
, trailWidth(TrailWidthInfo, 2.f, 1.f, 20.f)
, pointSizeExponent(PointSizeExponentInfo, 1.0f, 0.f, 25.f)
, renderingModes(
RenderingModeInfo,
properties::OptionProperty::DisplayType::Dropdown
)
, trailFade(TrailFadeInfo, 20.f, 0.f, 30.f)
, enableMaxSize(EnableMaxSizeInfo, false)
, maxSize(MaxSizeInfo, 1.f, 0.f, 45.f)
, enableOutline(EnableOutlineInfo, true)
, outlineColor(OutlineColorInfo, glm::vec3(0.f), glm::vec3(0.f), glm::vec3(1.f))
, outlineWeight(OutlineWeightInfo, 0.2f, 0.f, 1.f)
{
renderingModes.addOptions({
{ RenderingModeTrail, "Trails" },
{ RenderingModePoint, "Points" },
{ RenderingModePointTrail , "Points+Trails" }
});
color.setViewOption(properties::Property::ViewOptions::Color);
addProperty(renderingModes);
addProperty(color);
addProperty(trailWidth);
addProperty(trailFade);
addProperty(pointSizeExponent);
addProperty(enableMaxSize);
addProperty(maxSize);
addProperty(enableOutline);
addProperty(outlineColor);
addProperty(outlineWeight);
}
RenderableOrbitalKepler::RenderableOrbitalKepler(const ghoul::Dictionary& dict)
: Renderable(dict)
, _segmentQuality(SegmentQualityInfo, 2, 1, 10)
@@ -173,9 +308,33 @@ RenderableOrbitalKepler::RenderableOrbitalKepler(const ghoul::Dictionary& dict)
_segmentQuality.onChange([this]() { updateBuffers(); });
addProperty(_segmentQuality);
_appearance.lineColor = p.color;
_appearance.lineFade = p.trailFade.value_or(20.f);
_appearance.lineWidth = p.lineWidth.value_or(2.f);
_appearance.color = p.color;
_appearance.trailFade = p.trailFade.value_or(_appearance.trailFade);
_appearance.trailWidth = p.trailWidth.value_or(_appearance.trailWidth);
_appearance.enableMaxSize = p.enableMaxSize.value_or(_appearance.enableMaxSize);
_appearance.maxSize = p.maxSize.value_or(_appearance.maxSize);
_appearance.enableOutline = p.enableOutline.value_or(_appearance.enableOutline);
_appearance.outlineColor = p.outlineColor.value_or(_appearance.outlineColor);
_appearance.outlineWeight = p.outlineWeight.value_or(_appearance.outlineWeight);
_appearance.pointSizeExponent =
p.pointSizeExponent.value_or(_appearance.pointSizeExponent);
if (p.renderingMode.has_value()) {
switch (*p.renderingMode) {
case Parameters::RenderingMode::Trail:
_appearance.renderingModes = RenderingModeTrail;
break;
case Parameters::RenderingMode::Point:
_appearance.renderingModes = RenderingModePoint;
break;
case Parameters::RenderingMode::PointsTrails:
_appearance.renderingModes = RenderingModePointTrail;
break;
}
}
else {
_appearance.renderingModes = RenderingModeTrail;
}
addPropertySubOwner(_appearance);
_path = p.path.string();
@@ -217,23 +376,59 @@ void RenderableOrbitalKepler::initializeGL() {
glGenVertexArrays(1, &_vertexArray);
glGenBuffers(1, &_vertexBuffer);
_programObject = SpaceModule::ProgramObjectManager.request(
"OrbitalKepler",
// Program for line rendering
_trailProgram = SpaceModule::ProgramObjectManager.request(
"OrbitalKeplerTrails",
[]() -> std::unique_ptr<ghoul::opengl::ProgramObject> {
return global::renderEngine->buildRenderProgram(
"OrbitalKepler",
absPath("${MODULE_SPACE}/shaders/debrisViz_vs.glsl"),
absPath("${MODULE_SPACE}/shaders/debrisViz_fs.glsl")
"OrbitalKeplerTrails",
absPath("${MODULE_SPACE}/shaders/debrisVizTrails_vs.glsl"),
absPath("${MODULE_SPACE}/shaders/debrisVizTrails_fs.glsl")
);
}
);
// Program for point rendering
_pointProgram = SpaceModule::ProgramObjectManager.request(
"OrbitalKeplerPoints",
[]() -> std::unique_ptr<ghoul::opengl::ProgramObject> {
return global::renderEngine->buildRenderProgram(
"OrbitalKeplerPoints",
absPath("${MODULE_SPACE}/shaders/debrisVizPoints_vs.glsl"),
absPath("${MODULE_SPACE}/shaders/debrisVizPoints_fs.glsl"),
absPath("${MODULE_SPACE}/shaders/debrisVizPoints_gs.glsl")
);
}
);
_uniformCache.modelView = _programObject->uniformLocation("modelViewTransform");
_uniformCache.projection = _programObject->uniformLocation("projectionTransform");
_uniformCache.lineFade = _programObject->uniformLocation("lineFade");
_uniformCache.inGameTime = _programObject->uniformLocation("inGameTime");
_uniformCache.color = _programObject->uniformLocation("color");
_uniformCache.opacity = _programObject->uniformLocation("opacity");
// Init cache for line rendering
_uniformTrailCache.modelView =
_trailProgram->uniformLocation("modelViewTransform");
_uniformTrailCache.projection =
_trailProgram->uniformLocation("projectionTransform");
_uniformTrailCache.trailFade = _trailProgram->uniformLocation("trailFade");
_uniformTrailCache.inGameTime = _trailProgram->uniformLocation("inGameTime");
_uniformTrailCache.color = _trailProgram->uniformLocation("color");
_uniformTrailCache.opacity = _trailProgram->uniformLocation("opacity");
// Init cache for point rendering
_uniformPointCache.modelTransform = _pointProgram->uniformLocation("modelTransform");
_uniformPointCache.viewTransform = _pointProgram->uniformLocation("viewTransform");
_uniformPointCache.cameraUpWorld = _pointProgram->uniformLocation("cameraUpWorld");
_uniformPointCache.inGameTime = _pointProgram->uniformLocation("inGameTime");
_uniformPointCache.color = _pointProgram->uniformLocation("color");
_uniformPointCache.enableMaxSize = _pointProgram->uniformLocation("enableMaxSize");
_uniformPointCache.maxSize = _pointProgram->uniformLocation("maxSize");
_uniformPointCache.enableOutline = _pointProgram->uniformLocation("enableOutline");
_uniformPointCache.outlineColor = _pointProgram->uniformLocation("outlineColor");
_uniformPointCache.outlineWeight = _pointProgram->uniformLocation("outlineWeight");
_uniformPointCache.opacity = _pointProgram->uniformLocation("opacity");
_uniformPointCache.projectionTransform =
_pointProgram->uniformLocation("projectionTransform");
_uniformPointCache.cameraPositionWorld =
_pointProgram->uniformLocation("cameraPositionWorld");
_uniformPointCache.pointSizeExponent =
_pointProgram->uniformLocation("pointSizeExponent");
updateBuffers();
}
@@ -243,16 +438,25 @@ void RenderableOrbitalKepler::deinitializeGL() {
glDeleteVertexArrays(1, &_vertexArray);
SpaceModule::ProgramObjectManager.release(
"OrbitalKepler",
"OrbitalKeplerTrails",
[](ghoul::opengl::ProgramObject* p) {
global::renderEngine->removeRenderProgram(p);
}
);
_programObject = nullptr;
SpaceModule::ProgramObjectManager.release(
"OrbitalKeplerPoints",
[](ghoul::opengl::ProgramObject* p) {
global::renderEngine->removeRenderProgram(p);
}
);
_pointProgram = nullptr;
_trailProgram = nullptr;
}
bool RenderableOrbitalKepler::isReady() const {
return _programObject != nullptr;
return _pointProgram != nullptr && _trailProgram != nullptr;
}
void RenderableOrbitalKepler::update(const UpdateData&) {
@@ -267,35 +471,89 @@ void RenderableOrbitalKepler::render(const RenderData& data, RendererTasks&) {
return;
}
_programObject->activate();
_programObject->setUniform(_uniformCache.opacity, opacity());
_programObject->setUniform(_uniformCache.inGameTime, data.time.j2000Seconds());
_programObject->setUniform(_uniformCache.modelView, calcModelViewTransform(data));
// Because we want the property to work similar to the planet trails
const float fade = std::pow(
_appearance.lineFade.maxValue() - _appearance.lineFade,
2.f
);
_programObject->setUniform(_uniformCache.projection, data.camera.projectionMatrix());
_programObject->setUniform(_uniformCache.color, _appearance.lineColor);
_programObject->setUniform(_uniformCache.lineFade, fade);
glLineWidth(_appearance.lineWidth);
//glDepthMask(false);
//glBlendFunc(GL_SRC_ALPHA, GL_ONE)
GLint* _si = _startIndex.data();
GLint* _ss = _segmentSize.data();
glBindVertexArray(_vertexArray);
glMultiDrawArrays(GL_LINE_STRIP, _si, _ss, static_cast<GLsizei>(_startIndex.size()));
glBindVertexArray(0);
const int selection = _appearance.renderingModes;
const bool renderPoints = (
selection == RenderingModePoint ||
selection == RenderingModePointTrail
);
const bool renderTrails = (
selection == RenderingModeTrail ||
selection == RenderingModePointTrail
);
_programObject->deactivate();
if (renderPoints) {
_pointProgram->activate();
_pointProgram->setUniform(_uniformPointCache.modelTransform,
calcModelTransform(data));
_pointProgram->setUniform(_uniformPointCache.viewTransform,
data.camera.combinedViewMatrix());
_pointProgram->setUniform(_uniformPointCache.projectionTransform,
data.camera.projectionMatrix());
_pointProgram->setUniform(_uniformPointCache.cameraPositionWorld,
data.camera.positionVec3());
_pointProgram->setUniform(_uniformPointCache.cameraUpWorld,
data.camera.lookUpVectorWorldSpace());
_pointProgram->setUniform(_uniformPointCache.inGameTime,
data.time.j2000Seconds());
_pointProgram->setUniform(_uniformPointCache.pointSizeExponent,
_appearance.pointSizeExponent);
_pointProgram->setUniform(_uniformPointCache.enableMaxSize,
_appearance.enableMaxSize);
_pointProgram->setUniform(_uniformPointCache.enableOutline,
_appearance.enableOutline);
_pointProgram->setUniform(_uniformPointCache.outlineColor,
_appearance.outlineColor);
_pointProgram->setUniform(_uniformPointCache.outlineWeight,
_appearance.outlineWeight);
_pointProgram->setUniform(_uniformPointCache.color, _appearance.color);
_pointProgram->setUniform(_uniformPointCache.maxSize, _appearance.maxSize);
_pointProgram->setUniform(_uniformPointCache.opacity, opacity());
glBindVertexArray(_vertexArray);
glMultiDrawArrays(
GL_LINE_STRIP,
_si,
_ss,
static_cast<GLsizei>(_startIndex.size())
);
glBindVertexArray(0);
_pointProgram->deactivate();
}
if (renderTrails) {
_trailProgram->activate();
_trailProgram->setUniform(_uniformTrailCache.opacity, opacity());
_trailProgram->setUniform(_uniformTrailCache.color, _appearance.color);
_trailProgram->setUniform(_uniformTrailCache.inGameTime,
data.time.j2000Seconds());
_trailProgram->setUniform(_uniformTrailCache.modelView,
calcModelViewTransform(data));
_trailProgram->setUniform(_uniformTrailCache.projection,
data.camera.projectionMatrix());
// Because we want the property to work similar to the planet trails
const float fade = pow(
_appearance.trailFade.maxValue() - _appearance.trailFade, 2.f
);
_trailProgram->setUniform(_uniformTrailCache.trailFade, fade);
glLineWidth(_appearance.trailWidth);
glBindVertexArray(_vertexArray);
glMultiDrawArrays(
GL_LINE_STRIP,
_si,
_ss,
static_cast<GLsizei>(_startIndex.size())
);
glBindVertexArray(0);
_trailProgram->deactivate();
}
}
void RenderableOrbitalKepler::updateBuffers() {

View File

@@ -54,6 +54,30 @@ public:
static documentation::Documentation Documentation();
private:
struct Appearance : properties::PropertyOwner {
Appearance();
/// Specifies the base color of the line/point
properties::Vec3Property color;
/// Line width for the line rendering part
properties::FloatProperty trailWidth;
/// Point size exponent for the point rendering part
properties::FloatProperty pointSizeExponent;
/// The option determining which rendering method to use
properties::BoolProperty enableMaxSize;
/// The option enables or disables Max Angular Size limit
properties::FloatProperty maxSize;
/// Max angular size between vector cameraToPoint and edge of the point
properties::OptionProperty renderingModes;
/// Specifies a multiplicative factor that fades out the trail line
properties::FloatProperty trailFade;
/// Specifies if the point outline should be enabled
properties::BoolProperty enableOutline;
/// Specifies the color of the point outline
properties::Vec3Property outlineColor;
/// Specifies how much if the point should be covered by the outline
properties::FloatProperty outlineWeight;
};
void updateBuffers();
bool _updateDataBuffersAtNextRender = false;
@@ -80,14 +104,23 @@ private:
GLuint _vertexArray;
GLuint _vertexBuffer;
ghoul::opengl::ProgramObject* _programObject;
ghoul::opengl::ProgramObject* _trailProgram;
ghoul::opengl::ProgramObject* _pointProgram;
properties::StringProperty _path;
properties::BoolProperty _contiguousMode;
kepler::Format _format;
RenderableTrail::Appearance _appearance;
RenderableOrbitalKepler::Appearance _appearance;
UniformCache(modelView, projection, lineFade, inGameTime, color, opacity,
numberOfSegments) _uniformCache;
// Line cache
UniformCache(modelView, projection, trailFade, inGameTime, color, opacity)
_uniformTrailCache;
// Point cache
UniformCache(modelTransform, viewTransform, projectionTransform,
cameraPositionWorld, cameraUpWorld, inGameTime, color,
pointSizeExponent, enableMaxSize, maxSize, enableOutline,
outlineColor, outlineWeight, opacity)
_uniformPointCache;
};
} // namespace openspace

View File

@@ -0,0 +1,63 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2024 *
* *
* 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 "fragment.glsl"
in float projectionViewDepth;
in vec4 viewSpace;
in vec2 texCoord;
flat in int skip;
uniform bool enableOutline;
uniform vec3 outlineColor;
uniform float outlineWeight;
uniform vec3 color;
uniform float opacity;
Fragment getFragment() {
Fragment frag;
if (skip == 1) {
discard;
}
// Only draw circle instead of entire quad
vec2 st = (texCoord - vec2(0.5)) * 2.0;
if (length(st) > 1.0) {
discard;
}
// Creates outline for circle
vec3 _color = color;
if (enableOutline && (length(st) > (1.0 - outlineWeight) && length(st) < 1.0)) {
_color = outlineColor;
}
frag.color = vec4(_color, opacity);
frag.depth = projectionViewDepth;
frag.gPosition = viewSpace;
frag.gNormal = vec4(0.0, 0.0, 0.0, 1.0);
return frag;
}

View File

@@ -0,0 +1,145 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2024 *
* *
* 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__
#include "PowerScaling/powerScalingMath.hglsl"
layout(lines) in;
flat in double currentRevolutionFraction[];
flat in double vertexRevolutionFraction[];
uniform dmat4 modelTransform;
uniform dmat4 viewTransform;
uniform mat4 projectionTransform;
uniform dvec3 cameraPositionWorld;
uniform dvec3 cameraUpWorld;
uniform float pointSizeExponent;
uniform bool enableMaxSize;
uniform float maxSize;
layout(triangle_strip, max_vertices = 4) out;
out float projectionViewDepth;
out vec4 viewSpace;
out vec2 texCoord;
flat out int skip;
dvec4 dz_normalization(dvec4 dv_in) {
dvec4 dv_out = dv_in;
dv_out.z = 0;
return dv_out;
}
void main() {
skip = 0;
double cFrac = currentRevolutionFraction[0];
double v0Frac = vertexRevolutionFraction[0];
double v1Frac = vertexRevolutionFraction[1];
if (cFrac >= v0Frac && cFrac <= v1Frac) {
// Interpolate position of point
double dFrac = abs(cFrac - v0Frac);
double vFrac = abs(v1Frac - v0Frac);
double percentage = dFrac / vFrac;
dvec4 v0Weighted = (1.0 - percentage) * gl_in[0].gl_Position;
dvec4 v1Weighted = (percentage) * gl_in[1].gl_Position;
dvec4 pos = v0Weighted + v1Weighted;
// ==========================
// Calculate current vertex position to world space
dvec4 vertPosWorldSpace = modelTransform * pos;
// Calculate new axis for plane
dvec3 normal = normalize(cameraPositionWorld - vertPosWorldSpace.xyz);
dvec3 right = normalize(cross(cameraUpWorld, normal));
dvec3 up = normalize(cross(normal, right));
// Calculate size of points
double initialSize = pow(10.0, pointSizeExponent);
right *= initialSize;
up *= initialSize;
double opp = length(right);
double adj = length(cameraPositionWorld.xyz - vertPosWorldSpace.xyz);
float angle = atan(float(opp/adj));
float maxAngle = radians(maxSize * 0.5);
// Controls the point size
if (enableMaxSize && (angle > maxAngle) && (adj > 0.0)) {
double correction = (adj * tan(maxAngle)) / opp;
right *= correction;
up *= correction;
}
// Calculate and set corners of the quad
dvec4 p0World = vertPosWorldSpace + (dvec4(up-right, 0.0));
dvec4 p1World = vertPosWorldSpace + (dvec4(-right-up,0.0));
dvec4 p2World = vertPosWorldSpace + (dvec4(right+up, 0.0));
dvec4 p3World = vertPosWorldSpace + (dvec4(right-up, 0.0));
dmat4 ViewProjectionTransform = dmat4(projectionTransform) * viewTransform;
// Set some additional out parameters
viewSpace = z_normalization(
vec4(projectionTransform * viewTransform * modelTransform * pos)
);
projectionViewDepth = viewSpace.w;
//left-top
vec4 p0Screen = vec4(dz_normalization(ViewProjectionTransform * p0World));
gl_Position = p0Screen;
texCoord = vec2(0.0, 0.0);
EmitVertex();
//left-bot
vec4 p1Screen = vec4(dz_normalization(ViewProjectionTransform * p1World));
gl_Position = p1Screen;
texCoord = vec2(1.0, 0.0);
EmitVertex();
//right-top
vec4 p2Screen = vec4(dz_normalization(ViewProjectionTransform * p2World));
gl_Position = p2Screen;
texCoord = vec2(0.0, 1.0);
EmitVertex();
//right-bot
vec4 p3Screen = vec4(dz_normalization(ViewProjectionTransform * p3World));
gl_Position = p3Screen;
texCoord = vec2(1.0, 1.0);
EmitVertex();
// Primitive
EndPrimitive();
}
else {
skip = 1;
EmitVertex();
EndPrimitive();
}
}

View File

@@ -0,0 +1,48 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2024 *
* *
* 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__
layout (location = 0) in vec4 vertexData; // 1: x, 2: y, 3: z, 4: timeOffset,
layout (location = 1) in vec2 orbitData; // 1: epoch, 2: period
uniform double inGameTime;
uniform dmat4 modelTransform;
flat out double currentRevolutionFraction;
flat out double vertexRevolutionFraction;
void main() {
float epoch = orbitData.x;
float period = orbitData.y;
double numOfRevolutions = (inGameTime - epoch) / period;
vertexRevolutionFraction = vertexData.w / period;
currentRevolutionFraction = numOfRevolutions - double(int(numOfRevolutions));
if (currentRevolutionFraction < 0.0) {
currentRevolutionFraction += 1.0;
}
gl_Position = vec4(vertexData.xyz, 1.0);
}

View File

@@ -31,10 +31,18 @@ in float offsetPeriods;
uniform vec3 color;
uniform float opacity = 1.0;
uniform float lineFade;
uniform float trailFade;
/// Different modes - sync with renderableorbitalkepler.cpp
// RenderingModeLines = 0
// RenderingModePoint = 1
Fragment getFragment() {
Fragment frag;
float invert = 1.0;
float fade = 1.0;
// float offsetPeriods = offset / period;
// This is now done in the fragment shader instead to make smooth movement between
// vertices. We want vertexDistance to be double up to this point, I think, (hence the
@@ -46,26 +54,23 @@ Fragment getFragment() {
// float vertexID_perOrbit = mod(vertexID_f, numberOfSegments);
// float nrOfSegments_f = float(numberOfSegments);
// float vertexDistance = periodFraction - (vertexID_perOrbit/nrOfSegments_f);
if (vertexDistance < 0.0) {
vertexDistance += 1.0;
}
float invert = pow((1.0 - vertexDistance), lineFade);
float fade = clamp(invert, 0.0, 1.0);
invert = pow((1.0 - vertexDistance), trailFade);
fade = clamp(invert, 0.0, 1.0);
// Currently even fully transparent lines can occlude other lines, thus we discard these
// fragments since debris and satellites are rendered so close to each other
if (fade < 0.05) {
discard;
}
Fragment frag;
// Use additive blending for some values to make the discarding less abrupt
if (fade < 0.15) {
// Use additive blending for some values to make the discarding less abrupt
frag.blend = BLEND_MODE_ADDITIVE;
}
frag.color = vec4(color, fade * opacity);
frag.depth = viewSpaceDepth;
frag.gPosition = viewSpacePosition;

View File

@@ -40,7 +40,7 @@ uniform double inGameTime;
void main() {
// The way the position and line fade is calculated is:
// The way the position and trail fade is calculated is:
// By using inGameTime, epoch and period of this orbit, we get how many revolutions it
// has done since epoch. The fract of that, is how far into a revolution it has traveled
// since epoch. Similarly we do the same but for this vertex, but calculating