Small grid renderable updates/fixes (#1473)

* Make sure we have examples for all grid types

* Fix problems with blending when rendering transparent grids

* Rename 'GridColor' to 'Color' for better consistenty among renderables

* Fix issue with resizing box grid

* Avoid problems with line width on Mac
This commit is contained in:
Emma Broman
2021-01-28 09:22:50 +01:00
committed by GitHub
parent f6132b04c9
commit 19e5960020
13 changed files with 153 additions and 129 deletions

View File

@@ -1,6 +1,6 @@
local assetHelper = asset.require('util/asset_helper')
local scale = 3E11
local scale = 149597870700 -- 1 AU
local radialGrid = {
Identifier = "ExampleRadialGrid",
@@ -14,9 +14,10 @@ local radialGrid = {
Renderable = {
Type = "RenderableRadialGrid",
Opacity = 0.8,
GridColor = {0.6, 1.0, 0.7},
Color = { 0.6, 1.0, 0.7 },
LineWidth = 3.0,
GridSegments = {3, 4},
GridSegments = { 3, 4 },
OuterSize = 1.0,
InnerRadius = 0.2,
Enabled = false
},
@@ -36,10 +37,10 @@ local planarGrid = {
},
Renderable = {
Type = "RenderableGrid",
GridColor = {0.0, 1.0, 0.8},
Color = { 0.0, 1.0, 0.8 },
LineWidth = 2.0,
Segments = {5, 10},
Size = {1, 2},
Segments = { 5, 10 },
Size = { 1, 2 },
Enabled = false
},
GUI = {
@@ -48,7 +49,51 @@ local planarGrid = {
}
}
assetHelper.registerSceneGraphNodesAndExport(asset, {
radialGrid,
planarGrid
local sphericalGrid = {
Identifier = "ExampleSphericalGrid",
Transform = {
Scale = {
Type = "StaticScale",
Scale = scale
}
},
Renderable = {
Type = "RenderableSphericalGrid",
Color = { 1.0, 0.5, 0.2 },
LineWidth = 2.0,
Segments = 40,
Enabled = false
},
GUI = {
Name = "Example Spherical Grid",
Path = "/Examples/Grids"
}
}
local boxGrid = {
Identifier = "ExampleBoxGrid",
Transform = {
Scale = {
Type = "StaticScale",
Scale = scale
}
},
Renderable = {
Type = "RenderableBoxGrid",
Color = { 0.5, 0.0, 1.0 },
LineWidth = 2.0,
Size = { 2, 2, 2 },
Enabled = false
},
GUI = {
Name = "Example Box Grid",
Path = "/Examples/Grids"
}
}
assetHelper.registerSceneGraphNodesAndExport(asset, {
radialGrid,
planarGrid,
sphericalGrid,
boxGrid
})

View File

@@ -40,7 +40,7 @@ local radio = {
Type = "RenderableSphericalGrid",
Enabled = false,
Opacity = 1.0,
GridColor = { 0.3, 0.84, 1.0 },
Color = { 0.3, 0.84, 1.0 },
LineWidth = 2.0
},
GUI = {
@@ -66,7 +66,7 @@ local oort = {
Type = "RenderableSphericalGrid",
Enabled = false,
Opacity = 0.8,
GridColor = { 0.8, 0.4, 0.4 },
Color = { 0.8, 0.4, 0.4 },
LineWidth = 2.0
},
GUI = {
@@ -92,7 +92,7 @@ local ecliptic = {
Type = "RenderableSphericalGrid",
Enabled = false,
Opacity = 1.0,
GridColor = { 0.74, 0.26, 0.26 },
Color = { 0.74, 0.26, 0.26 },
LineWidth = 2.0
},
GUI = {
@@ -146,7 +146,7 @@ local equatorial = {
Type = "RenderableSphericalGrid",
Enabled = false,
Opacity = 0.8,
GridColor = { 0.69, 0.68, 0.29 },
Color = { 0.69, 0.68, 0.29 },
LineWidth = 2.0
},
GUI = {
@@ -197,7 +197,7 @@ local galactic = {
Enabled = false,
LineWidth = 2.0,
Opacity = 1.0,
GridColor = { 0.0, 0.6, 0.6 }
Color = { 0.0, 0.6, 0.6 }
},
GUI = {
Name = "Galactic Sphere",

View File

@@ -41,7 +41,7 @@ local addGrid = function (specification)
Type = "RenderableSphericalGrid",
Enabled = true,
LineWidth = 2.0,
GridColor = color
Color = color
},
GUI = {
Name = name,

View File

@@ -36,7 +36,7 @@ local getBookmarks = function (guiPath, bookmarkfile)
Type = 'RenderableSphericalGrid',
Enabled = false,
Opacity = 0.3,
GridColor = { 0.3, 0.84, 1.0},
Color = { 0.3, 0.84, 1.0},
LineWidth = linewidth
},
GUI = {

View File

@@ -28,7 +28,6 @@
#include <openspace/engine/globals.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/rendering/renderengine.h>
#include <openspace/util/spicemanager.h>
#include <openspace/util/updatestructures.h>
#include <openspace/documentation/verifier.h>
#include <ghoul/glm.h>
@@ -39,9 +38,9 @@
namespace {
constexpr const char* ProgramName = "GridProgram";
constexpr openspace::properties::Property::PropertyInfo GridColorInfo = {
"GridColor",
"Grid Color",
constexpr openspace::properties::Property::PropertyInfo ColorInfo = {
"Color",
"Color",
"This value determines the color of the grid lines that are rendered."
};
@@ -67,10 +66,10 @@ documentation::Documentation RenderableBoxGrid::Documentation() {
"base_renderable_boxgrid",
{
{
GridColorInfo.identifier,
ColorInfo.identifier,
new DoubleVector3Verifier,
Optional::Yes,
GridColorInfo.description
ColorInfo.description
},
{
LineWidthInfo.identifier,
@@ -88,17 +87,11 @@ documentation::Documentation RenderableBoxGrid::Documentation() {
};
}
RenderableBoxGrid::RenderableBoxGrid(const ghoul::Dictionary& dictionary)
: Renderable(dictionary)
, _gridColor(
GridColorInfo,
glm::vec3(0.5f, 0.5, 0.5f),
glm::vec3(0.f),
glm::vec3(1.f)
)
, _color(ColorInfo, glm::vec3(0.5f), glm::vec3(0.f), glm::vec3(1.f))
, _lineWidth(LineWidthInfo, 0.5f, 0.f, 20.f)
, _size(SizeInfo, glm::vec3(1e20f), glm::vec3(1.f), glm::vec3(1e35f))
, _size(SizeInfo, glm::vec3(1.f), glm::vec3(1.f), glm::vec3(100.f))
{
documentation::testSpecificationAndThrow(
Documentation(),
@@ -109,11 +102,11 @@ RenderableBoxGrid::RenderableBoxGrid(const ghoul::Dictionary& dictionary)
addProperty(_opacity);
registerUpdateRenderBinFromOpacity();
if (dictionary.hasKey(GridColorInfo.identifier)) {
_gridColor = dictionary.value<glm::dvec3>(GridColorInfo.identifier);
if (dictionary.hasKey(ColorInfo.identifier)) {
_color = dictionary.value<glm::dvec3>(ColorInfo.identifier);
}
_gridColor.setViewOption(properties::Property::ViewOptions::Color);
addProperty(_gridColor);
_color.setViewOption(properties::Property::ViewOptions::Color);
addProperty(_color);
if (dictionary.hasKey(LineWidthInfo.identifier)) {
_lineWidth = static_cast<float>(
@@ -173,8 +166,6 @@ void RenderableBoxGrid::deinitializeGL() {
void RenderableBoxGrid::render(const RenderData& data, RendererTasks&){
_gridProgram->activate();
_gridProgram->setUniform("opacity", _opacity);
glm::dmat4 modelTransform =
glm::translate(glm::dmat4(1.0), data.modelTransform.translation) * // Translation
glm::dmat4(data.modelTransform.rotation) * // Spice rotation
@@ -187,14 +178,19 @@ void RenderableBoxGrid::render(const RenderData& data, RendererTasks&){
"MVPTransform",
glm::dmat4(data.camera.projectionMatrix()) * modelViewTransform
);
_gridProgram->setUniform("opacity", _opacity);
_gridProgram->setUniform("gridColor", _color);
_gridProgram->setUniform("gridColor", _gridColor);
// Changes GL state:
// Change GL state:
#ifndef __APPLE__
glLineWidth(_lineWidth);
#else
glLineWidth(1.f);
#endif
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnablei(GL_BLEND, 0);
glEnable(GL_LINE_SMOOTH);
glDepthMask(false);
glBindVertexArray(_vaoID);
glDrawArrays(_mode, 0, static_cast<GLsizei>(_varray.size()));
@@ -202,16 +198,14 @@ void RenderableBoxGrid::render(const RenderData& data, RendererTasks&){
_gridProgram->deactivate();
// Restores GL State
// Restore GL State
global::renderEngine->openglStateCache().resetBlendState();
global::renderEngine->openglStateCache().resetLineState();
global::renderEngine->openglStateCache().resetDepthState();
}
void RenderableBoxGrid::update(const UpdateData&) {
if (_gridIsDirty) {
//_vsize = (_segments + 1) * (_segments + 1);
//_varray.resize(_vsize);
const glm::vec3 llf = -_size.value() / 2.f;
const glm::vec3 urb = _size.value() / 2.f;
@@ -244,6 +238,9 @@ void RenderableBoxGrid::update(const UpdateData&) {
const glm::vec3 v6 = glm::vec3(urb.x, urb.y, urb.z);
const glm::vec3 v7 = glm::vec3(llf.x, urb.y, urb.z);
_varray.clear();
_varray.reserve(16);
// First add the bounds
_varray.push_back({ v0.x, v0.y, v0.z });
_varray.push_back({ v1.x, v1.y, v1.z });
@@ -262,7 +259,6 @@ void RenderableBoxGrid::update(const UpdateData&) {
_varray.push_back({ v7.x, v7.y, v7.z });
_varray.push_back({ v3.x, v3.y, v3.z });
glBindVertexArray(_vaoID);
glBindBuffer(GL_ARRAY_BUFFER, _vBufferID);
glBufferData(
@@ -273,7 +269,6 @@ void RenderableBoxGrid::update(const UpdateData&) {
);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), nullptr);
glBindVertexArray(0);
_gridIsDirty = false;

View File

@@ -27,6 +27,7 @@
#include <openspace/rendering/renderable.h>
#include <openspace/properties/scalar/floatproperty.h>
#include <openspace/properties/vector/vec3property.h>
#include <ghoul/opengl/ghoul_gl.h>
@@ -59,7 +60,7 @@ protected:
ghoul::opengl::ProgramObject* _gridProgram = nullptr;
properties::Vec3Property _gridColor;
properties::Vec3Property _color;
properties::FloatProperty _lineWidth;
properties::Vec3Property _size;

View File

@@ -29,7 +29,6 @@
#include <openspace/engine/globals.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/rendering/renderengine.h>
#include <openspace/util/spicemanager.h>
#include <openspace/util/updatestructures.h>
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/glm.h>
@@ -39,9 +38,9 @@
namespace {
constexpr const char* ProgramName = "GridProgram";
constexpr openspace::properties::Property::PropertyInfo GridColorInfo = {
"GridColor",
"Grid Color",
constexpr openspace::properties::Property::PropertyInfo ColorInfo = {
"Color",
"Color",
"This value determines the color of the grid lines that are rendered."
};
@@ -74,10 +73,10 @@ documentation::Documentation RenderableGrid::Documentation() {
"base_renderable_grid",
{
{
GridColorInfo.identifier,
ColorInfo.identifier,
new DoubleVector3Verifier,
Optional::Yes,
GridColorInfo.description
ColorInfo.description
},
{
SegmentsInfo.identifier,
@@ -104,7 +103,7 @@ documentation::Documentation RenderableGrid::Documentation() {
RenderableGrid::RenderableGrid(const ghoul::Dictionary& dictionary)
: Renderable(dictionary)
, _gridColor(GridColorInfo, glm::vec3(0.5f), glm::vec3(0.f), glm::vec3(1.f))
, _color(ColorInfo, glm::vec3(0.5f), glm::vec3(0.f), glm::vec3(1.f))
, _segments(SegmentsInfo, glm::uvec2(10), glm::uvec2(1), glm::uvec2(200))
, _lineWidth(LineWidthInfo, 0.5f, 0.f, 20.f)
, _size(SizeInfo, glm::vec2(1e20f), glm::vec2(1.f), glm::vec2(1e35f))
@@ -118,11 +117,11 @@ RenderableGrid::RenderableGrid(const ghoul::Dictionary& dictionary)
addProperty(_opacity);
registerUpdateRenderBinFromOpacity();
if (dictionary.hasKey(GridColorInfo.identifier)) {
_gridColor = dictionary.value<glm::dvec3>(GridColorInfo.identifier);
if (dictionary.hasKey(ColorInfo.identifier)) {
_color = dictionary.value<glm::dvec3>(ColorInfo.identifier);
}
_gridColor.setViewOption(properties::Property::ViewOptions::Color);
addProperty(_gridColor);
_color.setViewOption(properties::Property::ViewOptions::Color);
addProperty(_color);
if (dictionary.hasKey(SegmentsInfo.identifier)) {
_segments = static_cast<glm::uvec2>(
@@ -190,8 +189,6 @@ void RenderableGrid::deinitializeGL() {
void RenderableGrid::render(const RenderData& data, RendererTasks&){
_gridProgram->activate();
_gridProgram->setUniform("opacity", _opacity);
glm::dmat4 modelTransform =
glm::translate(glm::dmat4(1.0), data.modelTransform.translation) * // Translation
glm::dmat4(data.modelTransform.rotation) * // Spice rotation
@@ -204,14 +201,19 @@ void RenderableGrid::render(const RenderData& data, RendererTasks&){
"MVPTransform",
glm::dmat4(data.camera.projectionMatrix()) * modelViewTransform
);
_gridProgram->setUniform("opacity", _opacity);
_gridProgram->setUniform("gridColor", _color);
_gridProgram->setUniform("gridColor", _gridColor);
// Changes GL state:
// Change GL state:
#ifndef __APPLE__
glLineWidth(_lineWidth);
#else
glLineWidth(1.f);
#endif
glEnablei(GL_BLEND, 0);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_LINE_SMOOTH);
glDepthMask(false);
glBindVertexArray(_vaoID);
glDrawArrays(_mode, 0, static_cast<GLsizei>(_varray.size()));
@@ -219,9 +221,10 @@ void RenderableGrid::render(const RenderData& data, RendererTasks&){
_gridProgram->deactivate();
// Restores GL State
// Restore GL State
global::renderEngine->openglStateCache().resetBlendState();
global::renderEngine->openglStateCache().resetLineState();
global::renderEngine->openglStateCache().resetDepthState();
}
void RenderableGrid::update(const UpdateData&) {

View File

@@ -28,8 +28,7 @@
#include <openspace/rendering/renderable.h>
#include <openspace/properties/stringproperty.h>
#include <openspace/properties/matrix/dmat4property.h>
#include <openspace/properties/scalar/intproperty.h>
#include <openspace/properties/scalar/floatproperty.h>
#include <openspace/properties/vector/uvec2property.h>
#include <openspace/properties/vector/vec2property.h>
#include <openspace/properties/vector/vec3property.h>
@@ -61,7 +60,7 @@ protected:
ghoul::opengl::ProgramObject* _gridProgram = nullptr;
properties::Vec3Property _gridColor;
properties::Vec3Property _color;
properties::UVec2Property _segments;
properties::FloatProperty _lineWidth;
properties::Vec2Property _size;

View File

@@ -28,7 +28,6 @@
#include <modules/base/basemodule.h>
#include <openspace/engine/globals.h>
#include <openspace/rendering/renderengine.h>
#include <openspace/util/spicemanager.h>
#include <openspace/util/updatestructures.h>
#include <openspace/documentation/verifier.h>
#include <ghoul/glm.h>
@@ -39,9 +38,9 @@
namespace {
constexpr const char* ProgramName = "GridProgram";
constexpr openspace::properties::Property::PropertyInfo GridColorInfo = {
"GridColor",
"Grid Color",
constexpr openspace::properties::Property::PropertyInfo ColorInfo = {
"Color",
"Color",
"This value determines the color of the grid lines that are rendered."
};
@@ -49,7 +48,7 @@ namespace {
"GridSegments",
"Number of Grid Segments",
"Specifies the number of segments for the grid, in the radial and angular "
" direction respectively"
"direction respectively"
};
constexpr openspace::properties::Property::PropertyInfo CircleSegmentsInfo = {
@@ -88,10 +87,10 @@ documentation::Documentation RenderableRadialGrid::Documentation() {
"base_renderable_radialgrid",
{
{
GridColorInfo.identifier,
ColorInfo.identifier,
new DoubleVector3Verifier,
Optional::Yes,
GridColorInfo.description
ColorInfo.description
},
{
GridSegmentsInfo.identifier,
@@ -129,13 +128,8 @@ documentation::Documentation RenderableRadialGrid::Documentation() {
RenderableRadialGrid::RenderableRadialGrid(const ghoul::Dictionary& dictionary)
: Renderable(dictionary)
, _gridColor(GridColorInfo, glm::vec3(0.5f), glm::vec3(0.f), glm::vec3(1.f))
, _gridSegments(
GridSegmentsInfo,
glm::ivec2(1, 1),
glm::ivec2(1),
glm::ivec2(200)
)
, _color(ColorInfo, glm::vec3(0.5f), glm::vec3(0.f), glm::vec3(1.f))
, _gridSegments(GridSegmentsInfo, glm::ivec2(1), glm::ivec2(1), glm::ivec2(200))
, _circleSegments(CircleSegmentsInfo, 36, 4, 200)
, _lineWidth(LineWidthInfo, 0.5f, 0.f, 20.f)
, _maxRadius(OuterRadiusInfo, 1.f, 0.f, 20.f)
@@ -150,11 +144,11 @@ RenderableRadialGrid::RenderableRadialGrid(const ghoul::Dictionary& dictionary)
addProperty(_opacity);
registerUpdateRenderBinFromOpacity();
if (dictionary.hasKey(GridColorInfo.identifier)) {
_gridColor = dictionary.value<glm::dvec3>(GridColorInfo.identifier);
if (dictionary.hasKey(ColorInfo.identifier)) {
_color = dictionary.value<glm::dvec3>(ColorInfo.identifier);
}
_gridColor.setViewOption(properties::Property::ViewOptions::Color);
addProperty(_gridColor);
_color.setViewOption(properties::Property::ViewOptions::Color);
addProperty(_color);
if (dictionary.hasKey(GridSegmentsInfo.identifier)) {
_gridSegments = static_cast<glm::ivec2>(
@@ -243,8 +237,6 @@ void RenderableRadialGrid::deinitializeGL() {
void RenderableRadialGrid::render(const RenderData& data, RendererTasks&) {
_gridProgram->activate();
_gridProgram->setUniform("opacity", _opacity);
const glm::dmat4 modelTransform =
glm::translate(glm::dmat4(1.0), data.modelTransform.translation) * // Translation
glm::dmat4(data.modelTransform.rotation) * // Spice rotation
@@ -258,20 +250,19 @@ void RenderableRadialGrid::render(const RenderData& data, RendererTasks&) {
"MVPTransform",
glm::dmat4(data.camera.projectionMatrix()) * modelViewTransform
);
_gridProgram->setUniform("opacity", _opacity);
_gridProgram->setUniform("gridColor", _color);
_gridProgram->setUniform("gridColor", _gridColor);
float adjustedLineWidth = 1.f;
// Change GL state:
#ifndef __APPLE__
adjustedLineWidth = _lineWidth;
glLineWidth(_lineWidth);
#else
glLineWidth(1.f);
#endif
// Changes GL state:
glLineWidth(adjustedLineWidth);
glEnablei(GL_BLEND, 0);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_LINE_SMOOTH);
glDepthMask(false);
for (GeometryData& c : _circles) {
c.render();
@@ -281,9 +272,10 @@ void RenderableRadialGrid::render(const RenderData& data, RendererTasks&) {
_gridProgram->deactivate();
// Restores GL State
// Restore GL State
global::renderEngine->openglStateCache().resetBlendState();
global::renderEngine->openglStateCache().resetLineState();
global::renderEngine->openglStateCache().resetDepthState();
}
void RenderableRadialGrid::update(const UpdateData&) {

View File

@@ -27,7 +27,6 @@
#include <openspace/rendering/renderable.h>
#include <openspace/properties/stringproperty.h>
#include <openspace/properties/scalar/floatproperty.h>
#include <openspace/properties/scalar/intproperty.h>
#include <openspace/properties/vector/ivec2property.h>
@@ -75,7 +74,7 @@ protected:
ghoul::opengl::ProgramObject* _gridProgram;
properties::Vec3Property _gridColor;
properties::Vec3Property _color;
properties::IVec2Property _gridSegments;
properties::IntProperty _circleSegments;
properties::FloatProperty _lineWidth;

View File

@@ -27,7 +27,6 @@
#include <modules/base/basemodule.h>
#include <openspace/engine/globals.h>
#include <openspace/rendering/renderengine.h>
#include <openspace/util/spicemanager.h>
#include <openspace/util/updatestructures.h>
#include <openspace/documentation/verifier.h>
#include <ghoul/glm.h>
@@ -38,9 +37,9 @@
namespace {
constexpr const char* ProgramName = "GridProgram";
constexpr openspace::properties::Property::PropertyInfo GridColorInfo = {
"GridColor",
"Grid Color",
constexpr openspace::properties::Property::PropertyInfo ColorInfo = {
"Color",
"Color",
"This value determines the color of the grid lines that are rendered."
};
@@ -67,10 +66,10 @@ documentation::Documentation RenderableSphericalGrid::Documentation() {
"base_renderable_sphericalgrid",
{
{
GridColorInfo.identifier,
ColorInfo.identifier,
new DoubleVector3Verifier,
Optional::Yes,
GridColorInfo.description
ColorInfo.description
},
{
SegmentsInfo.identifier,
@@ -88,16 +87,10 @@ documentation::Documentation RenderableSphericalGrid::Documentation() {
};
}
RenderableSphericalGrid::RenderableSphericalGrid(const ghoul::Dictionary& dictionary)
: Renderable(dictionary)
, _gridProgram(nullptr)
, _gridColor(
GridColorInfo,
glm::vec3(0.5f, 0.5, 0.5f),
glm::vec3(0.f),
glm::vec3(1.f)
)
, _color(ColorInfo, glm::vec3(0.5f), glm::vec3(0.f), glm::vec3(1.f))
, _segments(SegmentsInfo, 36, 4, 200)
, _lineWidth(LineWidthInfo, 0.5f, 0.f, 20.f)
{
@@ -110,11 +103,11 @@ RenderableSphericalGrid::RenderableSphericalGrid(const ghoul::Dictionary& dictio
addProperty(_opacity);
registerUpdateRenderBinFromOpacity();
if (dictionary.hasKey(GridColorInfo.identifier)) {
_gridColor = dictionary.value<glm::dvec3>(GridColorInfo.identifier);
if (dictionary.hasKey(ColorInfo.identifier)) {
_color = dictionary.value<glm::dvec3>(ColorInfo.identifier);
}
_gridColor.setViewOption(properties::Property::ViewOptions::Color);
addProperty(_gridColor);
_color.setViewOption(properties::Property::ViewOptions::Color);
addProperty(_color);
if (dictionary.hasKey(SegmentsInfo.identifier)) {
_segments = static_cast<int>(dictionary.value<double>(SegmentsInfo.identifier));
@@ -186,8 +179,6 @@ void RenderableSphericalGrid::deinitializeGL() {
void RenderableSphericalGrid::render(const RenderData& data, RendererTasks&){
_gridProgram->activate();
_gridProgram->setUniform("opacity", _opacity);
const glm::dmat4 modelTransform =
glm::translate(glm::dmat4(1.0), data.modelTransform.translation) * // Translation
glm::dmat4(data.modelTransform.rotation) * // Spice rotation
@@ -201,20 +192,19 @@ void RenderableSphericalGrid::render(const RenderData& data, RendererTasks&){
"MVPTransform",
glm::dmat4(data.camera.projectionMatrix()) * modelViewTransform
);
_gridProgram->setUniform("opacity", _opacity);
_gridProgram->setUniform("gridColor", _color);
_gridProgram->setUniform("gridColor", _gridColor);
float adjustedLineWidth = 1.f;
// Change GL state:
#ifndef __APPLE__
adjustedLineWidth = _lineWidth;
glLineWidth(_lineWidth);
#else
glLineWidth(1.f);
#endif
// Changes GL state:
glLineWidth(adjustedLineWidth);
glEnablei(GL_BLEND, 0);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_LINE_SMOOTH);
glDepthMask(false);
glBindVertexArray(_vaoID);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _iBufferID);
@@ -223,9 +213,10 @@ void RenderableSphericalGrid::render(const RenderData& data, RendererTasks&){
_gridProgram->deactivate();
// Restores GL State
// Restore GL State
global::renderEngine->openglStateCache().resetBlendState();
global::renderEngine->openglStateCache().resetLineState();
global::renderEngine->openglStateCache().resetDepthState();
}
void RenderableSphericalGrid::update(const UpdateData&) {

View File

@@ -27,7 +27,6 @@
#include <openspace/rendering/renderable.h>
#include <openspace/properties/stringproperty.h>
#include <openspace/properties/scalar/floatproperty.h>
#include <openspace/properties/scalar/intproperty.h>
#include <openspace/properties/vector/vec3property.h>
@@ -61,7 +60,7 @@ protected:
ghoul::opengl::ProgramObject* _gridProgram;
properties::Vec3Property _gridColor;
properties::Vec3Property _color;
properties::IntProperty _segments;
properties::FloatProperty _lineWidth;

View File

@@ -39,7 +39,7 @@ openspace.gaia.addClippingBox = function (name, size, position)
},
Renderable = {
Type = "RenderableBoxGrid",
GridColor = { 0.6, 0.5, 0.7 },
Color = { 0.6, 0.5, 0.7 },
LineWidth = 2.0,
Size = { size[1] * kilo_parsec_in_meter, size[2] * kilo_parsec_in_meter, size[3] * kilo_parsec_in_meter}
},
@@ -84,7 +84,7 @@ openspace.gaia.addClippingSphere = function (name, radius)
},
Renderable = {
Type = "RenderableSphericalGrid",
GridColor = { 0.6, 0.5, 0.7 },
Color = { 0.6, 0.5, 0.7 },
LineWidth = 1.0,
},
GUI = {