mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-27 14:29:37 -05:00
Merge branch 'master' into feature/model-opacity
* Resolve conflicts in shaders for models and modelprojections
This commit is contained in:
@@ -54,14 +54,7 @@ namespace {
|
||||
"This value species the size of each dimensions of the box"
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo DrawLabelInfo = {
|
||||
"DrawLabels",
|
||||
"Draw Labels",
|
||||
"Determines whether labels should be drawn or hidden"
|
||||
};
|
||||
|
||||
static const openspace::properties::PropertyOwner::PropertyOwnerInfo LabelsInfo =
|
||||
{
|
||||
static const openspace::properties::PropertyOwner::PropertyOwnerInfo LabelsInfo = {
|
||||
"Labels",
|
||||
"Labels",
|
||||
"The labels for the grid"
|
||||
@@ -77,9 +70,6 @@ namespace {
|
||||
// [[codegen::verbatim(SizeInfo.description)]]
|
||||
std::optional<glm::vec3> size;
|
||||
|
||||
// [[codegen::verbatim(DrawLabelInfo.description)]]
|
||||
std::optional<bool> drawLabels;
|
||||
|
||||
// [[codegen::verbatim(LabelsInfo.description)]]
|
||||
std::optional<ghoul::Dictionary> labels
|
||||
[[codegen::reference("space_labelscomponent")]];
|
||||
@@ -98,7 +88,6 @@ RenderableBoxGrid::RenderableBoxGrid(const ghoul::Dictionary& dictionary)
|
||||
, _color(ColorInfo, glm::vec3(0.5f), glm::vec3(0.f), glm::vec3(1.f))
|
||||
, _lineWidth(LineWidthInfo, 0.5f, 1.f, 20.f)
|
||||
, _size(SizeInfo, glm::vec3(1.f), glm::vec3(1.f), glm::vec3(100.f))
|
||||
, _drawLabels(DrawLabelInfo, false)
|
||||
{
|
||||
const Parameters p = codegen::bake<Parameters>(dictionary);
|
||||
|
||||
@@ -117,12 +106,11 @@ RenderableBoxGrid::RenderableBoxGrid(const ghoul::Dictionary& dictionary)
|
||||
addProperty(_size);
|
||||
|
||||
if (p.labels.has_value()) {
|
||||
_drawLabels = p.drawLabels.value_or(_drawLabels);
|
||||
addProperty(_drawLabels);
|
||||
|
||||
_labels = std::make_unique<LabelsComponent>(*p.labels);
|
||||
_hasLabels = true;
|
||||
addPropertySubOwner(_labels.get());
|
||||
// Fading of the labels should also depend on the fading of the renderable
|
||||
_labels->setParentFadeable(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,7 +203,7 @@ void RenderableBoxGrid::render(const RenderData& data, RendererTasks&){
|
||||
global::renderEngine->openglStateCache().resetDepthState();
|
||||
|
||||
// Draw labels
|
||||
if (_drawLabels && _hasLabels) {
|
||||
if (_hasLabels && _labels->enabled()) {
|
||||
const glm::vec3 lookup = data.camera.lookUpVectorWorldSpace();
|
||||
const glm::vec3 viewDirection = data.camera.viewDirectionWorldSpace();
|
||||
glm::vec3 right = glm::cross(viewDirection, lookup);
|
||||
|
||||
@@ -76,7 +76,6 @@ protected:
|
||||
|
||||
// Labels
|
||||
bool _hasLabels = false;
|
||||
properties::BoolProperty _drawLabels;
|
||||
std::unique_ptr<LabelsComponent> _labels;
|
||||
};
|
||||
|
||||
|
||||
@@ -81,14 +81,7 @@ namespace {
|
||||
"This value species the size of each dimensions of the grid"
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo DrawLabelInfo = {
|
||||
"DrawLabels",
|
||||
"Draw Labels",
|
||||
"Determines whether labels should be drawn or hidden"
|
||||
};
|
||||
|
||||
static const openspace::properties::PropertyOwner::PropertyOwnerInfo LabelsInfo =
|
||||
{
|
||||
static const openspace::properties::PropertyOwner::PropertyOwnerInfo LabelsInfo = {
|
||||
"Labels",
|
||||
"Labels",
|
||||
"The labels for the grid"
|
||||
@@ -116,9 +109,6 @@ namespace {
|
||||
// [[codegen::verbatim(SizeInfo.description)]]
|
||||
std::optional<glm::vec2> size;
|
||||
|
||||
// [[codegen::verbatim(DrawLabelInfo.description)]]
|
||||
std::optional<bool> drawLabels;
|
||||
|
||||
// [[codegen::verbatim(LabelsInfo.description)]]
|
||||
std::optional<ghoul::Dictionary> labels
|
||||
[[codegen::reference("space_labelscomponent")]];
|
||||
@@ -141,7 +131,6 @@ RenderableGrid::RenderableGrid(const ghoul::Dictionary& dictionary)
|
||||
, _lineWidth(LineWidthInfo, 0.5f, 1.f, 20.f)
|
||||
, _highlightLineWidth(HighlightLineWidthInfo, 0.5f, 1.f, 20.f)
|
||||
, _size(SizeInfo, glm::vec2(1.f), glm::vec2(1.f), glm::vec2(1e11f))
|
||||
, _drawLabels(DrawLabelInfo, false)
|
||||
{
|
||||
const Parameters p = codegen::bake<Parameters>(dictionary);
|
||||
|
||||
@@ -178,12 +167,11 @@ RenderableGrid::RenderableGrid(const ghoul::Dictionary& dictionary)
|
||||
addProperty(_size);
|
||||
|
||||
if (p.labels.has_value()) {
|
||||
_drawLabels = p.drawLabels.value_or(_drawLabels);
|
||||
addProperty(_drawLabels);
|
||||
|
||||
_labels = std::make_unique<LabelsComponent>(*p.labels);
|
||||
_hasLabels = true;
|
||||
addPropertySubOwner(_labels.get());
|
||||
// Fading of the labels should also depend on the fading of the renderable
|
||||
_labels->setParentFadeable(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -314,11 +302,11 @@ void RenderableGrid::render(const RenderData& data, RendererTasks&){
|
||||
global::renderEngine->openglStateCache().resetDepthState();
|
||||
|
||||
// Draw labels
|
||||
if (_drawLabels && _hasLabels) {
|
||||
if (_hasLabels && _labels->enabled()) {
|
||||
const glm::vec3 orthoUp = glm::normalize(
|
||||
glm::vec3(worldToModelTransform * glm::dvec4(up, 0.0))
|
||||
);
|
||||
_labels->render(data, modelViewProjectionMatrix, orthoRight, orthoUp);
|
||||
_labels->render(data, modelViewProjectionMatrix, orthoRight, orthoUp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -85,7 +85,6 @@ protected:
|
||||
|
||||
// Labels
|
||||
bool _hasLabels = false;
|
||||
properties::BoolProperty _drawLabels;
|
||||
std::unique_ptr<LabelsComponent> _labels;
|
||||
};
|
||||
|
||||
|
||||
@@ -71,14 +71,7 @@ namespace {
|
||||
"ring"
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo DrawLabelInfo = {
|
||||
"DrawLabels",
|
||||
"Draw Labels",
|
||||
"Determines whether labels should be drawn or hidden"
|
||||
};
|
||||
|
||||
static const openspace::properties::PropertyOwner::PropertyOwnerInfo LabelsInfo =
|
||||
{
|
||||
static const openspace::properties::PropertyOwner::PropertyOwnerInfo LabelsInfo = {
|
||||
"Labels",
|
||||
"Labels",
|
||||
"The labels for the grid"
|
||||
@@ -100,9 +93,6 @@ namespace {
|
||||
// [[codegen::verbatim(RadiiInfo.description)]]
|
||||
std::optional<glm::vec2> radii;
|
||||
|
||||
// [[codegen::verbatim(DrawLabelInfo.description)]]
|
||||
std::optional<bool> drawLabels;
|
||||
|
||||
// [[codegen::verbatim(LabelsInfo.description)]]
|
||||
std::optional<ghoul::Dictionary> labels
|
||||
[[codegen::reference("space_labelscomponent")]];
|
||||
@@ -123,7 +113,6 @@ RenderableRadialGrid::RenderableRadialGrid(const ghoul::Dictionary& dictionary)
|
||||
, _circleSegments(CircleSegmentsInfo, 36, 4, 200)
|
||||
, _lineWidth(LineWidthInfo, 0.5f, 1.f, 20.f)
|
||||
, _radii(RadiiInfo, glm::vec2(0.f, 1.f), glm::vec2(0.f), glm::vec2(20.f))
|
||||
, _drawLabels(DrawLabelInfo, false)
|
||||
{
|
||||
const Parameters p = codegen::bake<Parameters>(dictionary);
|
||||
|
||||
@@ -157,12 +146,11 @@ RenderableRadialGrid::RenderableRadialGrid(const ghoul::Dictionary& dictionary)
|
||||
addProperty(_radii);
|
||||
|
||||
if (p.labels.has_value()) {
|
||||
_drawLabels = p.drawLabels.value_or(_drawLabels);
|
||||
addProperty(_drawLabels);
|
||||
|
||||
_labels = std::make_unique<LabelsComponent>(*p.labels);
|
||||
_hasLabels = true;
|
||||
addPropertySubOwner(_labels.get());
|
||||
// Fading of the labels should also depend on the fading of the renderable
|
||||
_labels->setParentFadeable(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -244,7 +232,7 @@ void RenderableRadialGrid::render(const RenderData& data, RendererTasks&) {
|
||||
global::renderEngine->openglStateCache().resetDepthState();
|
||||
|
||||
// Draw labels
|
||||
if (_drawLabels && _hasLabels) {
|
||||
if (_hasLabels && _labels->enabled()) {
|
||||
const glm::vec3 lookup = data.camera.lookUpVectorWorldSpace();
|
||||
const glm::vec3 viewDirection = data.camera.viewDirectionWorldSpace();
|
||||
glm::vec3 right = glm::cross(viewDirection, lookup);
|
||||
|
||||
@@ -90,7 +90,6 @@ protected:
|
||||
|
||||
// Labels
|
||||
bool _hasLabels = false;
|
||||
properties::BoolProperty _drawLabels;
|
||||
std::unique_ptr<LabelsComponent> _labels;
|
||||
};
|
||||
|
||||
|
||||
@@ -55,14 +55,7 @@ namespace {
|
||||
"This value specifies the line width of the spherical grid"
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo DrawLabelInfo = {
|
||||
"DrawLabels",
|
||||
"Draw Labels",
|
||||
"Determines whether labels should be drawn or hidden"
|
||||
};
|
||||
|
||||
static const openspace::properties::PropertyOwner::PropertyOwnerInfo LabelsInfo =
|
||||
{
|
||||
static const openspace::properties::PropertyOwner::PropertyOwnerInfo LabelsInfo = {
|
||||
"Labels",
|
||||
"Labels",
|
||||
"The labels for the grid"
|
||||
@@ -78,9 +71,6 @@ namespace {
|
||||
// [[codegen::verbatim(LineWidthInfo.description)]]
|
||||
std::optional<float> lineWidth;
|
||||
|
||||
// [[codegen::verbatim(DrawLabelInfo.description)]]
|
||||
std::optional<bool> drawLabels;
|
||||
|
||||
// [[codegen::verbatim(LabelsInfo.description)]]
|
||||
std::optional<ghoul::Dictionary> labels
|
||||
[[codegen::reference("space_labelscomponent")]];
|
||||
@@ -100,7 +90,6 @@ RenderableSphericalGrid::RenderableSphericalGrid(const ghoul::Dictionary& dictio
|
||||
, _color(ColorInfo, glm::vec3(0.5f), glm::vec3(0.f), glm::vec3(1.f))
|
||||
, _segments(SegmentsInfo, 36, 4, 200)
|
||||
, _lineWidth(LineWidthInfo, 0.5f, 1.f, 20.f)
|
||||
, _drawLabels(DrawLabelInfo, false)
|
||||
{
|
||||
const Parameters p = codegen::bake<Parameters>(dictionary);
|
||||
|
||||
@@ -127,12 +116,11 @@ RenderableSphericalGrid::RenderableSphericalGrid(const ghoul::Dictionary& dictio
|
||||
setBoundingSphere(1.0);
|
||||
|
||||
if (p.labels.has_value()) {
|
||||
_drawLabels = p.drawLabels.value_or(_drawLabels);
|
||||
addProperty(_drawLabels);
|
||||
|
||||
_labels = std::make_unique<LabelsComponent>(*p.labels);
|
||||
_hasLabels = true;
|
||||
addPropertySubOwner(_labels.get());
|
||||
// Fading of the labels should also depend on the fading of the renderable
|
||||
_labels->setParentFadeable(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -232,7 +220,7 @@ void RenderableSphericalGrid::render(const RenderData& data, RendererTasks&){
|
||||
global::renderEngine->openglStateCache().resetDepthState();
|
||||
|
||||
// Draw labels
|
||||
if (_drawLabels && _hasLabels) {
|
||||
if (_hasLabels && _labels->enabled()) {
|
||||
const glm::vec3 lookup = data.camera.lookUpVectorWorldSpace();
|
||||
const glm::vec3 viewDirection = data.camera.viewDirectionWorldSpace();
|
||||
glm::vec3 right = glm::cross(viewDirection, lookup);
|
||||
|
||||
@@ -80,7 +80,6 @@ protected:
|
||||
|
||||
// Labels
|
||||
bool _hasLabels = false;
|
||||
properties::BoolProperty _drawLabels;
|
||||
std::unique_ptr<LabelsComponent> _labels;
|
||||
};
|
||||
|
||||
|
||||
@@ -208,23 +208,23 @@ void RenderableTrailTrajectory::update(const UpdateData& data) {
|
||||
_totalSampleInterval = _sampleInterval / _timeStampSubsamplingFactor;
|
||||
|
||||
// Cap _numberOfVertices in order to prevent overflow and extreme performance
|
||||
// degredation/RAM usage
|
||||
// degredation/RAM usage
|
||||
_numberOfVertices = std::min(
|
||||
static_cast<unsigned int>(timespan / _totalSampleInterval),
|
||||
maxNumberOfVertices
|
||||
);
|
||||
|
||||
// We need to recalcuate the _totalSampleInterval if _numberOfVertices eqals
|
||||
// maxNumberOfVertices. If we don't do this the position for each vertex
|
||||
// maxNumberOfVertices. If we don't do this the position for each vertex
|
||||
// will not be correct for the number of vertices we are doing along the trail.
|
||||
_totalSampleInterval = (_numberOfVertices == maxNumberOfVertices) ?
|
||||
_totalSampleInterval = (_numberOfVertices == maxNumberOfVertices) ?
|
||||
(timespan / _numberOfVertices) : _totalSampleInterval;
|
||||
|
||||
// Make space for the vertices
|
||||
_vertexArray.clear();
|
||||
_vertexArray.resize(_numberOfVertices);
|
||||
}
|
||||
|
||||
|
||||
// Calculate sweeping range for this iteration
|
||||
unsigned int startIndex = _sweepIteration * _sweepChunkSize;
|
||||
unsigned int nextIndex = (_sweepIteration + 1) * _sweepChunkSize;
|
||||
@@ -249,12 +249,12 @@ void RenderableTrailTrajectory::update(const UpdateData& data) {
|
||||
_sweepIteration = 0;
|
||||
setBoundingSphere(glm::distance(_maxVertex, _minVertex) / 2.f);
|
||||
}
|
||||
else {
|
||||
// Early return as we don't need to render if we are still
|
||||
else {
|
||||
// Early return as we don't need to render if we are still
|
||||
// doing full sweep calculations
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Upload vertices to the GPU
|
||||
glBindVertexArray(_primaryRenderInformation._vaoID);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _primaryRenderInformation._vBufferID);
|
||||
|
||||
@@ -60,7 +60,7 @@ public:
|
||||
static documentation::Documentation Documentation();
|
||||
|
||||
private:
|
||||
|
||||
|
||||
/// Reset some variables to default state
|
||||
void reset();
|
||||
|
||||
@@ -95,7 +95,7 @@ private:
|
||||
/// Tracks sweep iteration, is used to calculate which vertices to work on per frame
|
||||
int _sweepIteration = 0;
|
||||
|
||||
/// How many points do we need to compute given the distance between the
|
||||
/// How many points do we need to compute given the distance between the
|
||||
/// start and end date and the desired sample interval
|
||||
unsigned int _numberOfVertices = 0;
|
||||
|
||||
|
||||
@@ -56,15 +56,15 @@ void main() {
|
||||
vs_normalViewSpace =
|
||||
normalize(mat3(normalTransform) * (mat3(meshNormalTransform) * in_normal));
|
||||
|
||||
// TBN matrix for normal mapping
|
||||
vec3 T = normalize(mat3(normalTransform) * (mat3(meshNormalTransform) * in_tangent));
|
||||
vec3 N = normalize(mat3(normalTransform) * (mat3(meshNormalTransform) * in_normal));
|
||||
// TBN matrix for normal mapping
|
||||
vec3 T = normalize(mat3(normalTransform) * (mat3(meshNormalTransform) * in_tangent));
|
||||
vec3 N = normalize(mat3(normalTransform) * (mat3(meshNormalTransform) * in_normal));
|
||||
|
||||
// Re-orthogonalize T with respect to N
|
||||
T = normalize(T - dot(T, N) * N);
|
||||
// Re-orthogonalize T with respect to N
|
||||
T = normalize(T - dot(T, N) * N);
|
||||
|
||||
// Retrieve perpendicular vector B with cross product of T and N
|
||||
vec3 B = normalize(cross(N, T));
|
||||
// Retrieve perpendicular vector B with cross product of T and N
|
||||
vec3 B = normalize(cross(N, T));
|
||||
|
||||
vs_TBN = mat3(T, B, N);
|
||||
vs_TBN = mat3(T, B, N);
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ uniform vec3 color;
|
||||
uniform int renderPhase;
|
||||
uniform float opacity = 1.0;
|
||||
|
||||
// Fragile! Keep in sync with RenderableTrail::render::RenderPhase
|
||||
// Fragile! Keep in sync with RenderableTrail::render::RenderPhase
|
||||
#define RenderPhaseLines 0
|
||||
#define RenderPhasePoints 1
|
||||
|
||||
@@ -49,7 +49,7 @@ Fragment getFragment() {
|
||||
// Use the length of the vector (dot(circCoord, circCoord)) as factor in the
|
||||
// smoothstep to gradually decrease the alpha on the edges of the point
|
||||
vec2 circCoord = 2.0 * gl_PointCoord - 1.0;
|
||||
//float circleClipping = 1.0 - smoothstep(1.0 - Delta, 1.0, dot(circCoord, circCoord));
|
||||
//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) {
|
||||
|
||||
@@ -67,7 +67,7 @@ void main() {
|
||||
id = 1.0 - id;
|
||||
}
|
||||
|
||||
fade = clamp(id * lineFade, 0.0, 1.0);
|
||||
fade = clamp(id * lineFade, 0.0, 1.0);
|
||||
}
|
||||
else {
|
||||
fade = 1.0;
|
||||
@@ -76,8 +76,8 @@ void main() {
|
||||
vs_gPosition = vec4(modelViewTransform * dvec4(in_point_position, 1));
|
||||
vec4 vs_positionClipSpace = projectionTransform * vs_gPosition;
|
||||
vs_positionDepth = vs_positionClipSpace.w;
|
||||
|
||||
gl_PointSize = (stride == 1 || int(modId) % stride == 0) ?
|
||||
|
||||
gl_PointSize = (stride == 1 || int(modId) % stride == 0) ?
|
||||
float(pointSize) : float(pointSize) / 2;
|
||||
gl_Position = z_normalization(vs_positionClipSpace);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ uniform float opacity = 1.0;
|
||||
uniform float lineWidth;
|
||||
uniform vec4 viewport;
|
||||
|
||||
// Fragile! Keep in sync with RenderableTrail::render::RenderPhase
|
||||
// Fragile! Keep in sync with RenderableTrail::render::RenderPhase
|
||||
const int RenderPhaseLines = 0;
|
||||
const int RenderPhasePoints = 1;
|
||||
|
||||
@@ -52,7 +52,7 @@ Fragment getFragment() {
|
||||
// Use the length of the vector (dot(circCoord, circCoord)) as factor in the
|
||||
// smoothstep to gradually decrease the alpha on the edges of the point
|
||||
vec2 circCoord = 2.0 * gl_PointCoord - 1.0;
|
||||
//float circleClipping = 1.0 - smoothstep(1.0 - Delta, 1.0, dot(circCoord, circCoord));
|
||||
//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) {
|
||||
@@ -71,7 +71,7 @@ Fragment getFragment() {
|
||||
double distanceCenter = length(mathLine - xy);
|
||||
double dLW = double(lineWidth);
|
||||
const float blendFactor = 20.0;
|
||||
|
||||
|
||||
if (distanceCenter > dLW) {
|
||||
frag.color.a = 0.0;
|
||||
}
|
||||
@@ -80,7 +80,7 @@ Fragment getFragment() {
|
||||
}
|
||||
|
||||
frag.gPosition = vs_gPosition;
|
||||
|
||||
|
||||
// There is no normal here
|
||||
frag.gNormal = vec4(0.0, 0.0, -1.0, 1.0);
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ void main() {
|
||||
id = 1.0 - id;
|
||||
}
|
||||
|
||||
fade = clamp(id * lineFade, 0.0, 1.0);
|
||||
fade = clamp(id * lineFade, 0.0, 1.0);
|
||||
}
|
||||
else {
|
||||
fade = 1.0;
|
||||
@@ -78,8 +78,8 @@ void main() {
|
||||
vec4 vs_positionClipSpace = projectionTransform * vs_gPosition;
|
||||
vec4 vs_positionNDC = vs_positionClipSpace / vs_positionClipSpace.w;
|
||||
vs_positionDepth = vs_positionClipSpace.w;
|
||||
|
||||
gl_PointSize = (stride == 1 || int(modId) % stride == 0) ?
|
||||
|
||||
gl_PointSize = (stride == 1 || int(modId) % stride == 0) ?
|
||||
float(pointSize) : float(pointSize) / 2;
|
||||
gl_Position = z_normalization(vs_positionClipSpace);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user