mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-23 12:39:24 -05:00
Feature/stars (#1598)
* Add the ability to remap SPECK variables to usage values
This commit is contained in:
@@ -120,6 +120,61 @@ namespace {
|
||||
"to its color. The texture is used as a one dimensional lookup function."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo MappingBvInfo = {
|
||||
"MappingBV",
|
||||
"Mapping (bv-color)",
|
||||
"The name of the variable in the speck file that is used as the b-v color "
|
||||
"variable"
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo MappingLuminanceInfo = {
|
||||
"MappingLuminance",
|
||||
"Mapping (luminance)",
|
||||
"The name of the variable in the speck file that is used as the luminance "
|
||||
"variable"
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo MappingAbsMagnitudeInfo = {
|
||||
"MappingAbsMagnitude",
|
||||
"Mapping (absolute magnitude)",
|
||||
"The name of the variable in the speck file that is used as the absolute "
|
||||
"magnitude variable"
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo MappingAppMagnitudeInfo = {
|
||||
"MappingAppMagnitude",
|
||||
"Mapping (apparent magnitude)",
|
||||
"The name of the variable in the speck file that is used as the apparent "
|
||||
"magnitude variable"
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo MappingVxInfo = {
|
||||
"MappingVx",
|
||||
"Mapping (vx)",
|
||||
"The name of the variable in the speck file that is used as the star velocity "
|
||||
"along the x-axis"
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo MappingVyInfo = {
|
||||
"MappingVy",
|
||||
"Mapping (vy)",
|
||||
"The name of the variable in the speck file that is used as the star velocity "
|
||||
"along the y-axis"
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo MappingVzInfo = {
|
||||
"MappingVz",
|
||||
"Mapping (vz)",
|
||||
"The name of the variable in the speck file that is used as the star velocity "
|
||||
"along the z-axis"
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo MappingSpeedInfo = {
|
||||
"MappingSpeed",
|
||||
"Mapping (speed)",
|
||||
"The name of the variable in the speck file that is used as the speed"
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo ColorOptionInfo = {
|
||||
"ColorOption",
|
||||
"Color Option",
|
||||
@@ -361,11 +416,33 @@ namespace {
|
||||
// [[codegen::verbatim(SizeCompositionOptionInfo.description)]]
|
||||
std::optional<SizeComposition> sizeComposition;
|
||||
|
||||
struct DataMapping {
|
||||
// [[codegen::verbatim(MappingBvInfo.description)]]
|
||||
std::optional<std::string> bv;
|
||||
// [[codegen::verbatim(MappingLuminanceInfo.description)]]
|
||||
std::optional<std::string> luminance;
|
||||
// [[codegen::verbatim(MappingAbsMagnitudeInfo.description)]]
|
||||
std::optional<std::string> absoluteMagnitude;
|
||||
// [[codegen::verbatim(MappingAppMagnitudeInfo.description)]]
|
||||
std::optional<std::string> apparentMagnitude;
|
||||
// [[codegen::verbatim(MappingVxInfo.description)]]
|
||||
std::optional<std::string> vx;
|
||||
// [[codegen::verbatim(MappingVyInfo.description)]]
|
||||
std::optional<std::string> vy;
|
||||
// [[codegen::verbatim(MappingVzInfo.description)]]
|
||||
std::optional<std::string> vz;
|
||||
// [[codegen::verbatim(MappingSpeedInfo.description)]]
|
||||
std::optional<std::string> speed;
|
||||
};
|
||||
// The mappings between data values and the variable names specified in the speck
|
||||
// file
|
||||
DataMapping dataMapping;
|
||||
|
||||
// [[codegen::verbatim(FadeInDistancesInfo.description)]]
|
||||
std::optional<glm::dvec2> fadeInDistances;
|
||||
|
||||
// [[codegen::verbatim(DisableFadeInInfo.description)]]
|
||||
std::optional<bool> distableFadeIn;
|
||||
std::optional<bool> disableFadeIn;
|
||||
};
|
||||
#include "renderablestars_codegen.cpp"
|
||||
} // namespace
|
||||
@@ -383,6 +460,17 @@ RenderableStars::RenderableStars(const ghoul::Dictionary& dictionary)
|
||||
, _speckFile(SpeckFileInfo)
|
||||
, _colorTexturePath(ColorTextureInfo)
|
||||
//, _shapeTexturePath(ShapeTextureInfo)
|
||||
, _dataMappingContainer({ "DataMapping", "Data Mapping" })
|
||||
, _dataMapping{
|
||||
properties::StringProperty(MappingBvInfo),
|
||||
properties::StringProperty(MappingLuminanceInfo),
|
||||
properties::StringProperty(MappingAbsMagnitudeInfo),
|
||||
properties::StringProperty(MappingAppMagnitudeInfo),
|
||||
properties::StringProperty(MappingVxInfo),
|
||||
properties::StringProperty(MappingVyInfo),
|
||||
properties::StringProperty(MappingVzInfo),
|
||||
properties::StringProperty(MappingSpeedInfo)
|
||||
}
|
||||
, _colorOption(ColorOptionInfo, properties::OptionProperty::DisplayType::Dropdown)
|
||||
, _otherDataOption(
|
||||
OtherDataOptionInfo,
|
||||
@@ -416,7 +504,7 @@ RenderableStars::RenderableStars(const ghoul::Dictionary& dictionary)
|
||||
, _p2Param(P2ParamInfo, 0.138f, 0.f, 1.f)
|
||||
, _spencerAlphaConst(AlphaConstInfo, 0.02f, 0.000001f, 5.f)
|
||||
, _moffatPSFParamOwner(MoffatPSFParamOwnerInfo)
|
||||
, _FWHMConst(FWHMInfo, 10.4f, -100.f, 1000.f)
|
||||
, _FWHMConst(FWHMInfo, 10.4f, 0.f, 100.f)
|
||||
, _moffatBetaConst(BetaInfo, 4.765f, 0.f, 100.f)
|
||||
, _renderingMethodOption(
|
||||
RenderMethodOptionInfo,
|
||||
@@ -440,6 +528,40 @@ RenderableStars::RenderableStars(const ghoul::Dictionary& dictionary)
|
||||
addProperty(_opacity);
|
||||
registerUpdateRenderBinFromOpacity();
|
||||
|
||||
_dataMapping.bvColor = p.dataMapping.bv.value_or("");
|
||||
_dataMapping.bvColor.onChange([this]() { _dataIsDirty = true; });
|
||||
_dataMappingContainer.addProperty(_dataMapping.bvColor);
|
||||
|
||||
_dataMapping.luminance = p.dataMapping.luminance.value_or("");
|
||||
_dataMapping.luminance.onChange([this]() { _dataIsDirty = true; });
|
||||
_dataMappingContainer.addProperty(_dataMapping.luminance);
|
||||
|
||||
_dataMapping.absoluteMagnitude = p.dataMapping.absoluteMagnitude.value_or("");
|
||||
_dataMapping.absoluteMagnitude.onChange([this]() { _dataIsDirty = true; });
|
||||
_dataMappingContainer.addProperty(_dataMapping.absoluteMagnitude);
|
||||
|
||||
_dataMapping.apparentMagnitude = p.dataMapping.apparentMagnitude.value_or("");
|
||||
_dataMapping.apparentMagnitude.onChange([this]() { _dataIsDirty = true; });
|
||||
_dataMappingContainer.addProperty(_dataMapping.apparentMagnitude);
|
||||
|
||||
_dataMapping.vx = p.dataMapping.vx.value_or("");
|
||||
_dataMapping.vx.onChange([this]() { _dataIsDirty = true; });
|
||||
_dataMappingContainer.addProperty(_dataMapping.vx);
|
||||
|
||||
_dataMapping.vy = p.dataMapping.vy.value_or("");
|
||||
_dataMapping.vy.onChange([this]() { _dataIsDirty = true; });
|
||||
_dataMappingContainer.addProperty(_dataMapping.vy);
|
||||
|
||||
_dataMapping.vz = p.dataMapping.vz.value_or("");
|
||||
_dataMapping.vz.onChange([this]() { _dataIsDirty = true; });
|
||||
_dataMappingContainer.addProperty(_dataMapping.vz);
|
||||
|
||||
_dataMapping.speed = p.dataMapping.speed.value_or("");
|
||||
_dataMapping.speed.onChange([this]() { _dataIsDirty = true; });
|
||||
_dataMappingContainer.addProperty(_dataMapping.speed);
|
||||
|
||||
addPropertySubOwner(_dataMappingContainer);
|
||||
|
||||
_speckFile = p.speckFile.string();
|
||||
_speckFile.onChange([&]() { _speckFileIsDirty = true; });
|
||||
addProperty(_speckFile);
|
||||
@@ -1212,14 +1334,20 @@ void RenderableStars::loadData() {
|
||||
}
|
||||
|
||||
std::vector<float> RenderableStars::createDataSlice(ColorOption option) {
|
||||
const int bvIdx = std::max(_dataset.index("colorb_v"), 0);
|
||||
const int lumIdx = std::max(_dataset.index("lum"), 0);
|
||||
const int absMagIdx = std::max(_dataset.index("absmag"), 0);
|
||||
const int appMagIdx = std::max(_dataset.index("appmag"), 0);
|
||||
const int vxIdx = std::max(_dataset.index("vx"), 0);
|
||||
const int vyIdx = std::max(_dataset.index("vy"), 0);
|
||||
const int vzIdx = std::max(_dataset.index("vz"), 0);
|
||||
const int speedIdx = std::max(_dataset.index("speed"), 0);
|
||||
const int bvIdx = std::max(_dataset.index(_dataMapping.bvColor.value()), 0);
|
||||
const int lumIdx = std::max(_dataset.index(_dataMapping.luminance.value()), 0);
|
||||
const int absMagIdx = std::max(
|
||||
_dataset.index(_dataMapping.absoluteMagnitude.value()),
|
||||
0
|
||||
);
|
||||
const int appMagIdx = std::max(
|
||||
_dataset.index(_dataMapping.apparentMagnitude.value()),
|
||||
0
|
||||
);
|
||||
const int vxIdx = std::max(_dataset.index(_dataMapping.vx.value()), 0);
|
||||
const int vyIdx = std::max(_dataset.index(_dataMapping.vy.value()), 0);
|
||||
const int vzIdx = std::max(_dataset.index(_dataMapping.vz.value()), 0);
|
||||
const int speedIdx = std::max(_dataset.index(_dataMapping.speed.value()), 0);
|
||||
|
||||
_otherDataRange = glm::vec2(
|
||||
std::numeric_limits<float>::max(),
|
||||
|
||||
@@ -84,6 +84,18 @@ private:
|
||||
std::unique_ptr<ghoul::opengl::Texture> _colorTexture;
|
||||
std::unique_ptr<ghoul::filesystem::File> _colorTextureFile;
|
||||
|
||||
properties::PropertyOwner _dataMappingContainer;
|
||||
struct {
|
||||
properties::StringProperty bvColor;
|
||||
properties::StringProperty luminance;
|
||||
properties::StringProperty absoluteMagnitude;
|
||||
properties::StringProperty apparentMagnitude;
|
||||
properties::StringProperty vx;
|
||||
properties::StringProperty vy;
|
||||
properties::StringProperty vz;
|
||||
properties::StringProperty speed;
|
||||
} _dataMapping;
|
||||
|
||||
properties::OptionProperty _colorOption;
|
||||
properties::OptionProperty _otherDataOption;
|
||||
properties::StringProperty _otherDataColorMapPath;
|
||||
|
||||
@@ -23,14 +23,13 @@
|
||||
****************************************************************************************/
|
||||
|
||||
#include "fragment.glsl"
|
||||
#include "floatoperations.glsl"
|
||||
|
||||
// keep in sync with renderablestars.h:ColorOption enum
|
||||
const int COLOROPTION_COLOR = 0;
|
||||
const int COLOROPTION_VELOCITY = 1;
|
||||
const int COLOROPTION_SPEED = 2;
|
||||
const int COLOROPTION_OTHERDATA = 3;
|
||||
const int COLOROPTION_FIXEDCOLOR = 4;
|
||||
const int ColorOptionColor = 0;
|
||||
const int ColorOptionVelocity = 1;
|
||||
const int ColorOptionSpeed = 2;
|
||||
const int ColorOptionOtherData = 3;
|
||||
const int ColorOptionFixedColor = 4;
|
||||
|
||||
uniform sampler1D colorTexture;
|
||||
uniform sampler2D psfTexture;
|
||||
@@ -44,12 +43,11 @@ uniform sampler1D otherDataTexture;
|
||||
uniform vec2 otherDataRange;
|
||||
uniform bool filterOutOfRange;
|
||||
|
||||
in vec4 vs_position;
|
||||
in vec2 psfCoords;
|
||||
flat in vec4 ge_bvLumAbsMagAppMag;
|
||||
in vec3 vs_position;
|
||||
in vec2 texCoords;
|
||||
flat in float ge_bv;
|
||||
flat in vec3 ge_velocity;
|
||||
flat in float ge_speed;
|
||||
flat in float ge_observationDistance;
|
||||
flat in float gs_screenSpaceDepth;
|
||||
|
||||
vec4 bv2rgb(float bv) {
|
||||
@@ -59,32 +57,29 @@ vec4 bv2rgb(float bv) {
|
||||
}
|
||||
|
||||
bool isOtherDataValueInRange() {
|
||||
float t = (ge_bvLumAbsMagAppMag.x - otherDataRange.x) / (otherDataRange.y - otherDataRange.x);
|
||||
float t = (ge_bv - otherDataRange.x) / (otherDataRange.y - otherDataRange.x);
|
||||
return t >= 0.0 && t <= 1.0;
|
||||
}
|
||||
vec4 otherDataValue() {
|
||||
float t = (ge_bvLumAbsMagAppMag.x - otherDataRange.x) / (otherDataRange.y - otherDataRange.x);
|
||||
float t = (ge_bv - otherDataRange.x) / (otherDataRange.y - otherDataRange.x);
|
||||
t = clamp(t, 0.0, 1.0);
|
||||
return texture(otherDataTexture, t);
|
||||
}
|
||||
|
||||
Fragment getFragment() {
|
||||
// Something in the color calculations need to be changed because before it was dependent
|
||||
// on the gl blend functions since the abuffer was not involved
|
||||
|
||||
vec4 color = vec4(0.0);
|
||||
switch (colorOption) {
|
||||
case COLOROPTION_COLOR:
|
||||
color = bv2rgb(ge_bvLumAbsMagAppMag.x);
|
||||
case ColorOptionColor:
|
||||
color = bv2rgb(ge_bv);
|
||||
break;
|
||||
case COLOROPTION_VELOCITY:
|
||||
case ColorOptionVelocity:
|
||||
color = vec4(abs(ge_velocity), 0.5);
|
||||
break;
|
||||
case COLOROPTION_SPEED:
|
||||
case ColorOptionSpeed:
|
||||
// @TODO Include a transfer function here ---abock
|
||||
color = vec4(vec3(ge_speed), 0.5);
|
||||
break;
|
||||
case COLOROPTION_OTHERDATA:
|
||||
case ColorOptionOtherData:
|
||||
if (filterOutOfRange && !isOtherDataValueInRange()) {
|
||||
discard;
|
||||
}
|
||||
@@ -92,14 +87,13 @@ Fragment getFragment() {
|
||||
color = otherDataValue();
|
||||
}
|
||||
break;
|
||||
case COLOROPTION_FIXEDCOLOR:
|
||||
case ColorOptionFixedColor:
|
||||
color = vec4(fixedColor, 1.0);
|
||||
break;
|
||||
}
|
||||
|
||||
vec4 textureColor = texture(psfTexture, 0.5 * psfCoords + 0.5);
|
||||
vec4 fullColor = vec4(color.rgb, textureColor.a);
|
||||
fullColor.a *= alphaValue;
|
||||
vec4 textureColor = texture(psfTexture, texCoords);
|
||||
vec4 fullColor = vec4(color.rgb, textureColor.a * alphaValue);
|
||||
|
||||
if (fullColor.a < 0.001) {
|
||||
discard;
|
||||
@@ -108,7 +102,7 @@ Fragment getFragment() {
|
||||
Fragment frag;
|
||||
frag.color = fullColor;
|
||||
frag.depth = gs_screenSpaceDepth;
|
||||
frag.gPosition = vs_position;
|
||||
frag.gPosition = vec4(vs_position, 1.0);
|
||||
frag.gNormal = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
frag.disableLDR2HDR = true;
|
||||
|
||||
|
||||
+137
-102
@@ -24,7 +24,6 @@
|
||||
|
||||
#version __CONTEXT__
|
||||
|
||||
#include "floatoperations.glsl"
|
||||
#include "PowerScaling/powerScalingMath.hglsl"
|
||||
|
||||
layout(points) in;
|
||||
@@ -32,25 +31,20 @@ layout(triangle_strip, max_vertices = 4) out;
|
||||
|
||||
in vec4 vs_bvLumAbsMagAppMag[];
|
||||
in vec3 vs_velocity[];
|
||||
in vec4 vs_gPosition[];
|
||||
in float vs_speed[];
|
||||
|
||||
out vec4 vs_position;
|
||||
out vec2 psfCoords;
|
||||
out vec3 vs_position;
|
||||
out vec2 texCoords;
|
||||
|
||||
flat out vec4 ge_bvLumAbsMagAppMag;
|
||||
flat out float ge_bv;
|
||||
flat out vec3 ge_velocity;
|
||||
flat out float ge_speed;
|
||||
flat out float ge_observationDistance;
|
||||
flat out float gs_screenSpaceDepth;
|
||||
|
||||
uniform float magnitudeExponent;
|
||||
uniform dvec3 eyePosition;
|
||||
uniform dvec3 cameraUp;
|
||||
|
||||
// uniform float FWHM;
|
||||
// uniform float betaConstant;
|
||||
|
||||
uniform int psfParamConf;
|
||||
uniform float lumCent;
|
||||
uniform float radiusCent;
|
||||
@@ -62,127 +56,168 @@ uniform dmat4 modelMatrix;
|
||||
const double PARSEC = 3.08567756E16;
|
||||
//const double PARSEC = 3.08567782E16;
|
||||
|
||||
const vec2 corners[4] = vec2[4](
|
||||
vec2(0.0, 0.0),
|
||||
vec2(1.0, 0.0),
|
||||
vec2(1.0, 1.0),
|
||||
vec2(0.0, 1.0)
|
||||
);
|
||||
// FRAGILE
|
||||
// All of these values have to be synchronized with the values in the optionproperty
|
||||
const int SizeCompositionOptionAppBrightness = 0;
|
||||
const int SizeCompositionOptionLumSize = 1;
|
||||
const int SizeCompositionOptionLumSizeAppBrightness = 2;
|
||||
const int SizeCompositionOptionLumSizeAbsMagnitude = 3;
|
||||
const int SizeCompositionOptionLumSizeAppMagnitude = 4;
|
||||
const int SizeCompositionOptionLumSizeDistanceModulus = 5;
|
||||
|
||||
const float SunTemperature = 5800.0f;
|
||||
const float SunAbsMagnitude = 4.83f;
|
||||
const float SunTemperature = 5800.0;
|
||||
const float SunAbsMagnitude = 4.83;
|
||||
const float SunRadius = 6.957E8; // meters
|
||||
|
||||
float bvToKelvin(float bv) {
|
||||
float tmp = 0.92f * bv;
|
||||
return 4600.f * (1.f/(tmp+1.7f) +1.f/(tmp+0.62f));
|
||||
float tmp = 0.92 * bv;
|
||||
return 4600 * (1.f / (tmp + 1.7) + 1.f / (tmp + 0.62));
|
||||
}
|
||||
|
||||
double scaleForApparentBrightness(dvec3 dpos, float luminance) {
|
||||
// Working like Partiview
|
||||
double pSize = pow(10, 29.0 + magnitudeExponent);
|
||||
float luminosity = luminance * 10.0;
|
||||
double distanceToStar = length(dpos - eyePosition);
|
||||
return (pSize * luminosity) / distanceToStar;
|
||||
}
|
||||
|
||||
double scaleForLuminositySize(float bv, float luminance, float absMagnitude) {
|
||||
double adjustedLuminance = luminance + 5E9;
|
||||
float L_over_Lsun = pow(2.51, SunAbsMagnitude - absMagnitude);
|
||||
float temperature = bvToKelvin(bv);
|
||||
float relativeTemperature = SunTemperature / temperature;
|
||||
double starRadius = SunRadius * pow(relativeTemperature, 2.0) * sqrt(L_over_Lsun);
|
||||
return (lumCent * adjustedLuminance + (radiusCent * starRadius)) * pow(10.0, magnitudeExponent);
|
||||
}
|
||||
|
||||
double scaleForLuminositySizeAppBrightness(dvec3 dpos, float bv, float luminance, float absMagnitude) {
|
||||
double luminosity = double(1.0 - luminance);
|
||||
double distanceToStarInParsecs = trunc(length(dpos - eyePosition) / PARSEC);
|
||||
double apparentBrightness = luminosity / distanceToStarInParsecs;
|
||||
float L_over_Lsun = pow(2.51, SunAbsMagnitude - absMagnitude);
|
||||
float temperature = bvToKelvin(bv);
|
||||
float relativeTemperature = SunTemperature / temperature;
|
||||
double starRadius = SunRadius * pow(relativeTemperature, 2.0) * sqrt(L_over_Lsun);
|
||||
|
||||
double scaledLuminance = lumCent * (luminance + 5E9);
|
||||
double scaledStarRadius = radiusCent * starRadius;
|
||||
double scaledBrightness = brightnessCent * apparentBrightness * 5E15;
|
||||
return (scaledLuminance + scaledStarRadius + scaledBrightness) * pow(10.0, magnitudeExponent);
|
||||
}
|
||||
|
||||
double scaleForAbsoluteMagnitude(float absMagnitude) {
|
||||
return (-absMagnitude + 35) * pow(10.0, magnitudeExponent + 8.5);
|
||||
}
|
||||
|
||||
double scaleForApparentMagnitude(dvec3 dpos, float absMag) {
|
||||
double distanceToStarInMeters = length(dpos - eyePosition);
|
||||
double distanceToCenterInMeters = length(eyePosition);
|
||||
float distanceToStarInParsecs = float(distanceToStarInMeters/PARSEC);
|
||||
//float appMag = absMag + 5*log(distanceToStarInParsecs) - 5.0;
|
||||
float appMag = absMag + 5.0 * (log(distanceToStarInParsecs/10.0)/log(2.0));
|
||||
//appMag = vs_bvLumAbsMagAppMag[0].w;
|
||||
|
||||
//scaleMultiply = (30.623 - appMag) * pow(10.0, magnitudeExponent + 7.0);// *
|
||||
//float(distanceToStarInMeters/distanceToCenterInMeters);
|
||||
|
||||
return (-appMag + 50.f) * pow(10.0, magnitudeExponent + 7.5f);
|
||||
// return log(35.f + appMag) * pow(10.0, magnitudeExponent + 6.5f);
|
||||
// return exp((35.f - appMag) * 0.2) * pow(10.0, magnitudeExponent + 2.5f);
|
||||
// return appMag * pow(10.0, magnitudeExponent + 8.5f);
|
||||
// return exp((-30.0 - appMag) * 0.45) * pow(10.0, magnitudeExponent + 8.f);
|
||||
// return pow(10.0, (appMag - absMag)*(1.0/5.0) + 1.0) * pow(10.0, magnitudeExponent + 3.f);
|
||||
}
|
||||
|
||||
double scaleForDistanceModulus(float absMag) {
|
||||
return exp((-30.623 - absMag) * 0.462) * pow(10.0, magnitudeExponent + 12.5) * 2000;
|
||||
}
|
||||
|
||||
void main() {
|
||||
vs_position = gl_in[0].gl_Position; // in object space
|
||||
dvec4 dpos = modelMatrix * dvec4(vs_position);
|
||||
vec3 pos = gl_in[0].gl_Position.xyz;
|
||||
vs_position = pos; // in object space
|
||||
dvec4 dpos = modelMatrix * dvec4(pos, 1.0);
|
||||
|
||||
ge_bv = vs_bvLumAbsMagAppMag[0].x;
|
||||
ge_velocity = vs_velocity[0];
|
||||
ge_speed = vs_speed[0];
|
||||
|
||||
ge_bvLumAbsMagAppMag = vs_bvLumAbsMagAppMag[0];
|
||||
ge_velocity = vs_velocity[0];
|
||||
ge_speed = vs_speed[0];
|
||||
|
||||
double scaleMultiply = 1.0;
|
||||
|
||||
if (psfParamConf == 0) {
|
||||
// Working like Partiview
|
||||
double luminosity = double(ge_bvLumAbsMagAppMag.y) * 10.0;
|
||||
double pSize = pow(10, magnitudeExponent + 29.0);
|
||||
double distanceToStar = length((dpos.xyz - eyePosition));
|
||||
double apparentBrightness = pSize * luminosity / (distanceToStar);
|
||||
scaleMultiply = apparentBrightness;
|
||||
if (psfParamConf == SizeCompositionOptionAppBrightness) {
|
||||
float luminance = vs_bvLumAbsMagAppMag[0].y;
|
||||
|
||||
scaleMultiply = scaleForApparentBrightness(dpos.xyz, luminance);
|
||||
}
|
||||
else if (psfParamConf == 1) {
|
||||
float L_over_Lsun = pow(2.51f, SunAbsMagnitude - ge_bvLumAbsMagAppMag.z);
|
||||
float starTemperature = bvToKelvin(ge_bvLumAbsMagAppMag.x);
|
||||
float starRadius = SunRadius * pow(SunTemperature/starTemperature, 2.f) * sqrt(L_over_Lsun);
|
||||
scaleMultiply = ((lumCent * (ge_bvLumAbsMagAppMag.y + 5E9)) +
|
||||
(radiusCent * double(starRadius))) * pow(10.0, magnitudeExponent);
|
||||
else if (psfParamConf == SizeCompositionOptionLumSize) {
|
||||
float bv = vs_bvLumAbsMagAppMag[0].x;
|
||||
float luminance = vs_bvLumAbsMagAppMag[0].y;
|
||||
float absMagnitude = vs_bvLumAbsMagAppMag[0].z;
|
||||
|
||||
scaleMultiply = scaleForLuminositySize(bv, luminance, absMagnitude);
|
||||
}
|
||||
else if (psfParamConf == 2) {
|
||||
double luminosity = double(1.0 - ge_bvLumAbsMagAppMag.y);
|
||||
double distanceToStarInParsecs = trunc(length(dpos.xyz - eyePosition) / PARSEC);
|
||||
double apparentBrightness = luminosity / distanceToStarInParsecs;
|
||||
float L_over_Lsun = pow(2.51f, SunAbsMagnitude - ge_bvLumAbsMagAppMag.z);
|
||||
float starTemperature = bvToKelvin(ge_bvLumAbsMagAppMag.x);
|
||||
float starRadius = SunRadius * pow(SunTemperature/starTemperature, 2.f) *
|
||||
sqrt(L_over_Lsun);
|
||||
scaleMultiply = ((lumCent * (ge_bvLumAbsMagAppMag.y + 5E9)) +
|
||||
(radiusCent * double(starRadius)) +
|
||||
(brightnessCent * apparentBrightness * 5E15)) *
|
||||
pow(10.0, magnitudeExponent);
|
||||
else if (psfParamConf == SizeCompositionOptionLumSizeAppBrightness) {
|
||||
float bv = vs_bvLumAbsMagAppMag[0].x;
|
||||
float luminance = vs_bvLumAbsMagAppMag[0].y;
|
||||
float absMagnitude = vs_bvLumAbsMagAppMag[0].z;
|
||||
|
||||
scaleMultiply = scaleForLuminositySizeAppBrightness(dpos.xyz, bv, luminance, absMagnitude);
|
||||
}
|
||||
else if (psfParamConf == 3) {
|
||||
float absMag = ge_bvLumAbsMagAppMag.z;
|
||||
scaleMultiply = (-absMag + 35.f) * pow(10.0, magnitudeExponent + 8.5f);
|
||||
else if (psfParamConf == SizeCompositionOptionLumSizeAbsMagnitude) {
|
||||
float absMagnitude = vs_bvLumAbsMagAppMag[0].z;
|
||||
|
||||
scaleMultiply = scaleForAbsoluteMagnitude(absMagnitude);
|
||||
}
|
||||
else if (psfParamConf == 4) {
|
||||
float absMag = vs_bvLumAbsMagAppMag[0].z;
|
||||
double distanceToStarInMeters = length(dpos.xyz - eyePosition);
|
||||
double distanceToCenterInMeters = length(eyePosition);
|
||||
float distanceToStarInParsecs = float(distanceToStarInMeters/PARSEC);
|
||||
//float appMag = absMag + 5*log(distanceToStarInParsecs) - 5.0;
|
||||
float appMag = absMag + 5.0 * (log(distanceToStarInParsecs/10.0)/log(2.0));
|
||||
//appMag = vs_bvLumAbsMagAppMag[0].w;
|
||||
else if (psfParamConf == SizeCompositionOptionLumSizeAppMagnitude) {
|
||||
float absMagnitude = vs_bvLumAbsMagAppMag[0].z;
|
||||
|
||||
scaleMultiply = scaleForApparentMagnitude(dpos.xyz, absMagnitude);
|
||||
}
|
||||
else if (psfParamConf == SizeCompositionOptionLumSizeDistanceModulus) {
|
||||
float absMagnitude = vs_bvLumAbsMagAppMag[0].z;
|
||||
|
||||
//scaleMultiply = (30.623 - appMag) * pow(10.0, magnitudeExponent + 7.0);// *
|
||||
//float(distanceToStarInMeters/distanceToCenterInMeters);
|
||||
|
||||
//scaleMultiply = (-appMag + 50.f) * pow(10.0, magnitudeExponent + 7.5f);
|
||||
//scaleMultiply = log(35.f + appMag) * pow(10.0, magnitudeExponent + 6.5f);
|
||||
//scaleMultiply = exp((35.f - appMag) * 0.2) * pow(10.0, magnitudeExponent + 2.5f);
|
||||
//scaleMultiply = appMag * pow(10.0, magnitudeExponent + 8.5f);
|
||||
scaleMultiply = exp((-30.0 - appMag) * 0.45) * pow(10.0, magnitudeExponent + 8.f);
|
||||
//scaleMultiply = pow(10.0, (appMag - absMag)*(1.0/5.0) + 1.0) * pow(10.0, magnitudeExponent + 3.f);
|
||||
}
|
||||
else if (psfParamConf == 5) {
|
||||
float absMag = ge_bvLumAbsMagAppMag.z;
|
||||
scaleMultiply = exp((-30.623 - absMag) * 0.462) * pow(10.0, magnitudeExponent + 12.5f) * 2000;
|
||||
scaleMultiply = scaleForDistanceModulus(absMagnitude);
|
||||
}
|
||||
|
||||
dvec3 scaledRight = dvec3(0.0);
|
||||
dvec3 scaledUp = dvec3(0.0);
|
||||
vec4 bottomLeftVertex, bottomRightVertex, topLeftVertex, topRightVertex;
|
||||
|
||||
dvec3 normal = normalize(eyePosition - dpos.xyz);
|
||||
dvec3 normal = eyePosition - dpos.xyz;
|
||||
dvec3 newRight = normalize(cross(cameraUp, normal));
|
||||
dvec3 newUp = cross(normal, newRight);
|
||||
scaledRight = scaleMultiply * newRight;
|
||||
scaledUp = scaleMultiply * newUp;
|
||||
dvec3 newUp = normalize(cross(normal, newRight));
|
||||
dvec3 scaledRight = scaleMultiply * newRight;
|
||||
dvec3 scaledUp = scaleMultiply * newUp;
|
||||
|
||||
bottomLeftVertex = z_normalization(vec4(cameraViewProjectionMatrix *
|
||||
dvec4(dpos.xyz - scaledRight - scaledUp, dpos.w)));
|
||||
gs_screenSpaceDepth = bottomLeftVertex.w;
|
||||
vec4 lowerLeft = z_normalization(
|
||||
vec4(cameraViewProjectionMatrix * dvec4(dpos.xyz - scaledRight - scaledUp, dpos.w))
|
||||
);
|
||||
|
||||
topRightVertex = z_normalization(vec4(cameraViewProjectionMatrix *
|
||||
dvec4(dpos.xyz + scaledUp + scaledRight, dpos.w)));
|
||||
vec4 upperRight = z_normalization(
|
||||
vec4(cameraViewProjectionMatrix * dvec4(dpos.xyz + scaledUp + scaledRight, dpos.w))
|
||||
);
|
||||
|
||||
bottomRightVertex = z_normalization(vec4(cameraViewProjectionMatrix *
|
||||
dvec4(dpos.xyz + scaledRight - scaledUp, dpos.w)));
|
||||
vec4 lowerRight = z_normalization(
|
||||
vec4(cameraViewProjectionMatrix * dvec4(dpos.xyz + scaledRight - scaledUp, dpos.w))
|
||||
);
|
||||
|
||||
topLeftVertex = z_normalization(vec4(cameraViewProjectionMatrix *
|
||||
dvec4(dpos.xyz + scaledUp - scaledRight, dpos.w)));
|
||||
|
||||
// Build primitive
|
||||
|
||||
gl_Position = bottomLeftVertex;
|
||||
psfCoords = vec2(-1.0, -1.0);
|
||||
vec4 upperLeft = z_normalization(
|
||||
vec4(cameraViewProjectionMatrix * dvec4(dpos.xyz + scaledUp - scaledRight, dpos.w))
|
||||
);
|
||||
|
||||
gs_screenSpaceDepth = lowerLeft.w;
|
||||
|
||||
// Build primitive
|
||||
gl_Position = lowerLeft;
|
||||
texCoords = vec2(0.0, 0.0);
|
||||
EmitVertex();
|
||||
|
||||
gl_Position = bottomRightVertex;
|
||||
psfCoords = vec2(1.0, -1.0);
|
||||
gl_Position = lowerRight;
|
||||
texCoords = vec2(1.0,0.0);
|
||||
EmitVertex();
|
||||
|
||||
gl_Position = topLeftVertex;
|
||||
psfCoords = vec2(-1.0, 1.0);
|
||||
gl_Position = upperLeft;
|
||||
texCoords = vec2(0.0, 1.0);
|
||||
EmitVertex();
|
||||
|
||||
gl_Position = topRightVertex;
|
||||
psfCoords = vec2(1.0, 1.0);
|
||||
gl_Position = upperRight;
|
||||
texCoords = vec2(1.0, 1.0);
|
||||
EmitVertex();
|
||||
|
||||
EndPrimitive();
|
||||
|
||||
@@ -24,8 +24,6 @@
|
||||
|
||||
#version __CONTEXT__
|
||||
|
||||
#include "PowerScaling/powerScaling_vs.hglsl"
|
||||
|
||||
in vec3 in_position;
|
||||
in vec4 in_bvLumAbsMagAppMag;
|
||||
in vec3 in_velocity;
|
||||
@@ -37,8 +35,8 @@ out float vs_speed;
|
||||
|
||||
void main() {
|
||||
vs_bvLumAbsMagAppMag = in_bvLumAbsMagAppMag;
|
||||
vs_velocity = in_velocity;
|
||||
vs_speed = in_speed;
|
||||
vs_velocity = in_velocity;
|
||||
vs_speed = in_speed;
|
||||
|
||||
gl_Position = vec4(in_position, 1.0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user