Add a colored glare to exoplanet stars (#1511)

* Add possibility to multiply color to an image plane

* Add a colored glare to exoplanet stars (issue #1305)
This commit is contained in:
Emma Broman
2021-03-02 09:30:03 +01:00
committed by GitHub
parent f4cbadd822
commit 97144df4da
9 changed files with 111 additions and 11 deletions

View File

@@ -70,6 +70,13 @@ namespace {
"This determines the blending mode that is applied to this plane."
};
constexpr openspace::properties::Property::PropertyInfo MultiplyColorInfo = {
"MultiplyColor",
"Multiply Color",
"If set, the plane's texture is multiplied with this color. "
"Useful for applying a color grayscale images."
};
struct [[codegen::Dictionary(RenderablePlane)]] Parameters {
// [[codegen::verbatim(BillboardInfo.description)]]
std::optional<bool> billboard;
@@ -83,6 +90,9 @@ namespace {
};
// [[codegen::verbatim(BlendModeInfo.description)]]
std::optional<BlendMode> blendMode;
// [[codegen::verbatim(BlendModeInfo.description)]]
std::optional<glm::vec3> multiplyColor [[codegen::color()]];
};
#include "renderableplane_codegen.cpp"
} // namespace
@@ -100,6 +110,7 @@ RenderablePlane::RenderablePlane(const ghoul::Dictionary& dictionary)
, _blendMode(BlendModeInfo, properties::OptionProperty::DisplayType::Dropdown)
, _billboard(BillboardInfo, false)
, _size(SizeInfo, 10.f, 0.f, 1e25f)
, _multiplyColor(MultiplyColorInfo, glm::vec3(1.f), glm::vec3(0.f), glm::vec3(1.f))
{
Parameters p = codegen::bake<Parameters>(dictionary);
@@ -141,11 +152,15 @@ RenderablePlane::RenderablePlane(const ghoul::Dictionary& dictionary)
}
}
_multiplyColor = p.multiplyColor.value_or(_multiplyColor);
addProperty(_billboard);
addProperty(_size);
_size.onChange([this](){ _planeIsDirty = true; });
addProperty(_multiplyColor);
setBoundingSphere(_size);
}
@@ -238,6 +253,8 @@ void RenderablePlane::render(const RenderData& data, RendererTasks&) {
_shader->setUniform("texture1", unit);
_shader->setUniform("multiplyColor", _multiplyColor);
bool usingFramebufferRenderer = global::renderEngine->rendererImplementation() ==
RenderEngine::RendererImplementation::Framebuffer;

View File

@@ -31,6 +31,7 @@
#include <openspace/properties/stringproperty.h>
#include <openspace/properties/scalar/boolproperty.h>
#include <openspace/properties/scalar/floatproperty.h>
#include <openspace/properties/vector/vec3property.h>
#include <ghoul/opengl/ghoul_gl.h>
namespace ghoul::filesystem { class File; }
@@ -75,6 +76,7 @@ private:
properties::BoolProperty _billboard;
properties::FloatProperty _size;
properties::Vec3Property _multiplyColor;
ghoul::opengl::ProgramObject* _shader = nullptr;