mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-06 11:39:49 -06:00
Use new fade property for opacity of points
And remove a bunch of trailing whitespaces... (done on save)
This commit is contained in:
@@ -49,8 +49,8 @@ const std::string STRING_NOT_SET = "<string not set>";
|
||||
namespace {
|
||||
constexpr const char* _loggerCat = "PointsCloud";
|
||||
|
||||
constexpr const std::array<const char*, 20> UniformNames = {
|
||||
"color", "size", "modelMatrix", "cameraUp", "screenSize",
|
||||
constexpr const std::array<const char*, 21> UniformNames = {
|
||||
"color", "fade", "size", "modelMatrix", "cameraUp", "screenSize",
|
||||
"cameraViewProjectionMatrix", "eyePosition", "sizeOption",
|
||||
"colormapTexture", "colormapMin", "colormapMax", "colormapNanMode",
|
||||
"colormapNanColor", "colormapEnabled", "linearSizeMin", "linearSizeMax",
|
||||
@@ -74,7 +74,7 @@ namespace {
|
||||
"Identifier",
|
||||
"Identifier used as part of key to access data in centralized central storage."
|
||||
};
|
||||
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo PointUnitInfo = {
|
||||
"PointUnit",
|
||||
"Point Unit",
|
||||
@@ -146,13 +146,13 @@ namespace {
|
||||
"Velocity Time Unit",
|
||||
"The time unit of the velocity data."
|
||||
};
|
||||
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo VelocityDateRecordedInfo = {
|
||||
"VelocityDateRecorded",
|
||||
"Velocity Date Recorded",
|
||||
"The date the velocity data was recorded."
|
||||
};
|
||||
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo VelocityNanModeInfo = {
|
||||
"VelocityNanMode",
|
||||
"Velocity NaN Mode",
|
||||
@@ -222,7 +222,7 @@ namespace {
|
||||
|
||||
// [[codegen::verbatim(MotionEnabledInfo.description)]]
|
||||
std::optional<bool> motionEnabled;
|
||||
|
||||
|
||||
// [[codegen::verbatim(NameInfo.description)]]
|
||||
std::optional<std::string> name;
|
||||
|
||||
@@ -269,7 +269,7 @@ RenderablePointsCloud::RenderablePointsCloud(const ghoul::Dictionary& dictionary
|
||||
const Parameters p = codegen::bake<Parameters>(dictionary);
|
||||
|
||||
_identifier = p.identifier.value();
|
||||
|
||||
|
||||
_name = p.name.value_or(_name);
|
||||
_name.setVisibility(properties::Property::Visibility::Hidden);
|
||||
addProperty(_name);
|
||||
@@ -278,6 +278,8 @@ RenderablePointsCloud::RenderablePointsCloud(const ghoul::Dictionary& dictionary
|
||||
_color.setViewOption(properties::Property::ViewOptions::Color);
|
||||
addProperty(_color);
|
||||
|
||||
addProperty(_fade);
|
||||
|
||||
_size = p.size.value_or(_size);
|
||||
addProperty(_size);
|
||||
|
||||
@@ -465,6 +467,7 @@ void RenderablePointsCloud::render(const RenderData& data, RendererTasks&) {
|
||||
);
|
||||
|
||||
_shaderProgram->setUniform(_uniformCache.color, _color);
|
||||
_shaderProgram->setUniform(_uniformCache.fade, _fade);
|
||||
|
||||
_shaderProgram->setUniform(_uniformCache.size, _size);
|
||||
_shaderProgram->setUniform(_uniformCache.sizeOption, _sizeOption);
|
||||
@@ -571,7 +574,7 @@ void RenderablePointsCloud::update(const UpdateData&) {
|
||||
nullptr
|
||||
);
|
||||
|
||||
if (_hasLoadedColormapAttributeData) {
|
||||
if (_hasLoadedColormapAttributeData) {
|
||||
GLint colormapScalarsAttribute = _shaderProgram->attributeLocation("in_colormapAttributeScalar");
|
||||
glEnableVertexAttribArray(colormapScalarsAttribute);
|
||||
glVertexAttribPointer(
|
||||
@@ -584,7 +587,7 @@ void RenderablePointsCloud::update(const UpdateData&) {
|
||||
);
|
||||
}
|
||||
|
||||
if (_hasLoadedLinearSizeAttributeData) {
|
||||
if (_hasLoadedLinearSizeAttributeData) {
|
||||
GLint linearSizeAttributeScalar = _shaderProgram->attributeLocation("in_linearSizeAttributeScalar");
|
||||
glEnableVertexAttribArray(linearSizeAttributeScalar);
|
||||
glVertexAttribPointer(
|
||||
@@ -597,7 +600,7 @@ void RenderablePointsCloud::update(const UpdateData&) {
|
||||
);
|
||||
}
|
||||
|
||||
if (_hasLoadedVelocityData) {
|
||||
if (_hasLoadedVelocityData) {
|
||||
GLint velocityAttribute = _shaderProgram->attributeLocation("in_velocity");
|
||||
glEnableVertexAttribArray(velocityAttribute);
|
||||
glVertexAttribPointer(
|
||||
@@ -656,7 +659,7 @@ bool RenderablePointsCloud::checkDataStorage() {
|
||||
|
||||
void RenderablePointsCloud::loadPointData(SoftwareIntegrationModule* softwareIntegrationModule) {
|
||||
// Fetch point data from module's centralized storage
|
||||
std::vector<float> pointData;
|
||||
std::vector<float> pointData;
|
||||
if (!softwareIntegrationModule->fetchData(_identifier.value(), storage::Key::DataPoints, pointData)) {
|
||||
LERROR("There was an issue trying to fetch the point data from the centralized storage.");
|
||||
return;
|
||||
@@ -688,7 +691,7 @@ void RenderablePointsCloud::loadPointData(SoftwareIntegrationModule* softwareInt
|
||||
value *= toMeters;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Assign point data to point data slice
|
||||
auto pointDataSlice = getDataSlice(DataSliceKey::Points);
|
||||
pointDataSlice->clear();
|
||||
@@ -697,7 +700,7 @@ void RenderablePointsCloud::loadPointData(SoftwareIntegrationModule* softwareInt
|
||||
softwareIntegrationModule->setDataLoaded(_identifier.value(), storage::Key::DataPoints);
|
||||
LINFO(fmt::format(
|
||||
"New point data ({} points) has loaded. {} values are NaN values. "
|
||||
"Points with at least one NaN value are hidden.",
|
||||
"Points with at least one NaN value are hidden.",
|
||||
(pointData.size() / 3), nNans
|
||||
));
|
||||
}
|
||||
@@ -771,7 +774,7 @@ void RenderablePointsCloud::loadVelocityData(SoftwareIntegrationModule* software
|
||||
auto velocityDataSlice = getDataSlice(DataSliceKey::Velocity);
|
||||
velocityDataSlice->clear();
|
||||
velocityDataSlice->assign(velocityData.begin(), velocityData.end());
|
||||
|
||||
|
||||
LINFO(
|
||||
fmt::format(
|
||||
"Viewing {} points with velocity ({} points in total). "
|
||||
@@ -964,7 +967,7 @@ bool RenderablePointsCloud::shouldLoadVelocityData(SoftwareIntegrationModule* so
|
||||
(
|
||||
_velocityUnitsAreDirty
|
||||
|| softwareIntegrationModule->isDataDirty(_identifier.value(), storage::Key::VelocityData)
|
||||
)
|
||||
)
|
||||
&& _velocityDistanceUnit.value() != STRING_NOT_SET
|
||||
&& _velocityTimeUnit.value() != STRING_NOT_SET
|
||||
);
|
||||
|
||||
@@ -86,7 +86,7 @@ private:
|
||||
|
||||
std::unique_ptr<ghoul::opengl::ProgramObject> _shaderProgram = nullptr;
|
||||
UniformCache(
|
||||
color, size, modelMatrix, cameraUp, screenSize,
|
||||
color, fade, size, modelMatrix, cameraUp, screenSize,
|
||||
cameraViewProjectionMatrix, eyePosition, sizeOption,
|
||||
colormapTexture, colormapMin, colormapMax, colormapNanMode,
|
||||
colormapNanColor, colormapEnabled, linearSizeMin, linearSizeMax,
|
||||
@@ -115,8 +115,8 @@ private:
|
||||
properties::StringProperty _velocityTimeUnit;
|
||||
properties::IVec3Property _velocityDateRecorded;
|
||||
properties::IntProperty _velocityNanMode;
|
||||
|
||||
|
||||
|
||||
|
||||
std::optional<std::string> _identifier = std::nullopt;
|
||||
|
||||
bool _pointUnitIsDirty = false;
|
||||
@@ -125,7 +125,7 @@ private:
|
||||
bool _hasLoadedColormap = false;
|
||||
|
||||
bool _hasLoadedLinearSizeAttributeData = false;
|
||||
|
||||
|
||||
double _t0 = 0.0;
|
||||
bool _velocityDateIsDirty = false;
|
||||
bool _velocityUnitsAreDirty = false;
|
||||
|
||||
@@ -40,6 +40,7 @@ in float ta;
|
||||
in vec3 ge_velocity;
|
||||
|
||||
uniform vec4 color;
|
||||
uniform float fade;
|
||||
|
||||
uniform float colormapMin;
|
||||
uniform float colormapMax;
|
||||
@@ -67,25 +68,25 @@ Fragment getFragment() {
|
||||
discard;
|
||||
}
|
||||
|
||||
// Don't show points with no value for that
|
||||
// Don't show points with no value for that
|
||||
// attribute, if ColormapNanRenderMode is Hidden
|
||||
if (
|
||||
colormapEnabled
|
||||
&& isnan(ge_colormapAttributeScalar)
|
||||
colormapEnabled
|
||||
&& isnan(ge_colormapAttributeScalar)
|
||||
&& colormapNanMode == COLORMAPNANMODE_HIDDEN
|
||||
) {
|
||||
discard;
|
||||
}
|
||||
|
||||
|
||||
// ========== Velocity NaN mode ==========
|
||||
// Don't show points with no value for
|
||||
// Don't show points with no value for
|
||||
// velocity, if VelocityNanRenderMode is Hidden
|
||||
bool velocityIsNan = (isnan(ge_velocity[0]) ||
|
||||
isnan(ge_velocity[1]) ||
|
||||
isnan(ge_velocity[2]));
|
||||
if (motionEnabled &&
|
||||
velocityIsNan &&
|
||||
velocityNanMode == VELOCITYNANMODE_HIDDEN)
|
||||
if (motionEnabled &&
|
||||
velocityIsNan &&
|
||||
velocityNanMode == VELOCITYNANMODE_HIDDEN)
|
||||
{
|
||||
discard;
|
||||
} // else the point is left static
|
||||
@@ -99,7 +100,7 @@ Fragment getFragment() {
|
||||
|
||||
vec4 outputColor = color;
|
||||
if (colormapEnabled) {
|
||||
// Set colormapNanColor if point doesn't have a value for the attribute
|
||||
// Set colormapNanColor if point doesn't have a value for the attribute
|
||||
if (isnan(ge_colormapAttributeScalar) && colormapNanMode == COLORMAPNANMODE_COLOR) {
|
||||
outputColor = vec4(colormapNanColor.rgb, colormapNanColor.a);
|
||||
}
|
||||
@@ -109,6 +110,8 @@ Fragment getFragment() {
|
||||
}
|
||||
}
|
||||
|
||||
outputColor.a *= fade;
|
||||
|
||||
Fragment frag;
|
||||
frag.color = outputColor * vec4(circle);
|
||||
frag.depth = ge_screenSpaceDepth;
|
||||
|
||||
Reference in New Issue
Block a user