Removed 4-tuple color in favor of 3-tulpe color plus opacity. Changed abs to fabs when needed.

This commit is contained in:
Jonathas Costa
2020-06-08 13:47:47 -04:00
parent ea72753ea3
commit 4c49cc0fdf
7 changed files with 38 additions and 29 deletions
+10 -5
View File
@@ -24,7 +24,8 @@ local radio = {
Renderable = {
Type = "RenderableSphericalGrid",
Enabled = false,
GridColor = { 0.3, 0.84, 1.0, 0.3},
Opacity = 0.3,
GridColor = { 0.3, 0.84, 1.0},
LineWidth = 2.0,
GridMatrix = { -0.05487554, 0.4941095, -0.8676661 , 0.0,
-0.9938214 , -0.1109906, -0.0003515167, 0.0,
@@ -49,7 +50,8 @@ local oort = {
Renderable = {
Type = "RenderableSphericalGrid",
Enabled = false,
GridColor = { 0.8, 0.4, 0.4, 0.25},
Opacity = 0.25,
GridColor = { 0.8, 0.4, 0.4},
LineWidth = 2.0,
GridMatrix = { -0.05487554, 0.4941095, -0.8676661 , 0.0,
-0.9938214 , -0.1109906, -0.0003515167, 0.0,
@@ -74,7 +76,8 @@ local ecliptic = {
Renderable = {
Type = "RenderableSphericalGrid",
Enabled = false,
GridColor = { 0.74, 0.26, 0.26, 0.5},
Opacity = 0.5,
GridColor = { 0.74, 0.26, 0.26},
LineWidth = 2.0,
GridMatrix = { -0.05487554, 0.4941095, -0.8676661 , 0.0,
-0.9938214 , -0.1109906, -0.0003515167, 0.0,
@@ -127,7 +130,8 @@ local equatorial = {
Renderable = {
Type = "RenderableSphericalGrid",
Enabled = false,
GridColor = { 0.69, 0.68, 0.29, 0.8},
Opacity = 0.8,
GridColor = { 0.69, 0.68, 0.29},
LineWidth = 2.0,
GridMatrix = { -0.05487554, 0.4941095, -0.8676661, 0.0,
-0.8734371 , -0.4448296, -0.1980764, 0.0,
@@ -181,7 +185,8 @@ local galactic = {
Type = "RenderableSphericalGrid",
Enabled = false,
LineWidth = 2.0,
GridColor = { 0.0, 0.6, 0.6, 0.6}
Opacity = 0.6,
GridColor = { 0.0, 0.6, 0.6}
},
GUI = {
Name = "Galactic Sphere",
@@ -80,7 +80,7 @@ documentation::Documentation RenderableSphericalGrid::Documentation() {
},
{
GridColorInfo.identifier,
new DoubleVector4Verifier,
new DoubleVector3Verifier,
Optional::Yes,
GridColorInfo.description
},
@@ -107,9 +107,9 @@ RenderableSphericalGrid::RenderableSphericalGrid(const ghoul::Dictionary& dictio
, _gridMatrix(GridMatrixInfo, glm::mat4(1.f))
, _gridColor(
GridColorInfo,
glm::vec4(0.5f, 0.5, 0.5f, 1.f),
glm::vec4(0.f),
glm::vec4(1.f)
glm::vec3(0.5f, 0.5, 0.5f),
glm::vec3(0.f),
glm::vec3(1.f)
)
, _segments(SegmentsInfo, 36, 4, 200)
, _lineWidth(LineWidthInfo, 0.5f, 0.f, 20.f)
@@ -129,7 +129,7 @@ RenderableSphericalGrid::RenderableSphericalGrid(const ghoul::Dictionary& dictio
addProperty(_gridMatrix);
if (dictionary.hasKey(GridColorInfo.identifier)) {
_gridColor = dictionary.value<glm::vec4>(GridColorInfo.identifier);
_gridColor = dictionary.value<glm::vec3>(GridColorInfo.identifier);
}
_gridColor.setViewOption(properties::Property::ViewOptions::Color);
addProperty(_gridColor);
@@ -233,6 +233,10 @@ void RenderableSphericalGrid::render(const RenderData& data, RendererTasks&){
GLfloat currentLineWidth;
glGetFloatv(GL_LINE_WIDTH, &currentLineWidth);
GLboolean isLineSmoothEnabled = glIsEnabled(GL_LINE_SMOOTH);
GLenum currentDepthFunction;
glGetIntegerv(GL_DEPTH_FUNC, &currentDepthFunction);
glDepthFunc(GL_LEQUAL);
GLenum blendEquationRGB, blendEquationAlpha, blendDestAlpha,
blendDestRGB, blendSrcAlpha, blendSrcRGB;
@@ -268,6 +272,8 @@ void RenderableSphericalGrid::render(const RenderData& data, RendererTasks&){
if (!isLineSmoothEnabled) {
glDisable(GL_LINE_SMOOTH);
}
glDepthFunc(currentDepthFunction);
}
void RenderableSphericalGrid::update(const UpdateData&) {
@@ -31,7 +31,7 @@
#include <openspace/properties/matrix/dmat4property.h>
#include <openspace/properties/scalar/floatproperty.h>
#include <openspace/properties/scalar/intproperty.h>
#include <openspace/properties/vector/vec4property.h>
#include <openspace/properties/vector/vec3property.h>
#include <ghoul/opengl/ghoul_gl.h>
namespace ghoul::opengl { class ProgramObject; }
@@ -63,7 +63,7 @@ protected:
ghoul::opengl::ProgramObject* _gridProgram;
properties::DMat4Property _gridMatrix;
properties::Vec4Property _gridColor;
properties::Vec3Property _gridColor;
properties::IntProperty _segments;
properties::FloatProperty _lineWidth;
+6 -6
View File
@@ -25,18 +25,18 @@
#include "fragment.glsl"
#include "PowerScaling/powerScaling_fs.hglsl"
in float vs_screenSpaceDepth;
in float vs_depthClipSpace;
in vec4 vs_positionViewSpace;
uniform vec4 gridColor;
uniform vec3 gridColor;
uniform float opacity;
Fragment getFragment() {
Fragment frag;
frag.color = gridColor;
frag.color.a *= opacity;
frag.depth = vs_screenSpaceDepth;
frag.gPosition = vs_positionViewSpace;
frag.color.rgb = gridColor;
frag.color.a = opacity;
frag.depth = vs_depthClipSpace;
frag.gPosition = vs_positionViewSpace;
// There is no normal here
frag.gNormal = vec4(0.0, 0.0, -1.0, 1.0);
+6 -8
View File
@@ -28,23 +28,21 @@
layout(location = 0) in vec3 in_position;
out float vs_screenSpaceDepth;
out float vs_depthClipSpace;
out vec4 vs_positionViewSpace;
uniform dmat4 modelViewTransform;
uniform dmat4 MVPTransform;
void main() {
dvec4 objPosDouble = dvec4(in_position, 1.0);
dvec4 positionViewSpace = modelViewTransform * objPosDouble;
dvec4 positionClipSpace = MVPTransform * objPosDouble;
dvec4 objPosDouble = dvec4(in_position, 1.0);
dvec4 positionViewSpace = modelViewTransform * objPosDouble;
dvec4 positionClipSpace = MVPTransform * objPosDouble;
positionClipSpace.z = 0.0;
vec4 positionScreenSpace = vec4(positionClipSpace);
vs_screenSpaceDepth = float(positionClipSpace.w);
vs_depthClipSpace = float(positionClipSpace.w);
vs_positionViewSpace = vec4(positionViewSpace);
gl_Position = positionScreenSpace;
gl_Position = vec4(positionClipSpace);
}
+2 -2
View File
@@ -735,13 +735,13 @@ void SceneGraphNode::computeScreenSpaceData(RenderData& newData) {
);
constexpr const double RadiusThreshold = 2.0;
const double r = abs(_screenSizeRadius - screenSpaceRadius);
const double r = std::fabs(_screenSizeRadius - screenSpaceRadius);
if (r > RadiusThreshold) {
_screenSizeRadius = screenSpaceRadius;
}
constexpr const double ZoomThreshold = 0.1;
const double d = abs(_distFromCamToNode - distFromCamToNode);
const double d = std::fabs(_distFromCamToNode - distFromCamToNode);
if (d > (ZoomThreshold * distFromCamToNode)) {
_distFromCamToNode = distFromCamToNode;
}