mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-04 18:11:01 -05:00
Issue/425 (#860)
* Working on the fix for the depth sorting problem. * Changed grids and billboards to additive blending.
This commit is contained in:
committed by
Alexander Bock
parent
8351ec2108
commit
8bb70e328d
@@ -111,6 +111,12 @@ namespace {
|
||||
"Disable Fade-In/Fade-Out effects",
|
||||
"Enables/Disables the Fade-In/Out effects."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo BackgroundInfo = {
|
||||
"Background",
|
||||
"Sets the current sphere rendering as a background rendering type",
|
||||
"Enables/Disables background rendering."
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace openspace {
|
||||
@@ -175,6 +181,12 @@ documentation::Documentation RenderableSphere::Documentation() {
|
||||
Optional::Yes,
|
||||
DisableFadeInOutInfo.description
|
||||
},
|
||||
{
|
||||
BackgroundInfo.identifier,
|
||||
new BoolVerifier,
|
||||
Optional::Yes,
|
||||
BackgroundInfo.description
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -189,6 +201,7 @@ RenderableSphere::RenderableSphere(const ghoul::Dictionary& dictionary)
|
||||
, _mirrorTexture(MirrorTextureInfo, false)
|
||||
, _useAdditiveBlending(UseAdditiveBlendingInfo, false)
|
||||
, _disableFadeInDistance(DisableFadeInOutInfo, true)
|
||||
, _backgroundRendering(BackgroundInfo, false)
|
||||
, _fadeInThreshold(FadeInThresholdInfo, -1.f, 0.f, 1.f)
|
||||
, _fadeOutThreshold(FadeOutThresholdInfo, -1.f, 0.f, 1.f)
|
||||
{
|
||||
@@ -249,6 +262,10 @@ RenderableSphere::RenderableSphere(const ghoul::Dictionary& dictionary)
|
||||
}
|
||||
if (dictionary.hasKey(UseAdditiveBlendingInfo.identifier)) {
|
||||
_useAdditiveBlending = dictionary.value<bool>(UseAdditiveBlendingInfo.identifier);
|
||||
|
||||
if (_useAdditiveBlending) {
|
||||
setRenderBin(Renderable::RenderBin::Transparent);
|
||||
}
|
||||
}
|
||||
|
||||
if (dictionary.hasKey(FadeOutThresholdInfo.identifier)) {
|
||||
@@ -270,6 +287,14 @@ RenderableSphere::RenderableSphere(const ghoul::Dictionary& dictionary)
|
||||
_disableFadeInDistance.set(false);
|
||||
addProperty(_disableFadeInDistance);
|
||||
}
|
||||
|
||||
if (dictionary.hasKey(BackgroundInfo.identifier)) {
|
||||
_backgroundRendering = dictionary.value<bool>(BackgroundInfo.identifier);
|
||||
|
||||
if (_backgroundRendering) {
|
||||
setRenderBin(Renderable::RenderBin::Background);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool RenderableSphere::isReady() const {
|
||||
|
||||
@@ -72,6 +72,7 @@ private:
|
||||
properties::BoolProperty _mirrorTexture;
|
||||
properties::BoolProperty _useAdditiveBlending;
|
||||
properties::BoolProperty _disableFadeInDistance;
|
||||
properties::BoolProperty _backgroundRendering;
|
||||
|
||||
properties::FloatProperty _fadeInThreshold;
|
||||
properties::FloatProperty _fadeOutThreshold;
|
||||
|
||||
@@ -643,6 +643,8 @@ void RenderableBillboardsCloud::initialize() {
|
||||
// entry is the one selected by default.
|
||||
_colorOption.setValue(static_cast<int>(_colorRangeData.size() - 1));
|
||||
}
|
||||
|
||||
setRenderBin(Renderable::RenderBin::Transparent);
|
||||
}
|
||||
|
||||
void RenderableBillboardsCloud::initializeGL() {
|
||||
@@ -722,6 +724,7 @@ void RenderableBillboardsCloud::renderBillboards(const RenderData& data,
|
||||
float fadeInVariable)
|
||||
{
|
||||
glDepthMask(false);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
// Saving current OpenGL state
|
||||
GLboolean blendEnabled = glIsEnabledi(GL_BLEND, 0);
|
||||
@@ -746,8 +749,7 @@ void RenderableBillboardsCloud::renderBillboards(const RenderData& data,
|
||||
|
||||
glEnablei(GL_BLEND, 0);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||
//glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
|
||||
_program->activate();
|
||||
|
||||
const glm::dmat4 projMatrix = glm::dmat4(data.camera.projectionMatrix());
|
||||
|
||||
@@ -387,6 +387,8 @@ RenderableDUMeshes::RenderableDUMeshes(const ghoul::Dictionary& dictionary)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
setRenderBin(Renderable::RenderBin::Opaque);
|
||||
}
|
||||
|
||||
bool RenderableDUMeshes::isReady() const {
|
||||
@@ -473,9 +475,10 @@ void RenderableDUMeshes::renderMeshes(const RenderData&,
|
||||
glGetIntegerv(GL_BLEND_SRC_RGB, &blendSrcRGB);
|
||||
|
||||
glEnablei(GL_BLEND, 0);
|
||||
//glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||
//glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glDepthMask(false);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
_program->activate();
|
||||
|
||||
|
||||
@@ -52,8 +52,8 @@ Fragment getFragment() {
|
||||
|
||||
fullColor.a *= fadeInValue * ta;
|
||||
|
||||
if (fullColor.a == 0.f ||
|
||||
fullColor.rgb == vec3(0.0)) {
|
||||
float textureOpacity = dot(fullColor.rgb, vec3(1.0));
|
||||
if (fullColor.a == 0.f || textureOpacity == 0.0) {
|
||||
discard;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user