Added new data, new RenderableBillboardsCloud renderable, added and fixed multiple shaders.

This commit is contained in:
Jonathas Costa
2017-09-22 08:12:45 -04:00
parent 653001f8a4
commit 74f0da9033
24 changed files with 2142 additions and 56 deletions

View File

@@ -77,16 +77,29 @@ function postInitialization()
openspace.setPropertyValue("SunGlare.renderable.Enabled", false)
openspace.setPropertyValue("SunMarker.renderable.Enabled", false)
-- DU Objects
openspace.setPropertyValue("Quasars.renderable.Enabled", false)
openspace.setPropertyValue("WMAP.renderable.Enabled", false)
openspace.setPropertyValue("Pulsars.renderable.Enabled", false)
openspace.setPropertyValue("Kepler Planetary Candidates.renderable.Enabled", false)
openspace.setPropertyValue("Globular Clusters.renderable.Enabled", false)
openspace.setPropertyValue("Constellation Bounds.renderable.Enabled", false)
openspace.setPropertyValue("Constellation Bounds.renderable.Enabled", false)
-- Digital Universe
openspace.setPropertyValue("WMAP.renderable.Enabled", false)
openspace.setPropertyValue("Quasars.renderable.Enabled", false)
openspace.setPropertyValue("Pulsars.renderable.Enabled", false)
openspace.setPropertyValue("Globular Clusters.renderable.Enabled", false)
openspace.setPropertyValue("Kepler Planetary Candidates.renderable.Enabled", false)
openspace.setPropertyValue("Local Dwarf Galaxies.renderable.Enabled", false)
openspace.setPropertyValue("Exoplanets.renderable.Enabled", false)
openspace.setPropertyValue("Sloan Digital Sky Survey Galaxies.renderable.Enabled", false)
openspace.setPropertyValue("Planetary Nebulae.renderable.Enabled", false)
openspace.setPropertyValue("OB Associations.renderable.Enabled", false)
openspace.setPropertyValue("Open Star Clusters.renderable.Enabled", false)
openspace.setPropertyValue("Supernova Remnants.renderable.Enabled", false)
openspace.setPropertyValue("HII Regions.renderable.Enabled", false)
openspace.setPropertyValue("Abell Galaxy Clusters.renderable.Enabled", false)
openspace.setPropertyValue("2MASS Galaxies.renderable.Enabled", false)
openspace.setPropertyValue("6dF Galaxies.renderable.Enabled", false)
openspace.setPropertyValue("2dF Galaxies.renderable.Enabled", false)
openspace.setPropertyValue("Earth.RenderableGlobe.Atmosphere", true)
openspace.setPropertyValue("Earth.RenderableGlobe.Debug.LevelByProjectedAreaElseDistance", false)
@@ -132,10 +145,22 @@ return {
"constellationbounds",
"grids",
"quasars/digitaluniverse",
"pulsars/digitaluniverse",
"backgroundradiation/digitaluniverse",
"globularclusters/digitaluniverse",
"kepler/digitaluniverse"
"kepler/digitaluniverse",
"pulsars/digitaluniverse",
"localdwarfs/digitaluniverse",
"exoplanets/digitaluniverse",
"sloandss/digitaluniverse",
"openclusters/digitaluniverse",
"obassociations/digitaluniverse",
"planetarynebulae/digitaluniverse",
"supernovaremnants/digitaluniverse",
"h2regions/digitaluniverse",
"abell/digitaluniverse",
"2mass/digitaluniverse",
"6dF/digitaluniverse",
"2dF/digitaluniverse",
}
}

View File

@@ -28,21 +28,34 @@ set(HEADER_FILES
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablepointssprite.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablepoints.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderabledumeshes.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablebillboardscloud.h
)
source_group("Header Files" FILES ${HEADER_FILES})
set(SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablepointssprite.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablepoints.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderabledumeshes.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderabledumeshes.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablebillboardscloud.cpp
)
source_group("Source Files" FILES ${SOURCE_FILES})
set(SHADER_FILES
${CMAKE_CURRENT_SOURCE_DIR}/shaders/pointssprite_fs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/pointssprite_vs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/points_sprite_fs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/points_fs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/points_gs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/points_vs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/billboard_fs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/billboard_gs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/billboard_vs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/billboard2_fs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/billboard2_gs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/billboard2_vs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/billboardpolygon_fs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/billboardpolygon_gs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/billboardpolygon_vs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/dumesh_vs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/dumesh_fs.glsl
)

View File

