mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-12 14:29:42 -05:00
Temporarilly moved star's rendering back to original one in order to avoid unkown night sky for non-stereo users.
This commit is contained in:
@@ -29,10 +29,7 @@ local object = {
|
||||
Type = "RenderableStars",
|
||||
File = speck .. "/stars.speck",
|
||||
Texture = textures .. "/halo.png",
|
||||
ColorMap = colorLUT .. "/colorbv.cmap",
|
||||
MagnitudeExponent = 19,
|
||||
BillboardSize = 30,
|
||||
Sharpness = 1.3
|
||||
ColorMap = colorLUT .. "/colorbv.cmap"
|
||||
},
|
||||
GUI = {
|
||||
Path = "/Milky Way/Stars"
|
||||
@@ -41,4 +38,4 @@ local object = {
|
||||
|
||||
|
||||
|
||||
assetHelper.registerSceneGraphNodesAndExport(asset, { object })
|
||||
assetHelper.registerSceneGraphNodesAndExport(asset, { object })
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,26 +1,26 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2018 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2018 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __OPENSPACE_MODULE_SPACE___RENDERABLESTARS___H__
|
||||
#define __OPENSPACE_MODULE_SPACE___RENDERABLESTARS___H__
|
||||
@@ -42,68 +42,68 @@ namespace ghoul::opengl {
|
||||
|
||||
namespace openspace {
|
||||
|
||||
namespace documentation { struct Documentation; }
|
||||
namespace documentation { struct Documentation; }
|
||||
|
||||
class RenderableStars : public Renderable {
|
||||
public:
|
||||
explicit RenderableStars(const ghoul::Dictionary& dictionary);
|
||||
~RenderableStars();
|
||||
class RenderableStars : public Renderable {
|
||||
public:
|
||||
explicit RenderableStars(const ghoul::Dictionary& dictionary);
|
||||
~RenderableStars();
|
||||
|
||||
void initializeGL() override;
|
||||
void deinitializeGL() override;
|
||||
void initializeGL() override;
|
||||
void deinitializeGL() override;
|
||||
|
||||
bool isReady() const override;
|
||||
bool isReady() const override;
|
||||
|
||||
void render(const RenderData& data, RendererTasks& rendererTask) override;
|
||||
void update(const UpdateData& data) override;
|
||||
void render(const RenderData& data, RendererTasks& rendererTask) override;
|
||||
void update(const UpdateData& data) override;
|
||||
|
||||
static documentation::Documentation Documentation();
|
||||
static documentation::Documentation Documentation();
|
||||
|
||||
private:
|
||||
enum ColorOption {
|
||||
Color = 0,
|
||||
Velocity = 1,
|
||||
Speed = 2
|
||||
private:
|
||||
enum ColorOption {
|
||||
Color = 0,
|
||||
Velocity = 1,
|
||||
Speed = 2
|
||||
};
|
||||
|
||||
void createDataSlice(ColorOption option);
|
||||
|
||||
bool loadData();
|
||||
bool readSpeckFile();
|
||||
bool loadCachedFile(const std::string& file);
|
||||
bool saveCachedFile(const std::string& file) const;
|
||||
|
||||
properties::StringProperty _pointSpreadFunctionTexturePath;
|
||||
std::unique_ptr<ghoul::opengl::Texture> _pointSpreadFunctionTexture;
|
||||
std::unique_ptr<ghoul::filesystem::File> _pointSpreadFunctionFile;
|
||||
bool _pointSpreadFunctionTextureIsDirty;
|
||||
|
||||
properties::StringProperty _colorTexturePath;
|
||||
std::unique_ptr<ghoul::opengl::Texture> _colorTexture;
|
||||
std::unique_ptr<ghoul::filesystem::File> _colorTextureFile;
|
||||
bool _colorTextureIsDirty;
|
||||
|
||||
properties::OptionProperty _colorOption;
|
||||
bool _dataIsDirty;
|
||||
|
||||
properties::FloatProperty _alphaValue;
|
||||
properties::FloatProperty _scaleFactor;
|
||||
properties::FloatProperty _minBillboardSize;
|
||||
|
||||
std::unique_ptr<ghoul::opengl::ProgramObject> _program;
|
||||
UniformCache(view, projection, colorOption, alphaValue, scaleFactor,
|
||||
minBillboardSize, screenSize, scaling, psfTexture, colorTexture) _uniformCache;
|
||||
|
||||
std::string _speckFile;
|
||||
|
||||
std::vector<float> _slicedData;
|
||||
std::vector<float> _fullData;
|
||||
int _nValuesPerStar;
|
||||
|
||||
GLuint _vao;
|
||||
GLuint _vbo;
|
||||
};
|
||||
|
||||
void createDataSlice(ColorOption option);
|
||||
|
||||
bool loadData();
|
||||
bool readSpeckFile();
|
||||
bool loadCachedFile(const std::string& file);
|
||||
bool saveCachedFile(const std::string& file) const;
|
||||
|
||||
properties::StringProperty _pointSpreadFunctionTexturePath;
|
||||
std::unique_ptr<ghoul::opengl::Texture> _pointSpreadFunctionTexture;
|
||||
std::unique_ptr<ghoul::filesystem::File> _pointSpreadFunctionFile;
|
||||
bool _pointSpreadFunctionTextureIsDirty;
|
||||
|
||||
properties::StringProperty _colorTexturePath;
|
||||
std::unique_ptr<ghoul::opengl::Texture> _colorTexture;
|
||||
std::unique_ptr<ghoul::filesystem::File> _colorTextureFile;
|
||||
bool _colorTextureIsDirty;
|
||||
|
||||
properties::OptionProperty _colorOption;
|
||||
bool _dataIsDirty;
|
||||
|
||||
properties::FloatProperty _magnitudeExponent;
|
||||
properties::FloatProperty _sharpness;
|
||||
properties::FloatProperty _billboardSize;
|
||||
|
||||
std::unique_ptr<ghoul::opengl::ProgramObject> _program;
|
||||
UniformCache(model, view, viewScaling, projection, colorOption, magnitudeExponent, sharpness,
|
||||
billboardSize, screenSize, scaling, psfTexture, colorTexture) _uniformCache;
|
||||
|
||||
std::string _speckFile;
|
||||
|
||||
std::vector<float> _slicedData;
|
||||
std::vector<float> _fullData;
|
||||
int _nValuesPerStar;
|
||||
|
||||
GLuint _vao;
|
||||
GLuint _vbo;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __OPENSPACE_MODULE_SPACE___RENDERABLESTARS___H__
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
****************************************************************************************/
|
||||
|
||||
#include "fragment.glsl"
|
||||
#include "floatoperations.glsl"
|
||||
#include "PowerScaling/powerScaling_fs.hglsl"
|
||||
|
||||
// keep in sync with renderablestars.h:ColorOption enum
|
||||
const int COLOROPTION_COLOR = 0;
|
||||
@@ -32,11 +32,10 @@ const int COLOROPTION_SPEED = 2;
|
||||
|
||||
uniform sampler2D psfTexture;
|
||||
uniform sampler1D colorTexture;
|
||||
uniform float minBillboardSize;
|
||||
|
||||
uniform float magnitudeExponent;
|
||||
uniform float sharpness;
|
||||
uniform float alphaValue;
|
||||
uniform int colorOption;
|
||||
uniform vec3 eyePosition;
|
||||
|
||||
in vec4 vs_position;
|
||||
in vec4 ge_gPosition;
|
||||
@@ -44,8 +43,13 @@ in vec3 ge_brightness;
|
||||
in vec3 ge_velocity;
|
||||
in float ge_speed;
|
||||
in vec2 texCoord;
|
||||
in float ge_observationDistance;
|
||||
in vec4 ge_worldPosition;
|
||||
in float billboardSize;
|
||||
|
||||
#include "fragment.glsl"
|
||||
//#include "PowerScaling/powerScaling_fs.hglsl"
|
||||
|
||||
uniform vec2 magnitudeClamp;
|
||||
|
||||
|
||||
vec4 bv2rgb(float bv) {
|
||||
// BV is [-0.4,2.0]
|
||||
@@ -56,7 +60,7 @@ vec4 bv2rgb(float bv) {
|
||||
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:
|
||||
@@ -73,15 +77,19 @@ Fragment getFragment() {
|
||||
|
||||
vec4 textureColor = texture(psfTexture, texCoord);
|
||||
vec4 fullColor = vec4(color.rgb, textureColor.a);
|
||||
fullColor.a = pow(fullColor.a, sharpness);
|
||||
fullColor.a *= alphaValue;
|
||||
|
||||
float d = magnitudeExponent - log(ge_observationDistance) / log(10.0);
|
||||
fullColor.a *= clamp(d, 0.0, 1.0);
|
||||
vec4 position = vs_position;
|
||||
// This has to be fixed when the scale graph is in place ---emiax
|
||||
position.w = 15;
|
||||
|
||||
Fragment frag;
|
||||
frag.color = fullColor;
|
||||
frag.depth = safeLength(vs_position);
|
||||
frag.depth = pscDepth(position);
|
||||
|
||||
// G-Buffer
|
||||
frag.gPosition = ge_gPosition;
|
||||
// There is no normal here
|
||||
frag.gNormal = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
|
||||
if (fullColor.a == 0) {
|
||||
@@ -89,4 +97,4 @@ Fragment getFragment() {
|
||||
}
|
||||
|
||||
return frag;
|
||||
}
|
||||
}
|
||||
@@ -24,15 +24,15 @@
|
||||
|
||||
#version __CONTEXT__
|
||||
|
||||
#include "floatoperations.glsl"
|
||||
#include "PowerScaling/powerScalingMath.hglsl"
|
||||
|
||||
layout(points) in;
|
||||
|
||||
in vec4 psc_position[];
|
||||
in vec3 vs_brightness[];
|
||||
in vec3 vs_velocity[];
|
||||
in vec4 vs_gPosition[];
|
||||
in float vs_speed[];
|
||||
in vec4 vs_worldPosition[];
|
||||
in vec4 cam_position[];
|
||||
|
||||
layout(triangle_strip, max_vertices = 4) out;
|
||||
|
||||
@@ -42,14 +42,13 @@ out vec3 ge_brightness;
|
||||
out vec3 ge_velocity;
|
||||
out float ge_speed;
|
||||
out vec2 texCoord;
|
||||
out float ge_observationDistance;
|
||||
out vec4 ge_worldPosition;
|
||||
out float billboardSize;
|
||||
|
||||
uniform mat4 projection;
|
||||
|
||||
uniform float viewScaling;
|
||||
uniform float scaleFactor;
|
||||
uniform float billboardSize;
|
||||
uniform float minBillboardSize;
|
||||
uniform vec2 screenSize;
|
||||
uniform vec3 eyePosition;
|
||||
|
||||
const vec2 corners[4] = vec2[4](
|
||||
vec2(0.0, 1.0),
|
||||
@@ -58,77 +57,52 @@ const vec2 corners[4] = vec2[4](
|
||||
vec2(1.0, 0.0)
|
||||
);
|
||||
|
||||
void main() {
|
||||
|
||||
if ((vs_worldPosition[0].x == 0.0) &&
|
||||
(vs_worldPosition[0].y == 0.0) &&
|
||||
(vs_worldPosition[0].z == 0.0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
void main() {
|
||||
// JCC: We want to display the Sun.
|
||||
// if ((psc_position[0].x == 0.0) &&
|
||||
// (psc_position[0].y == 0.0) &&
|
||||
// (psc_position[0].z == 0.0))
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
|
||||
ge_brightness = vs_brightness[0];
|
||||
ge_velocity = vs_velocity[0];
|
||||
ge_speed = vs_speed[0];
|
||||
ge_worldPosition = vs_worldPosition[0];
|
||||
|
||||
vec4 projectedPoint = gl_in[0].gl_Position;
|
||||
|
||||
float distanceToStarInParsecs = length(ge_worldPosition.xyz / 3.0856776E16 - eyePosition / 3.0856776E16);
|
||||
float absoluteMagnitude = vs_brightness[0].z;
|
||||
float modifiedSpriteSize =
|
||||
exp((-30.623 - absoluteMagnitude) * 0.462) * scaleFactor * 2000;
|
||||
|
||||
float luminosity = ge_brightness.y;
|
||||
|
||||
// Working like Partiview
|
||||
float pSize = 3.0E5;
|
||||
float slum = 1.0;
|
||||
float samplingFactor = 1.0;
|
||||
float apparentBrightness = (pSize * slum * samplingFactor * luminosity) / (distanceToStarInParsecs * distanceToStarInParsecs);
|
||||
|
||||
vec2 multiplier = vec2(apparentBrightness * projectedPoint.w);
|
||||
|
||||
// Max Star Sizes:
|
||||
// Fragment Coords:
|
||||
vec2 bottomLeft = screenSize * ((projectedPoint.xy + vec2(multiplier) * corners[1])/projectedPoint.w + vec2(1.0)) - vec2(0.5);
|
||||
vec2 topRight = screenSize * ((projectedPoint.xy + vec2(multiplier) * corners[2])/projectedPoint.w + vec2(1.0)) - vec2(0.5);
|
||||
vec4 projPos[4];
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
vec4 p1 = gl_in[0].gl_Position;
|
||||
p1.xy += vec2(modifiedSpriteSize * (corners[i] - vec2(0.5)));
|
||||
projPos[i] = projection * p1;
|
||||
}
|
||||
|
||||
float height = abs(topRight.y - bottomLeft.y);
|
||||
float width = abs(topRight.x - bottomLeft.x);
|
||||
float var = (height + width);
|
||||
// Calculate the positions of the lower left and upper right corners of the
|
||||
// billboard in screen-space
|
||||
vec2 ll = (((projPos[1].xy / projPos[1].w) + 1.0) / 2.0) * screenSize;
|
||||
vec2 ur = (((projPos[2].xy / projPos[2].w) + 1.0) / 2.0) * screenSize;
|
||||
|
||||
float maxBillboardSize = billboardSize;
|
||||
float minBillboardSize = 1.0;
|
||||
// The billboard is smaller than one pixel, we can discard it
|
||||
float sizeInPixels = length(ll - ur);
|
||||
if (sizeInPixels < minBillboardSize) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ((height > maxBillboardSize) ||
|
||||
(width > maxBillboardSize)) {
|
||||
//if (height > maxBillboardSize) {
|
||||
float correctionScale = height > maxBillboardSize ? maxBillboardSize / (topRight.y - bottomLeft.y) :
|
||||
maxBillboardSize / (topRight.x - bottomLeft.x);
|
||||
multiplier *= correctionScale;
|
||||
} else {
|
||||
if (width < 2.0f * minBillboardSize) {
|
||||
float maxVar = 2.0f * minBillboardSize;
|
||||
float minVar = minBillboardSize;
|
||||
float ta = ( (var - minVar)/(maxVar - minVar) );
|
||||
if (ta == 0.0f)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
vec2 starSize = multiplier;
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
vs_position = gl_in[0].gl_Position;
|
||||
gl_Position = projectedPoint + vec4(starSize * (corners[i] - 0.5), 0.0, 0.0);
|
||||
gl_Position.z = 0.0;
|
||||
|
||||
gl_Position = projPos[i];
|
||||
texCoord = corners[i];
|
||||
|
||||
// G-Buffer
|
||||
ge_gPosition = vs_gPosition[0];
|
||||
ge_observationDistance = safeLength(vs_gPosition[0] / viewScaling);
|
||||
|
||||
billboardSize = sizeInPixels;
|
||||
EmitVertex();
|
||||
}
|
||||
|
||||
EndPrimitive();
|
||||
}
|
||||
}
|
||||
@@ -31,25 +31,30 @@ in vec3 in_brightness;
|
||||
in vec3 in_velocity;
|
||||
in float in_speed;
|
||||
|
||||
out vec4 psc_position;
|
||||
out vec3 vs_brightness;
|
||||
out vec3 vs_velocity;
|
||||
out float vs_speed;
|
||||
out vec4 vs_gPosition;
|
||||
out vec4 vs_worldPosition;
|
||||
|
||||
uniform mat4 model;
|
||||
uniform mat4 view;
|
||||
uniform mat4 projection;
|
||||
|
||||
|
||||
void main() {
|
||||
vec4 p = in_position;
|
||||
psc_position = p;
|
||||
vs_brightness = in_brightness;
|
||||
vs_velocity = in_velocity;
|
||||
vs_speed = in_speed;
|
||||
|
||||
vec3 modelPosition = in_position.xyz;
|
||||
vs_worldPosition = model * vec4(modelPosition, 1.0);
|
||||
vec4 viewPosition = view * vs_worldPosition;
|
||||
|
||||
vs_gPosition = viewPosition;
|
||||
gl_Position = projection * vs_gPosition;
|
||||
}
|
||||
vec4 tmp = p;
|
||||
vec4 position = pscTransform(tmp, mat4(1.0));
|
||||
|
||||
// G-Buffer
|
||||
vs_gPosition = view * (vec4(1E19, 1E19, 1E19, 1.0) * position);
|
||||
|
||||
position = view * position;
|
||||
|
||||
gl_Position = position;
|
||||
}
|
||||
Reference in New Issue
Block a user