mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-07 20:09:58 -05:00
Rename 'transparency' to 'colorFilter' in the ring classes
to avoid confusion with opacity name change. Also, the 'transparency' used in the rings had a diffrent meaning than for the rest of the rendered objects. It affects the filtering of the color values.
This commit is contained in:
@@ -35,7 +35,7 @@ in vec4 shadowCoords;
|
||||
uniform sampler2DShadow shadowMapTexture;
|
||||
uniform sampler1D ringTexture;
|
||||
uniform vec2 textureOffset;
|
||||
uniform float transparency;
|
||||
uniform float colorFilterValue;
|
||||
|
||||
uniform vec3 sunPosition;
|
||||
uniform float _nightFactor;
|
||||
@@ -67,12 +67,11 @@ Fragment getFragment() {
|
||||
}
|
||||
|
||||
vec4 diffuse = texture(ringTexture, texCoord);
|
||||
float colorValue = length(diffuse.rgb);
|
||||
// times 3 as length of vec3(1.0, 1.0, 1.0) will return 3 and we want
|
||||
// to normalize the transparency value to [0,1]
|
||||
if (colorValue < 3.0 * transparency) {
|
||||
diffuse.a = pow(colorValue / (3.0 * transparency), 1);
|
||||
//diffuse.a = (colorValue / 3.0) * transparency;
|
||||
// divided by 3 as length of vec3(1.0, 1.0, 1.0) will return 3 and we want
|
||||
// to normalize the alpha value to [0,1]
|
||||
float colorValue = length(diffuse.rgb) / 3.0;
|
||||
if (colorValue < colorFilterValue) {
|
||||
diffuse.a = colorValue * colorFilterValue;
|
||||
if (diffuse.a < 0.65)
|
||||
discard;
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace {
|
||||
constexpr const char* _loggerCat = "RingsComponent";
|
||||
|
||||
constexpr const std::array<const char*, 9> UniformNames = {
|
||||
"modelViewProjectionMatrix", "textureOffset", "transparency", "_nightFactor",
|
||||
"modelViewProjectionMatrix", "textureOffset", "colorFilterValue", "_nightFactor",
|
||||
"sunPosition", "ringTexture", "shadowMatrix", "shadowMapTexture",
|
||||
"zFightingPercentage"
|
||||
};
|
||||
@@ -91,11 +91,11 @@ namespace {
|
||||
"of the night side occurs."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo TransparencyInfo = {
|
||||
"Transparency",
|
||||
"Transparency",
|
||||
"This value determines the transparency of part of the rings depending on the "
|
||||
"color values. For this value v, the transparency is equal to length(color) / v."
|
||||
constexpr openspace::properties::Property::PropertyInfo ColorFilterInfo = {
|
||||
"ColorFilter",
|
||||
"Color Filter",
|
||||
"This value affects the filtering out of part of the rings depending on the "
|
||||
"color values of the texture. The higher value, the more rings are filtered out."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo ZFightingPercentageInfo = {
|
||||
@@ -146,10 +146,10 @@ documentation::Documentation RingsComponent::Documentation() {
|
||||
NightFactorInfo.description
|
||||
},
|
||||
{
|
||||
TransparencyInfo.identifier,
|
||||
ColorFilterInfo.identifier,
|
||||
new DoubleVerifier,
|
||||
Optional::Yes,
|
||||
TransparencyInfo.description
|
||||
ColorFilterInfo.description
|
||||
},
|
||||
{
|
||||
ZFightingPercentageInfo.identifier,
|
||||
@@ -173,7 +173,7 @@ RingsComponent::RingsComponent(const ghoul::Dictionary& dictionary)
|
||||
, _size(SizeInfo, 1.f, 0.f, 1e25f)
|
||||
, _offset(OffsetInfo, glm::vec2(0.f, 1.f), glm::vec2(0.f), glm::vec2(1.f))
|
||||
, _nightFactor(NightFactorInfo, 0.33f, 0.f, 1.f)
|
||||
, _transparency(TransparencyInfo, 0.15f, 0.f, 1.f)
|
||||
, _colorFilter(ColorFilterInfo, 0.15f, 0.f, 1.f)
|
||||
, _enabled({ "Enabled", "Enabled", "Enable/Disable Rings" }, true)
|
||||
, _zFightingPercentage(ZFightingPercentageInfo, 0.995f, 0.000001f, 1.f)
|
||||
, _nShadowSamples(NumberShadowSamplesInfo, 2, 1, 7)
|
||||
@@ -228,9 +228,9 @@ void RingsComponent::initialize() {
|
||||
}
|
||||
addProperty(_nightFactor);
|
||||
|
||||
if (_ringsDictionary.hasKeyAndValue<double>(TransparencyInfo.identifier)) {
|
||||
_transparency = static_cast<float>(
|
||||
_ringsDictionary.value<double>(TransparencyInfo.identifier)
|
||||
if (_ringsDictionary.hasKeyAndValue<double>(ColorFilterInfo.identifier)) {
|
||||
_colorFilter = static_cast<float>(
|
||||
_ringsDictionary.value<double>(ColorFilterInfo.identifier)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -248,7 +248,7 @@ void RingsComponent::initialize() {
|
||||
_nShadowSamples.onChange([this]() { compileShadowShader(); });
|
||||
addProperty(_nShadowSamples);
|
||||
|
||||
addProperty(_transparency);
|
||||
addProperty(_colorFilter);
|
||||
}
|
||||
|
||||
bool RingsComponent::isReady() const {
|
||||
@@ -327,7 +327,7 @@ void RingsComponent::draw(const RenderData& data,
|
||||
modelViewProjectionTransform
|
||||
);
|
||||
_shader->setUniform(_uniformCache.textureOffset, _offset);
|
||||
_shader->setUniform(_uniformCache.transparency, _transparency);
|
||||
_shader->setUniform(_uniformCache.colorFilterValue, _colorFilter);
|
||||
_shader->setUniform(_uniformCache.nightFactor, _nightFactor);
|
||||
_shader->setUniform(_uniformCache.sunPosition, _sunPosition);
|
||||
_shader->setUniform(_uniformCache.zFightingPercentage, _zFightingPercentage);
|
||||
|
||||
@@ -81,14 +81,14 @@ private:
|
||||
properties::FloatProperty _size;
|
||||
properties::Vec2Property _offset;
|
||||
properties::FloatProperty _nightFactor;
|
||||
properties::FloatProperty _transparency;
|
||||
properties::FloatProperty _colorFilter;
|
||||
properties::BoolProperty _enabled;
|
||||
properties::FloatProperty _zFightingPercentage;
|
||||
properties::IntProperty _nShadowSamples;
|
||||
|
||||
std::unique_ptr<ghoul::opengl::ProgramObject> _shader;
|
||||
std::unique_ptr<ghoul::opengl::ProgramObject> _geometryOnlyShader;
|
||||
UniformCache(modelViewProjectionMatrix, textureOffset, transparency, nightFactor,
|
||||
UniformCache(modelViewProjectionMatrix, textureOffset, colorFilterValue, nightFactor,
|
||||
sunPosition, ringTexture, shadowMatrix, shadowMapTexture, zFightingPercentage
|
||||
) _uniformCache;
|
||||
UniformCache(modelViewProjectionMatrix, textureOffset, ringTexture
|
||||
|
||||
Reference in New Issue
Block a user