mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-12 22:39:09 -05:00
Add FloatProperty to RenderableStars to modify transparency (closing #150)
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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<ghoul::opengl::Texture> _pointSpreadFunctionTexture;
|
||||
bool _pointSpreadFunctionTextureIsDirty;
|
||||
bool _pointSpreadFunctionTextureIsDirty;
|
||||
|
||||
properties::StringProperty _colorTexturePath;
|
||||
properties::StringProperty _colorTexturePath;
|
||||
std::unique_ptr<ghoul::opengl::Texture> _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<ghoul::opengl::ProgramObject> _program;
|
||||
std::unique_ptr<ghoul::opengl::ProgramObject> _program;
|
||||
|
||||
std::string _speckFile;
|
||||
std::string _speckFile;
|
||||
|
||||
std::vector<float> _slicedData;
|
||||
std::vector<float> _fullData;
|
||||
int _nValuesPerStar;
|
||||
std::vector<float> _slicedData;
|
||||
std::vector<float> _fullData;
|
||||
int _nValuesPerStar;
|
||||
|
||||
GLuint _vao;
|
||||
GLuint _vbo;
|
||||
GLuint _vao;
|
||||
GLuint _vbo;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user