diff --git a/modules/base/rendering/renderablestars.cpp b/modules/base/rendering/renderablestars.cpp index 87b5ea26c0..cf3fc50022 100644 --- a/modules/base/rendering/renderablestars.cpp +++ b/modules/base/rendering/renderablestars.cpp @@ -92,6 +92,7 @@ RenderableStars::RenderableStars(const ghoul::Dictionary& dictionary) , _colorTextureIsDirty(true) , _colorOption("colorOption", "Color Option") , _dataIsDirty(true) + , _alphaValue("alphaValue", "Transparency", 1.f, 0.f, 1.f) , _scaleFactor("scaleFactor", "Scale Factor", 1.f, 0.f, 10.f) , _minBillboardSize("minBillboardSize", "Min Billboard Size", 1.f, 1.f, 100.f) , _program(nullptr) @@ -132,6 +133,7 @@ RenderableStars::RenderableStars(const ghoul::Dictionary& dictionary) _colorTexturePath.onChange([&]{ _colorTextureIsDirty = true; }); _colorTextureFile->setCallback([&](const File&) { _colorTextureIsDirty = true; }); + addProperty(_alphaValue); addProperty(_scaleFactor); addProperty(_minBillboardSize); } @@ -200,6 +202,7 @@ void RenderableStars::render(const RenderData& data) { _program->setUniform("projection", projectionMatrix); _program->setUniform("colorOption", _colorOption); + _program->setUniform("alphaValue", _alphaValue); _program->setUniform("scaleFactor", _scaleFactor); _program->setUniform("minBillboardSize", _minBillboardSize); diff --git a/modules/base/rendering/renderablestars.h b/modules/base/rendering/renderablestars.h index 68a1e5c8ea..40b9b0fbe6 100644 --- a/modules/base/rendering/renderablestars.h +++ b/modules/base/rendering/renderablestars.h @@ -37,55 +37,56 @@ namespace openspace { class RenderableStars : public Renderable { public: - RenderableStars(const ghoul::Dictionary& dictionary); - ~RenderableStars(); + RenderableStars(const ghoul::Dictionary& dictionary); + ~RenderableStars(); - bool initialize() override; - bool deinitialize() override; + bool initialize() override; + bool deinitialize() override; - bool isReady() const override; + bool isReady() const override; - void render(const RenderData& data) override; - void update(const UpdateData& data) override; + void render(const RenderData& data) override; + void update(const UpdateData& data) override; private: - enum ColorOption { - Color = 0, - Velocity = 1, - Speed = 2 - }; + enum ColorOption { + Color = 0, + Velocity = 1, + Speed = 2 + }; - void createDataSlice(ColorOption option); + void createDataSlice(ColorOption option); - bool loadData(); - bool readSpeckFile(); - bool loadCachedFile(const std::string& file); - bool saveCachedFile(const std::string& file) const; + bool loadData(); + bool readSpeckFile(); + bool loadCachedFile(const std::string& file); + bool saveCachedFile(const std::string& file) const; - properties::StringProperty _pointSpreadFunctionTexturePath; + properties::StringProperty _pointSpreadFunctionTexturePath; std::unique_ptr _pointSpreadFunctionTexture; - bool _pointSpreadFunctionTextureIsDirty; + bool _pointSpreadFunctionTextureIsDirty; - properties::StringProperty _colorTexturePath; + properties::StringProperty _colorTexturePath; std::unique_ptr _colorTexture; - bool _colorTextureIsDirty; + bool _colorTextureIsDirty; - properties::OptionProperty _colorOption; - bool _dataIsDirty; + properties::OptionProperty _colorOption; + bool _dataIsDirty; + properties::FloatProperty _alphaValue; properties::FloatProperty _scaleFactor; properties::FloatProperty _minBillboardSize; - std::unique_ptr _program; + std::unique_ptr _program; - std::string _speckFile; + std::string _speckFile; - std::vector _slicedData; - std::vector _fullData; - int _nValuesPerStar; + std::vector _slicedData; + std::vector _fullData; + int _nValuesPerStar; - GLuint _vao; - GLuint _vbo; + GLuint _vao; + GLuint _vbo; }; } // namespace openspace diff --git a/modules/base/shaders/star_fs.glsl b/modules/base/shaders/star_fs.glsl index 43a9299449..43f77a26b7 100644 --- a/modules/base/shaders/star_fs.glsl +++ b/modules/base/shaders/star_fs.glsl @@ -32,6 +32,7 @@ uniform sampler2D psfTexture; uniform sampler1D colorTexture; uniform float minBillboardSize; +uniform float alphaValue; uniform int colorOption; in vec4 vs_position; @@ -74,6 +75,7 @@ Fragment getFragment() { vec4 textureColor = texture(psfTexture, texCoord); vec4 fullColor = vec4(color.rgb, textureColor.a); + fullColor.a *= alphaValue; vec4 position = vs_position; // This has to be fixed when the scale graph is in place ---emiax