@@ -32,6 +32,7 @@
#include <ghoul/misc/assert.h>
#include <modules/digitaluniverse/rendering/renderablepoints.h>
#include <modules/digitaluniverse/rendering/renderablebillboardscloud.h>
//#include <modules/digitaluniverse/rendering/renderablepointssprite.h>
#include <modules/digitaluniverse/rendering/renderabledumeshes.h>
@@ -46,6 +47,7 @@ void DigitalUniverseModule::internalInitialize() {
ghoul_assert(fRenderable, "Renderable factory was not created");
fRenderable->registerClass<RenderablePoints>("RenderablePoints");
fRenderable->registerClass<RenderableBillboardsCloud>("RenderableBillboardsCloud");
//fRenderable->registerClass<RenderablePointsSprite>("RenderablePointsSprite");
fRenderable->registerClass<RenderableDUMeshes>("RenderableDUMeshes");
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,139 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2017 *
* *
* 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_DIGITALUNIVERSE___RENDERABLEBILLBOARDSCLOUD___H__
#define __OPENSPACE_MODULE_DIGITALUNIVERSE___RENDERABLEBILLBOARDSCLOUD___H__
#include <openspace/rendering/renderable.h>
#include <openspace/properties/optionproperty.h>
#include <openspace/properties/stringproperty.h>
#include <openspace/properties/scalar/boolproperty.h>
#include <openspace/properties/scalar/floatproperty.h>
#include <openspace/properties/vector/vec3property.h>
#include <ghoul/opengl/ghoul_gl.h>
#include <functional>
namespace ghoul::filesystem {
class File;
}
namespace ghoul::opengl {
class ProgramObject;
class Texture;
} // namespace ghoul::opengl
namespace openspace {
namespace documentation { struct Documentation; }
class RenderableBillboardsCloud : public Renderable {
public:
explicit RenderableBillboardsCloud(const ghoul::Dictionary& dictionary);
~RenderableBillboardsCloud() = default;
void initialize() override;
void deinitialize() override;
bool isReady() const override;
void render(const RenderData& data, RendererTasks& rendererTask) override;
void update(const UpdateData& data) override;
static documentation::Documentation Documentation();
private:
enum Unit {
Meter = 0,
Kilometer = 1,
Parsec = 2,
Kiloparsec = 3,
Megaparsec = 4,
Gigaparsec = 5,
GigalightYears = 6
};
void createDataSlice();
void createPolygonTexture();
void createTextTexture();
void renderToTexture(std::function<GLuint(void)> geometryLoadingFunction,
std::function<void(GLuint)> renderFunction,
GLuint textureToRenderTo, GLuint textureWidth, GLuint textureHeight);
GLuint loadPolygonGeometryForRendering();
void renderPolygonGeometry(GLuint vao);
GLuint loadTextGeometryForRendering();
void renderTextgonGeometry(GLuint vao);
bool loadData();
bool readSpeckFile();
bool readColorMapFile();
bool loadCachedFile(const std::string& file);
bool saveCachedFile(const std::string& file) const;
void saveTextureToPPMFile(const GLenum color_buffer_attachment,
const std::string & fileName, const int width, const int height) const;
bool _dataIsDirty;
bool _hasSpriteTexture;
bool _spriteTextureIsDirty;
bool _hasColorMapFile;
bool _hasPolygon;
int _polygonSides;
GLuint _pTexture;
GLuint _tTexture;
properties::FloatProperty _alphaValue;
properties::FloatProperty _scaleFactor;
properties::Vec3Property _pointColor;
properties::StringProperty _spriteTexturePath;
std::unique_ptr<ghoul::opengl::Texture> _polygonTexture;
std::unique_ptr<ghoul::opengl::Texture> _spriteTexture;
std::unique_ptr<ghoul::filesystem::File> _spriteTextureFile;
std::unique_ptr<ghoul::opengl::ProgramObject> _program;
//std::unique_ptr<ghoul::fontrendering::FontRenderer> _fontRenderer;
std::string _speckFile;
std::string _colorMapFile;
Unit _unit;
std::vector<float> _slicedData;
std::vector<float> _fullData;
std::vector<glm::vec4> _colorMapData;
int _nValuesPerAstronomicalObject;
GLuint _vao;
GLuint _vbo;
};
} // namespace openspace
#endif // __OPENSPACE_MODULE_DIGITALUNIVERSE___RENDERABLEBILLBOARDSCLOUD___H__

View File

@@ -40,6 +40,8 @@
#include <array>
#include <fstream>
#include <stdint.h>
#include <locale>
#include <string>
namespace {
const char* _loggerCat = "RenderablePoints";
@@ -56,6 +58,12 @@ namespace {
const int8_t CurrentCacheVersion = 1;
const double PARSEC = 0.308567756E17;
static const openspace::properties::Property::PropertyInfo SpriteTextureInfo = {
"Texture",
"Point Sprite Texture",
"The path to the texture that should be used as the point sprite."
};
static const openspace::properties::Property::PropertyInfo TransparencyInfo = {
"Transparency",
@@ -75,7 +83,13 @@ namespace {
"Color",
"Color",
"This value is used to define the color of the astronomical object."
};
};
static const openspace::properties::Property::PropertyInfo ColorMapInfo = {
"ColorMap",
"Color Map File",
"The path to the color map file of the astronomical onject."
};
} // namespace
namespace openspace {
@@ -104,10 +118,16 @@ namespace openspace {
Optional::No,
"Astronomical Object Color (r,g,b)."
},
{
SpriteTextureInfo.identifier,
new StringVerifier,
Optional::Yes,
SpriteTextureInfo.description
},
{
TransparencyInfo.identifier,
new DoubleVerifier,
Optional::Yes,
Optional::No,
TransparencyInfo.description
},
{
@@ -115,7 +135,14 @@ namespace openspace {
new DoubleVerifier,
Optional::Yes,
ScaleFactorInfo.description
}
},
{
ColorMapInfo.identifier,
new StringVerifier,
Optional::Yes,
ColorMapInfo.description
},
}
};
}
@@ -124,11 +151,17 @@ namespace openspace {
RenderablePoints::RenderablePoints(const ghoul::Dictionary& dictionary)
: Renderable(dictionary)
, _dataIsDirty(true)
, _hasSpriteTexture(false)
, _spriteTextureIsDirty(true)
, _hasColorMapFile(false)
, _alphaValue(TransparencyInfo, 1.f, 0.f, 1.f)
, _scaleFactor(ScaleFactorInfo, 1.f, 0.f, 64.f)
, _pointColor(ColorInfo, glm::vec3(1.f, 0.4f, 0.2f), glm::vec3(0.f, 0.f, 0.f), glm::vec3(1.0f, 1.0f, 1.0f))
, _spriteTexturePath(SpriteTextureInfo)
, _spriteTexture(nullptr)
, _program(nullptr)
, _speckFile("")
, _colorMapFile("")
, _unit(Parsec)
, _nValuesPerAstronomicalObject(0)
, _vao(0)
@@ -143,8 +176,7 @@ namespace openspace {
);
_speckFile = absPath(dictionary.value<std::string>(KeyFile));
if (dictionary.hasKey(keyUnit)) {
std::string unit = dictionary.value<std::string>(keyUnit);
if (unit == MeterUnit) {
@@ -179,6 +211,28 @@ namespace openspace {
}
addProperty(_pointColor);
if (dictionary.hasKey(SpriteTextureInfo.identifier)) {
_spriteTexturePath = absPath(dictionary.value<std::string>(
SpriteTextureInfo.identifier
));
_spriteTextureFile = std::make_unique<File>(_spriteTexturePath);
_spriteTexturePath.onChange([&] { _spriteTextureIsDirty = true; });
_spriteTextureFile->setCallback(
[&](const File&) { _spriteTextureIsDirty = true; }
);
addProperty(_spriteTexturePath);
_hasSpriteTexture = true;
}
if (dictionary.hasKey(ColorMapInfo.identifier)) {
_colorMapFile = absPath(dictionary.value<std::string>(
ColorMapInfo.identifier
));
_hasColorMapFile = true;
}
if (dictionary.hasKey(TransparencyInfo.identifier)) {
_alphaValue = static_cast<float>(
dictionary.value<double>(TransparencyInfo.identifier)
@@ -201,11 +255,18 @@ namespace openspace {
void RenderablePoints::initialize() {
RenderEngine& renderEngine = OsEng.renderEngine();
_program = renderEngine.buildRenderProgram("RenderablePoints",
"${MODULE_DIGITALUNIVERSE}/shaders/points_vs.glsl",
"${MODULE_DIGITALUNIVERSE}/shaders/points_fs.glsl");// ,
//"${MODULE_DIGITALUNIVERSE}/shaders/points_ge.glsl");
if (_hasSpriteTexture) {
_program = renderEngine.buildRenderProgram("RenderablePoints",
"${MODULE_DIGITALUNIVERSE}/shaders/points_vs.glsl",
"${MODULE_DIGITALUNIVERSE}/shaders/points_sprite_fs.glsl");
}
else {
_program = renderEngine.buildRenderProgram("RenderablePoints",
"${MODULE_DIGITALUNIVERSE}/shaders/points_vs.glsl",
"${MODULE_DIGITALUNIVERSE}/shaders/points_fs.glsl");// ,
//"${MODULE_DIGITALUNIVERSE}/shaders/points_gs.glsl");
}
bool success = loadData();
if (!success) {
throw ghoul::RuntimeError("Error loading data");
@@ -223,6 +284,10 @@ namespace openspace {
renderEngine.removeRenderProgram(_program);
_program = nullptr;
}
if (_hasSpriteTexture) {
_spriteTexture = nullptr;
}
}
void RenderablePoints::render(const RenderData& data, RendererTasks&) {
@@ -237,13 +302,24 @@ namespace openspace {
data.camera.combinedViewMatrix() * modelMatrix);
_program->setUniform("color", _pointColor);
_program->setUniform("sides", 4);
_program->setUniform("alphaValue", _alphaValue);
_program->setUniform("scaleFactor", _scaleFactor);
//setPscUniforms(*_program.get(), data.camera, data.position);
//_program->setUniform("scaling", scaling);
if (_hasSpriteTexture) {
ghoul::opengl::TextureUnit spriteTextureUnit;
spriteTextureUnit.activate();
_spriteTexture->bind();
_program->setUniform("spriteTexture", spriteTextureUnit);
}
if (_hasColorMapFile) {
_program->setUniform("hasColorMap", true);
}
else {
_program->setUniform("hasColorMap", false);
}
glEnable(GL_PROGRAM_POINT_SIZE);
glBindVertexArray(_vao);
const GLsizei nAstronomicalObjects = static_cast<GLsizei>(_fullData.size() / _nValuesPerAstronomicalObject);
@@ -274,6 +350,7 @@ namespace openspace {
glGenBuffers(1, &_vbo);
LDEBUG("Generating Vertex Buffer Object id '" << _vbo << "'");
}
glBindVertexArray(_vao);
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
glBufferData(
@@ -282,28 +359,68 @@ namespace openspace {
&_slicedData[0],
GL_STATIC_DRAW
);
GLint positionAttrib = _program->attributeLocation("in_position");
const size_t nAstronomicalObjects = _fullData.size() / _nValuesPerAstronomicalObject;
const size_t nValues = _slicedData.size() / nAstronomicalObjects;
GLsizei stride = static_cast<GLsizei>(sizeof(double) * nValues);
if (_hasColorMapFile) {
const size_t nAstronomicalObjects = _fullData.size() / _nValuesPerAstronomicalObject;
const size_t nValues = _slicedData.size() / nAstronomicalObjects;
GLsizei stride = static_cast<GLsizei>(sizeof(double) * nValues);
glEnableVertexAttribArray(positionAttrib);
glVertexAttribLPointer(
positionAttrib,
4,
GL_DOUBLE,
sizeof(double)*8,
nullptr
);
GLint colorMapAttrib = _program->attributeLocation("in_colormap");
glEnableVertexAttribArray(colorMapAttrib);
glVertexAttribLPointer(
colorMapAttrib,
4,
GL_DOUBLE,
sizeof(double) * 8,
reinterpret_cast<void*>(sizeof(double)*4)
);
}
else {
glEnableVertexAttribArray(positionAttrib);
glVertexAttribLPointer(
positionAttrib,
4,
GL_DOUBLE,
0,
nullptr
);
}
glEnableVertexAttribArray(positionAttrib);
glVertexAttribLPointer(
positionAttrib,
4,
GL_DOUBLE,
0,
nullptr
);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindVertexArray(0);
_dataIsDirty = false;
}
if (_hasSpriteTexture && _spriteTextureIsDirty) {
LDEBUG("Reloading Sprite Texture");
_spriteTexture = nullptr;
if (_spriteTexturePath.value() != "") {
_spriteTexture = ghoul::io::TextureReader::ref().loadTexture(absPath(_spriteTexturePath));
if (_spriteTexture) {
LDEBUG("Loaded texture from '" << absPath(_spriteTexturePath) << "'");
_spriteTexture->uploadTexture();
}
_spriteTexture->setFilter(ghoul::opengl::Texture::FilterMode::AnisotropicMipMap);
_spriteTextureFile = std::make_unique<ghoul::filesystem::File>(
_spriteTexturePath);
_spriteTextureFile->setCallback(
[&](const ghoul::filesystem::File&) { _spriteTextureIsDirty = true; }
);
}
_spriteTextureIsDirty = false;
}
}
bool RenderablePoints::loadData() {
@@ -319,7 +436,10 @@ namespace openspace {
bool success = loadCachedFile(cachedFile);
if (success) {
return true;
if (_hasColorMapFile) {
success &= readColorMapFile();
}
return success;
}
else {
FileSys.cacheManager()->removeCacheFile(_file);
@@ -340,6 +460,10 @@ namespace openspace {
LINFO("Saving cache");
success = saveCachedFile(cachedFile);
if (_hasColorMapFile) {
success &= readColorMapFile();
}
return success;
}
@@ -408,6 +532,55 @@ namespace openspace {
return true;
}
bool RenderablePoints::readColorMapFile() {
std::string _file = _colorMapFile;
std::ifstream file(_file);
if (!file.good()) {
LERROR("Failed to open Color Map file '" << _file << "'");
return false;
}
std::size_t numberOfColors = 0;
// The beginning of the speck file has a header that either contains comments
// (signaled by a preceding '#') or information about the structure of the file
// (signaled by the keywords 'datavar', 'texturevar', and 'texture')
std::string line = "";
while (true) {
std::streampos position = file.tellg();
std::getline(file, line);
if (line[0] == '#' || line.empty()) {
continue;
}
// Initial number of colors
std::locale loc;
if (std::isdigit(line[0], loc)) {
std::string::size_type sz;
numberOfColors = std::stoi(line, &sz);
break;
}
else if (file.eof()) {
return false;
}
}
for (auto i = 0; i < numberOfColors; ++i) {
std::getline(file, line);
std::stringstream str(line);
glm::vec4 color;
for (auto j = 0; j < 4; ++j) {
str >> color[j];
}
_colorMapData.push_back(color);
}
return true;
}
bool RenderablePoints::loadCachedFile(const std::string& file) {
std::ifstream fileStream(file, std::ifstream::binary);
if (fileStream.good()) {
@@ -467,7 +640,14 @@ namespace openspace {
void RenderablePoints::createDataSlice() {
_slicedData.clear();
if (_hasColorMapFile) {
_slicedData.reserve(8 * (_fullData.size() / _nValuesPerAstronomicalObject));
}
else {
_slicedData.reserve(4 * (_fullData.size()/_nValuesPerAstronomicalObject));
}
int colorIndex = 0;
for (size_t i = 0; i < _fullData.size(); i += _nValuesPerAstronomicalObject) {
glm::dvec3 p = glm::dvec3(_fullData[i + 0], _fullData[i + 1], _fullData[i + 2]);
@@ -493,9 +673,21 @@ namespace openspace {
glm::dvec4 position(p, 1.0);
for (auto j = 0; j < 4; ++j) {
_slicedData.push_back(position[j]);
}
if (_hasColorMapFile) {
for (auto j = 0; j < 4; ++j) {
_slicedData.push_back(position[j]);
}
for (auto j = 0; j < 4; ++j) {
_slicedData.push_back(_colorMapData[colorIndex][j]);
}
}
else {
for (auto j = 0; j < 4; ++j) {
_slicedData.push_back(position[j]);
}
}
colorIndex = (colorIndex == (_colorMapData.size() - 1)) ? 0 : colorIndex + 1;
}
}

View File

@@ -80,24 +80,33 @@ namespace openspace {
bool loadData();
bool readSpeckFile();
bool readColorMapFile();
bool loadCachedFile(const std::string& file);
bool saveCachedFile(const std::string& file) const;
bool _dataIsDirty;
bool _hasSpriteTexture;
bool _spriteTextureIsDirty;
bool _hasColorMapFile;
properties::FloatProperty _alphaValue;
properties::FloatProperty _scaleFactor;
properties::Vec3Property _pointColor;
properties::StringProperty _spriteTexturePath;
std::unique_ptr<ghoul::opengl::Texture> _spriteTexture;
std::unique_ptr<ghoul::filesystem::File> _spriteTextureFile;
std::unique_ptr<ghoul::opengl::ProgramObject> _program;
std::string _speckFile;
std::string _colorMapFile;
Unit _unit;
std::vector<double> _slicedData;
std::vector<float> _fullData;
std::vector<glm::vec4> _colorMapData;
int _nValuesPerAstronomicalObject;
GLuint _vao;

View File

@@ -0,0 +1,62 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014 - 2017 *
* *
* 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. *
****************************************************************************************/
#include "fragment.glsl"
in vec4 gs_colorMap;
in float vs_screenSpaceDepth;
in vec2 texCoord;
uniform float alphaValue;
uniform vec3 color;
uniform sampler2D spriteTexture;
uniform sampler2D polygonTexture;
uniform bool hasColorMap;
uniform bool hasPolygon;
Fragment getFragment() {
vec4 textureColor = texture(spriteTexture, texCoord);
vec4 fullColor = vec4(1.0);
if (hasColorMap) {
fullColor = vec4(gs_colorMap.rgb * textureColor.rgb, gs_colorMap.a * textureColor.a * alphaValue);
} else if (hasPolygon) {
vec4 polygon = texture(polygonTexture, texCoord);
fullColor = vec4(color.rgb * textureColor.rgb + polygon.rgb, textureColor.a * alphaValue);
} else {
fullColor = vec4(color.rgb * textureColor.rgb, textureColor.a * alphaValue);
}
if (fullColor.a == 0.f) {
discard;
}
Fragment frag;
frag.color = fullColor;
frag.depth = vs_screenSpaceDepth;
return frag;
}

View File

@@ -0,0 +1,110 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014 - 2017 *
* *
* 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. *
****************************************************************************************/
#version __CONTEXT__
#include "PowerScaling/powerScalingMath.hglsl"
layout(points) in;
layout(triangle_strip, max_vertices = 6) out;
uniform dmat4 modelViewProjectionTransform;
uniform float scaleFactor;
uniform vec3 up;
uniform vec3 right;
in vec4 colorMap[];
out vec4 gs_colorMap;
out vec2 texCoord;
out float vs_screenSpaceDepth;
const double PARSEC = 0.308567756e17LF;
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)
);
void main() {
vec4 pos = gl_in[0].gl_Position;
gs_colorMap = colorMap[0];
// Temp:
double scaleMultiply = exp(scaleFactor/10);
dvec3 scaledRight = scaleMultiply * right/2.0f;
dvec3 scaledUp = scaleMultiply * up/2.0f;
double unit = PARSEC;
// Must be the same as the enum in RenderableBillboardsCloud.h
if (pos.w == 1.f) {
unit = 1E3;
} else if (pos.w == 2.f) {
unit = PARSEC;
} else if (pos.w == 3.f) {
unit = 1E3 * PARSEC;
} else if (pos.w == 4.f) {
unit = 1E6 * PARSEC;
} else if (pos.w == 5.f) {
unit = 1E9 * PARSEC;
} else if (pos.w == 6.f) {
unit = 306391534.73091 * PARSEC;
}
dvec4 dpos = dvec4(dvec3(pos.xyz) * unit, 1.0);
texCoord = corners[0];
vec4 initialPosition = z_normalization(vec4(modelViewProjectionTransform * dvec4(dpos.xyz - scaledRight - scaledUp, dpos.w)));
vs_screenSpaceDepth = initialPosition.w;
gl_Position = initialPosition;
EmitVertex();
texCoord = corners[1];
gl_Position = z_normalization(vec4(modelViewProjectionTransform * dvec4(dpos.xyz + scaledRight - scaledUp, dpos.w)));
EmitVertex();
texCoord = corners[2];
vec4 crossCorner = z_normalization(vec4(modelViewProjectionTransform * dvec4(dpos.xyz + scaledUp + scaledRight, dpos.w)));
gl_Position = crossCorner;
EmitVertex();
EndPrimitive(); // First Triangle
texCoord = corners[0];
gl_Position = initialPosition;
EmitVertex();
texCoord = corners[2];
gl_Position = crossCorner;
EmitVertex();
texCoord = corners[3];
gl_Position = z_normalization(vec4(modelViewProjectionTransform * dvec4(dpos.xyz + scaledUp - scaledRight, dpos.w)));
EmitVertex();
EndPrimitive(); // Second Triangle
}

View File

@@ -0,0 +1,37 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014 - 2017 *
* *
* 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. *
****************************************************************************************/
#version __CONTEXT__
#include "PowerScaling/powerScaling_vs.hglsl"
in vec4 in_position;
in vec4 in_colormap;
out vec4 colorMap;
void main() {
colorMap = in_colormap;
gl_Position = vec4(in_position);
}

View File

@@ -0,0 +1,62 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014 - 2017 *
* *
* 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. *
****************************************************************************************/
#include "fragment.glsl"
//in vec4 gs_colorMap;
in float gs_screenSpaceDepth;
in vec2 texCoord;
//uniform bool hasColorMap;
uniform float alphaValue;
uniform vec3 color;
uniform sampler2D spriteTexture;
Fragment getFragment() {
vec4 textureColor = texture(spriteTexture, texCoord);
vec4 fullColor = vec4(0.0);
//if (hasColorMap) {
// fullColor = vec4(gs_colorMap.rgb * textureColor.rgb, textureColor.a);
// }
//else {
fullColor = vec4(color.rgb * textureColor.rgb, textureColor.a);
// }
//fullColor.a *= alphaValue;
//if (fullColor.a == 0) {
// discard;
//}
//fullColor = vec4(textureColor.rgb, 1.0);
fullColor = vec4(1.0);
Fragment frag;
frag.color = fullColor;
frag.depth = gs_screenSpaceDepth;
return frag;
}

View File

@@ -0,0 +1,97 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014 - 2017 *
* *
* 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. *
****************************************************************************************/
#version __CONTEXT__
#include "PowerScaling/powerScalingMath.hglsl"
layout(points) in;
layout(triangle_strip, max_vertices = 4) out;
//layout(points, max_vertices = 1) out;
in vec4 orig_position[];
//in vec4 colorMap[];
in float vs_screenSpaceDepth[];
out vec2 texCoord;
out float billboardSize;
out float gs_screenSpaceDepth;
//out vec4 gs_colorMap;
uniform mat4 projection;
uniform float scaleFactor;
uniform float minBillboardSize;
uniform vec2 screenSize;
const vec2 corners[4] = vec2[4](
vec2(0.0, 1.0),
vec2(0.0, 0.0),
vec2(1.0, 1.0),
vec2(1.0, 0.0)
);
void main() {
gs_screenSpaceDepth = vs_screenSpaceDepth[0];
//gs_colorMap = colorMap[0];
// if ((orig_position[0].x == 0.0) &&
// (orig_position[0].y == 0.0) &&
// (orig_position[0].z == 0.0))
// {
// return;
// }
//float modifiedSpriteSize = exp((-30.623 - 0.5) * 1.0) * scaleFactor * 2000;
float modifiedSpriteSize =
exp((-30.623 - (-5.0)) * 0.462) * 1.0 * 2000;
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;
}
// 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;
// The billboard is smaller than one pixel, we can discard it
float sizeInPixels = length(ll - ur);
//if (sizeInPixels < minBillboardSize) {
// return;
//}
for (int i = 0; i < 4; i++) {
gl_Position = projPos[i];
texCoord = corners[i];
billboardSize = sizeInPixels;
EmitVertex();
}
EndPrimitive();
}

View File

@@ -0,0 +1,49 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014 - 2017 *
* *
* 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. *
****************************************************************************************/
#version __CONTEXT__
#include "PowerScaling/powerScaling_vs.hglsl"
in dvec4 in_position;
//in dvec4 in_colormap;
uniform dmat4 modelViewTransform;
uniform mat4 projection;
out float vs_screenSpaceDepth;
out vec4 orig_position;
//out vec4 colorMap;
void main() {
orig_position = vec4(in_position);
//colorMap = vec4(in_colormap);
vec4 positionViewSpace = vec4(modelViewTransform * in_position);
vec4 positionScreenSpace = vec4(z_normalization(projection * positionViewSpace));
//vec4 positionScreenSpace = vec4(projection * positionViewSpace);
vs_screenSpaceDepth = positionScreenSpace.w;
gl_Position = positionViewSpace;
}

View File

@@ -0,0 +1,33 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014 - 2017 *
* *
* 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. *
****************************************************************************************/
#version __CONTEXT__
out vec4 finalColor;
uniform vec3 polygonColor;
void main(void) {
finalColor = vec4(polygonColor, 1.0 );
}

View File

@@ -0,0 +1,74 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014 - 2017 *
* *
* 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. *
****************************************************************************************/
#version __CONTEXT__
layout(points) in;
//layout(line_strip, max_vertices = 19) out;
layout(triangle_strip, max_vertices = 63) out;
uniform int sides;
const float PI = 3.1415926;
void main()
{
// for (int i = 0; i <= sides; i++) {
// // Angle between each side in radians
// float ang = PI * 2.0 / float(sides) * i;
// // Offset from center of point (0.3 to accomodate for aspect ratio)
// //vec4 offset = vec4(cos(ang) * 0.003, -sin(ang) * 0.004, 0.0, 0.0);
// vec4 offset = vec4(cos(ang) * 0.8, -sin(ang) * 0.8, 0.0, 0.0);
// gl_Position = gl_in[0].gl_Position + offset;
// // vec4 offset = vec4(cos(ang) * gl_in[0].gl_Position[0], -sin(ang) * gl_in[0].gl_Position[1],
// // gl_in[0].gl_Position[2] , gl_in[0].gl_Position[3]);
// // gl_Position = offset;
// EmitVertex();
// }
// EndPrimitive();
vec4 v0 = gl_in[0].gl_Position;
for (int i = sides; i > 0; --i) {
// Angle between each side in radians
float ang = PI * 2.0 / float(sides) * i;
gl_Position = v0;
EmitVertex();
vec4 vi = v0 + vec4(cos(ang) * 0.8, -sin(ang) * 0.8, 0.0, 0.0);
gl_Position = vi;
EmitVertex();
ang = PI * 2.0 / float(sides) * (i-1);
vec4 vii = v0 + vec4(cos(ang) * 0.8, -sin(ang) * 0.8, 0.0, 0.0);
gl_Position = vii;
EmitVertex();
EndPrimitive();
}
}

View File

@@ -0,0 +1,31 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014 - 2017 *
* *
* 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. *
****************************************************************************************/
#version __CONTEXT__
layout(location = 0) in vec4 in_position;
void main() {
gl_Position = in_position;
}

View File

@@ -24,11 +24,13 @@
#include "fragment.glsl"
//in float gs_screenSpaceDepth;
in float vs_screenSpaceDepth;
flat in dvec4 test;
in vec4 colorMap;
uniform vec3 color;
uniform float alphaValue;
uniform bool hasColorMap;
Fragment getFragment() {
Fragment frag;
@@ -37,7 +39,13 @@ Fragment getFragment() {
discard;
}
frag.color = vec4(color, alphaValue);
if (hasColorMap) {
frag.color = vec4(colorMap.xyz, alphaValue);
} else {
frag.color = vec4(color, alphaValue);
}
//frag.depth = gs_screenSpaceDepth;
frag.depth = vs_screenSpaceDepth;
return frag;

View File

@@ -0,0 +1,64 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014 - 2017 *
* *
* 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. *
****************************************************************************************/
#version __CONTEXT__
layout(points) in;
//layout(points, max_vertices = 13) out;
layout(line_strip, max_vertices = 13) out;
in float vs_screenSpaceDepth[];
in float vs_scaleFactor[];
in vec4 colorMap[]
uniform int sides;
out float gs_screenSpaceDepth;
const float PI = 3.1415926;
void main()
{
gs_screenSpaceDepth = vs_screenSpaceDepth[0];
for (int i = 0; i <= sides; i++) {
// Angle between each side in radians
float ang = PI * 2.0 / float(sides) * i;
// Offset from center of point (0.3 to accomodate for aspect ratio)
//vec4 offset = vec4(cos(ang) * 0.003, -sin(ang) * 0.004, 0.0, 0.0);
//gl_Position = gl_in[0].gl_Position + offset;
vec4 offset = vec4(cos(ang) * gl_in[0].gl_Position[0], -sin(ang) * gl_in[0].gl_Position[1],
gl_in[0].gl_Position[2] , gl_in[0].gl_Position[3]);
gl_Position = offset;
EmitVertex();
}
//gl_Position = gl_in[0].gl_Position;// + offset;
//EmitVertex();
EndPrimitive();
}

View File

@@ -0,0 +1,49 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014 - 2017 *
* *
* 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. *
****************************************************************************************/
#include "fragment.glsl"
//in float gs_screenSpaceDepth;
in float vs_screenSpaceDepth;
uniform vec3 color;
uniform float alphaValue;
// Sprite
uniform sampler2D spriteTexture;
Fragment getFragment() {
Fragment frag;
if (alphaValue == 0.0) {
discard;
}
frag.color = texture(spriteTexture, gl_PointCoord) * vec4(color, alphaValue);
//frag.depth = gs_screenSpaceDepth;
frag.depth = vs_screenSpaceDepth;
frag.blend = BLEND_MODE_ADDITIVE;
return frag;
}

View File

@@ -27,21 +27,24 @@
#include "PowerScaling/powerScaling_vs.hglsl"
in dvec4 in_position;
in dvec4 in_colormap;
uniform dmat4 modelViewProjectionTransform;
uniform float scaleFactor;
out float vs_screenSpaceDepth;
out dvec4 test;
out float vs_scaleFactor;
out vec4 colorMap;
void main() {
test = in_position;
vec4 positionClipSpace = vec4(modelViewProjectionTransform * in_position);
//positionClipSpace = vec4( modelViewProjectionTransform *
//vec4(0,0,0,1));
// positionClipSpace = vec4( modelViewProjectionTransform *
// vec4(0,0,0,1));
vec4 positionScreenSpace = vec4(z_normalization(positionClipSpace));
vs_screenSpaceDepth = positionScreenSpace.w;
vs_scaleFactor = scaleFactor;
colorMap = vec4(in_colormap);
gl_PointSize = scaleFactor;
gl_Position = positionScreenSpace;

View File

@@ -7,10 +7,10 @@ return {
-- occurs in a single window, a fisheye projection, or a dome cluster system
-- A regular 1280x720 window
SGCTConfig = sgct.config.single{},
--SGCTConfig = sgct.config.single{},
-- A regular 1920x1080 window
-- SGCTConfig = sgct.config.single{1920, 1080},
SGCTConfig = sgct.config.single{1920, 1080},
-- A windowed 1920x1080 fullscreen
-- SGCTConfig = sgct.config.single{1920, 1080, border=false, windowPos={0,0}, shared=true, name="WV_OBS_SPOUT1"},