mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-06 11:29:55 -05:00
Added properties to change the appearance of stars
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
#include <openspace/rendering/renderable.h>
|
||||
#include <openspace/properties/stringproperty.h>
|
||||
#include <openspace/properties/optionproperty.h>
|
||||
#include <openspace/properties/vectorproperty.h>
|
||||
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
#include <ghoul/opengl/texture.h>
|
||||
@@ -69,12 +70,13 @@ private:
|
||||
ghoul::opengl::Texture* _colorTexture;
|
||||
bool _colorTextureIsDirty;
|
||||
|
||||
|
||||
properties::OptionProperty _colorOption;
|
||||
bool _dataIsDirty;
|
||||
|
||||
properties::FloatProperty _spriteBaseSize;
|
||||
properties::FloatProperty _spriteResponseSize;
|
||||
properties::Vec2Property _magnitudeClamp;
|
||||
properties::FloatProperty _exponentialOffset;
|
||||
properties::FloatProperty _exponentialDampening;
|
||||
properties::FloatProperty _scaleFactor;
|
||||
|
||||
ghoul::opengl::ProgramObject* _program;
|
||||
bool _programIsDirty;
|
||||
|
||||
@@ -51,8 +51,11 @@ layout(location = 4) out vec2 texCoord;
|
||||
|
||||
uniform mat4 projection;
|
||||
|
||||
uniform float spriteBaseSize;
|
||||
uniform float spriteResponseSize;
|
||||
uniform vec2 magnitudeClamp;
|
||||
uniform float exponentialOffset;
|
||||
uniform float exponentialDampening;
|
||||
uniform float scaleFactor;
|
||||
|
||||
|
||||
// As soon as the scalegraph is in place, replace this by a dynamic calculation
|
||||
// of apparent magnitude in relation to the camera position ---abock
|
||||
@@ -67,8 +70,10 @@ void main() {
|
||||
|
||||
float M = vs_brightness[0].z;
|
||||
|
||||
M = clamp(M, 1.0, 4.0);
|
||||
float modifiedSpriteSize = exp((-5 - M) * 0.871);
|
||||
// M = clamp(M, 1.0, 4.0);
|
||||
M = clamp(M, magnitudeClamp[0], magnitudeClamp[1]);
|
||||
// float modifiedSpriteSize = exp((-5 - M) * 0.871);
|
||||
float modifiedSpriteSize = exp((-exponentialOffset - M) * exponentialDampening) * scaleFactor;
|
||||
|
||||
for(int i = 0; i < 4; i++){
|
||||
vec4 p1 = gl_in[0].gl_Position;
|
||||
|
||||
@@ -84,8 +84,16 @@ RenderableStars::RenderableStars(const ghoul::Dictionary& dictionary)
|
||||
, _colorTextureIsDirty(true)
|
||||
, _colorOption("colorOption", "Color Option")
|
||||
, _dataIsDirty(true)
|
||||
, _spriteBaseSize("spriteBaseSize", "Sprite Base Size", 0.1f, 0.f, 10.f)
|
||||
, _spriteResponseSize("spriteResponseSize", "Sprite Response Size", 1.f, 0.f, 10.f)
|
||||
, _magnitudeClamp(
|
||||
"magnitudeClamp",
|
||||
"Magnitude Clamping",
|
||||
glm::vec2(1.f, 4.f),
|
||||
glm::vec2(-15.f),
|
||||
glm::vec2(15.f)
|
||||
)
|
||||
, _exponentialOffset("exponentialOffset", "Exponential Offset", 5.f, 0.f, 10.f)
|
||||
, _exponentialDampening("exponentialDampening", "Exponential Dampening", 0.871f, 0.f, 1.f)
|
||||
, _scaleFactor("scaleFactor", "Scale Factor", 1.f, 0.f, 10.f)
|
||||
, _program(nullptr)
|
||||
, _programIsDirty(false)
|
||||
, _speckFile("")
|
||||
@@ -114,14 +122,16 @@ RenderableStars::RenderableStars(const ghoul::Dictionary& dictionary)
|
||||
addProperty(_colorOption);
|
||||
_colorOption.onChange([&]{ _dataIsDirty = true;});
|
||||
|
||||
addProperty(_spriteBaseSize);
|
||||
addProperty(_spriteResponseSize);
|
||||
|
||||
addProperty(_pointSpreadFunctionTexturePath);
|
||||
_pointSpreadFunctionTexturePath.onChange([&]{ _pointSpreadFunctionTextureIsDirty = true;});
|
||||
|
||||
addProperty(_colorTexturePath);
|
||||
_colorTexturePath.onChange([&]{ _colorTextureIsDirty = true; });
|
||||
|
||||
addProperty(_magnitudeClamp);
|
||||
addProperty(_exponentialOffset);
|
||||
addProperty(_exponentialDampening);
|
||||
addProperty(_scaleFactor);
|
||||
}
|
||||
|
||||
RenderableStars::~RenderableStars() {
|
||||
@@ -181,13 +191,14 @@ void RenderableStars::render(const RenderData& data) {
|
||||
_program->setUniform("projection", projectionMatrix);
|
||||
|
||||
_program->setUniform("colorOption", _colorOption);
|
||||
_program->setUniform("magnitudeClamp", _magnitudeClamp);
|
||||
_program->setUniform("exponentialOffset", _exponentialOffset);
|
||||
_program->setUniform("exponentialDampening", _exponentialDampening);
|
||||
_program->setUniform("scaleFactor", _scaleFactor);
|
||||
|
||||
setPscUniforms(_program, &data.camera, data.position);
|
||||
_program->setUniform("scaling", scaling);
|
||||
|
||||
_program->setUniform("spriteBaseSize", _spriteBaseSize);
|
||||
_program->setUniform("spriteResponseSize", _spriteResponseSize);
|
||||
|
||||
ghoul::opengl::TextureUnit psfUnit;
|
||||
psfUnit.activate();
|
||||
if (_pointSpreadFunctionTexture)
|
||||
|
||||
Reference in New Issue
Block a user