mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-08 04:31:08 -06:00
Merge branch 'feature/iSWA' of github.com:OpenSpace/OpenSpace-Development into feature/iSWA
This commit is contained in:
@@ -40,7 +40,6 @@ set(HEADER_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/simplespheregeometry.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/screenspaceframebuffer.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/screenspaceimage.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ephemeris/dynamicephemeris.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ephemeris/spiceephemeris.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ephemeris/staticephemeris.h
|
||||
)
|
||||
@@ -62,7 +61,6 @@ set(SOURCE_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/simplespheregeometry.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/screenspaceframebuffer.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/screenspaceimage.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ephemeris/dynamicephemeris.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ephemeris/spiceephemeris.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ephemeris/staticephemeris.cpp
|
||||
)
|
||||
@@ -77,11 +75,15 @@ set(SHADER_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders/imageplane_vs.glsl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders/model_fs.glsl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders/model_vs.glsl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders/nighttexture_fs.glsl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders/nighttexture_vs.glsl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders/path_fs.glsl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders/path_gs.glsl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders/path_vs.glsl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders/plane_fs.glsl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders/plane_vs.glsl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders/pscstandard_fs.glsl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders/pscstandard_vs.glsl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders/sphere_fs.glsl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders/sphere_vs.glsl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders/star_fs.glsl
|
||||
|
||||
@@ -47,7 +47,6 @@
|
||||
#include <modules/base/rendering/screenspaceframebuffer.h>
|
||||
|
||||
#include <modules/base/ephemeris/staticephemeris.h>
|
||||
#include <modules/base/ephemeris/dynamicephemeris.h>
|
||||
#include <modules/base/ephemeris/spiceephemeris.h>
|
||||
|
||||
#include <ghoul/filesystem/filesystem>
|
||||
@@ -61,6 +60,7 @@ BaseModule::BaseModule()
|
||||
void BaseModule::internalInitialize() {
|
||||
FactoryManager::ref().addFactory(std::make_unique<ghoul::TemplateFactory<planetgeometry::PlanetGeometry>>());
|
||||
FactoryManager::ref().addFactory(std::make_unique<ghoul::TemplateFactory<modelgeometry::ModelGeometry>>());
|
||||
FactoryManager::ref().addFactory(std::make_unique<ghoul::TemplateFactory<ScreenSpaceRenderable>>());
|
||||
|
||||
auto fScreenSpaceRenderable = FactoryManager::ref().factory<ScreenSpaceRenderable>();
|
||||
ghoul_assert(fScreenSpaceRenderable, "ScreenSpaceRenderable factory was not created");
|
||||
@@ -84,7 +84,6 @@ void BaseModule::internalInitialize() {
|
||||
auto fEphemeris = FactoryManager::ref().factory<Ephemeris>();
|
||||
ghoul_assert(fEphemeris, "Ephemeris factory was not created");
|
||||
fEphemeris->registerClass<StaticEphemeris>("Static");
|
||||
fEphemeris->registerClass<StaticEphemeris>("Dynamic");
|
||||
fEphemeris->registerClass<SpiceEphemeris>("Spice");
|
||||
|
||||
auto fPlanetGeometry = FactoryManager::ref().factory<planetgeometry::PlanetGeometry>();
|
||||
|
||||
@@ -131,16 +131,17 @@ bool RenderablePlanet::initialize() {
|
||||
// Night texture program
|
||||
_programObject = renderEngine.buildRenderProgram(
|
||||
"nightTextureProgram",
|
||||
"${SHADERS}/nighttexture_vs.glsl",
|
||||
"${SHADERS}/nighttexture_fs.glsl");
|
||||
if (!_programObject) return false;
|
||||
"${MODULE_BASE}/shaders/nighttexture_vs.glsl",
|
||||
"${MODULE_BASE}/shaders/nighttexture_fs.glsl");
|
||||
if (!_programObject)
|
||||
return false;
|
||||
}
|
||||
else if (_programObject == nullptr) {
|
||||
// pscstandard
|
||||
_programObject = renderEngine.buildRenderProgram(
|
||||
"pscstandard",
|
||||
"${SHADERS}/pscstandard_vs.glsl",
|
||||
"${SHADERS}/pscstandard_fs.glsl");
|
||||
"${MODULE_BASE}/shaders/pscstandard_vs.glsl",
|
||||
"${MODULE_BASE}/shaders/pscstandard_fs.glsl");
|
||||
if (!_programObject) return false;
|
||||
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ bool RenderableSphere::initialize() {
|
||||
// pscstandard
|
||||
RenderEngine& renderEngine = OsEng.renderEngine();
|
||||
_shader = renderEngine.buildRenderProgram("Sphere",
|
||||
"${MODULES}/base/shaders/sphere_vs.glsl",
|
||||
"${MODULE_BASE}/shaders/sphere_vs.glsl",
|
||||
"${MODULES}/base/shaders/sphere_fs.glsl");
|
||||
if (!_shader)
|
||||
return false;
|
||||
|
||||
82
modules/base/shaders/nighttexture_fs.glsl
Normal file
82
modules/base/shaders/nighttexture_fs.glsl
Normal file
@@ -0,0 +1,82 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* 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. *
|
||||
****************************************************************************************/
|
||||
|
||||
uniform vec4 campos;
|
||||
uniform vec4 objpos;
|
||||
|
||||
uniform vec3 sun_pos;
|
||||
|
||||
uniform bool _performShading = true;
|
||||
uniform float transparency;
|
||||
uniform int shadows;
|
||||
|
||||
uniform float time;
|
||||
uniform sampler2D texture1;
|
||||
uniform sampler2D nightTex;
|
||||
|
||||
in vec2 vs_st;
|
||||
in vec2 vs_nightTex;
|
||||
in vec4 vs_normal;
|
||||
in vec4 vs_position;
|
||||
|
||||
#include "PowerScaling/powerScaling_fs.hglsl"
|
||||
#include "fragment.glsl"
|
||||
|
||||
Fragment getFragment() {
|
||||
vec4 position = vs_position;
|
||||
float depth = pscDepth(position);
|
||||
vec4 diffuse = texture(texture1, vs_st);
|
||||
vec4 diffuse2 = texture(nightTex, vs_st);
|
||||
|
||||
Fragment frag;
|
||||
if (_performShading) {
|
||||
// directional lighting
|
||||
vec3 origin = vec3(0.0);
|
||||
vec4 spec = vec4(0.0);
|
||||
|
||||
vec3 n = normalize(vs_normal.xyz);
|
||||
//vec3 e = normalize(camdir);
|
||||
vec3 l_pos = vec3(sun_pos); // sun.
|
||||
vec3 l_dir = normalize(l_pos-objpos.xyz);
|
||||
float intensity = min(max(5*dot(n,l_dir), 0.0), 1);
|
||||
float darkSide = min(max(5*dot(n,-l_dir), 0.0), 1);
|
||||
|
||||
float shine = 0.0001;
|
||||
|
||||
vec4 specular = vec4(0.5);
|
||||
vec4 ambient = vec4(0.0,0.0,0.0,transparency);
|
||||
|
||||
vec4 daytex = max(intensity * diffuse, ambient);
|
||||
vec4 mixtex = mix(diffuse, diffuse2, (1+dot(n,-l_dir))/2);
|
||||
|
||||
diffuse = (daytex*2 + mixtex)/3;
|
||||
}
|
||||
|
||||
diffuse[3] = transparency;
|
||||
frag.color = diffuse;
|
||||
frag.depth = depth;
|
||||
|
||||
return frag;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2016 *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* 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 *
|
||||
@@ -22,35 +22,36 @@
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include <modules/base/ephemeris/dynamicephemeris.h>
|
||||
#version __CONTEXT__
|
||||
|
||||
namespace {
|
||||
const std::string KeyPosition = "Position";
|
||||
}
|
||||
uniform mat4 ViewProjection;
|
||||
uniform mat4 ModelTransform;
|
||||
|
||||
namespace openspace {
|
||||
layout(location = 0) in vec4 in_position;
|
||||
layout(location = 1) in vec2 in_st;
|
||||
layout(location = 2) in vec3 in_normal;
|
||||
//layout(location = 3) in vec2 in_nightTex;
|
||||
|
||||
DynamicEphemeris::DynamicEphemeris(const ghoul::Dictionary& dictionary)
|
||||
: _position(0.f, 0.f, 0.f, 0.f)
|
||||
|
||||
out vec2 vs_st;
|
||||
out vec4 vs_normal;
|
||||
out vec4 vs_position;
|
||||
out float s;
|
||||
|
||||
#include "PowerScaling/powerScaling_vs.hglsl"
|
||||
|
||||
void main()
|
||||
{
|
||||
const bool hasPosition = dictionary.hasKeyAndValue<glm::vec4>(KeyPosition);
|
||||
if (hasPosition) {
|
||||
glm::vec4 tmp;
|
||||
dictionary.getValue(KeyPosition, tmp);
|
||||
_position = tmp;
|
||||
}
|
||||
}
|
||||
// set variables
|
||||
vs_st = in_st;
|
||||
vs_position = in_position;
|
||||
vec4 tmp = in_position;
|
||||
|
||||
DynamicEphemeris::~DynamicEphemeris() {}
|
||||
|
||||
const psc& DynamicEphemeris::position() const {
|
||||
return _position;
|
||||
}
|
||||
|
||||
void DynamicEphemeris::setPosition(psc pos) {
|
||||
_position = pos;
|
||||
}
|
||||
|
||||
void DynamicEphemeris::update(const UpdateData&) {}
|
||||
|
||||
} // namespace openspace
|
||||
// this is wrong for the normal. The normal transform is the transposed inverse of the model transform
|
||||
vs_normal = normalize(ModelTransform * vec4(in_normal,0));
|
||||
|
||||
vec4 position = pscTransform(tmp, ModelTransform);
|
||||
vs_position = tmp;
|
||||
position = ViewProjection * position;
|
||||
gl_Position = z_normalization(position);
|
||||
}
|
||||
84
modules/base/shaders/pscstandard_fs.glsl
Normal file
84
modules/base/shaders/pscstandard_fs.glsl
Normal file
@@ -0,0 +1,84 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* 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. *
|
||||
****************************************************************************************/
|
||||
|
||||
uniform vec4 campos;
|
||||
uniform vec4 objpos;
|
||||
//uniform vec3 camdir; // add this for specular
|
||||
|
||||
uniform vec3 sun_pos;
|
||||
|
||||
uniform bool _performShading = true;
|
||||
uniform float transparency;
|
||||
uniform int shadows;
|
||||
|
||||
uniform float time;
|
||||
uniform sampler2D texture1;
|
||||
|
||||
in vec2 vs_st;
|
||||
in vec4 vs_normal;
|
||||
in vec4 vs_position;
|
||||
|
||||
#include "fragment.glsl"
|
||||
#include "PowerScaling/powerScaling_fs.hglsl"
|
||||
|
||||
//#include "PowerScaling/powerScaling_vs.hglsl"
|
||||
Fragment getFragment() {
|
||||
vec4 position = vs_position;
|
||||
float depth = pscDepth(position);
|
||||
vec4 diffuse = texture(texture1, vs_st);
|
||||
|
||||
Fragment frag;
|
||||
if (_performShading) {
|
||||
// directional lighting
|
||||
vec3 origin = vec3(0.0);
|
||||
vec4 spec = vec4(0.0);
|
||||
|
||||
vec3 n = normalize(vs_normal.xyz);
|
||||
//vec3 e = normalize(camdir);
|
||||
vec3 l_pos = vec3(sun_pos); // sun.
|
||||
vec3 l_dir = normalize(l_pos-objpos.xyz);
|
||||
float intensity = min(max(5*dot(n,l_dir), 0.0), 1);
|
||||
|
||||
float shine = 0.0001;
|
||||
|
||||
vec4 specular = vec4(0.5);
|
||||
vec4 ambient = vec4(0.0,0.0,0.0,transparency);
|
||||
/*
|
||||
if(intensity > 0.f){
|
||||
// halfway vector
|
||||
vec3 h = normalize(l_dir + e);
|
||||
// specular factor
|
||||
float intSpec = max(dot(h,n),0.0);
|
||||
spec = specular * pow(intSpec, shine);
|
||||
}
|
||||
*/
|
||||
diffuse = max(intensity * diffuse, ambient);
|
||||
}
|
||||
|
||||
diffuse[3] = transparency;
|
||||
frag.color = diffuse;
|
||||
frag.depth = depth;
|
||||
|
||||
return frag;
|
||||
}
|
||||
57
modules/base/shaders/pscstandard_vs.glsl
Normal file
57
modules/base/shaders/pscstandard_vs.glsl
Normal file
@@ -0,0 +1,57 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* 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__
|
||||
|
||||
uniform mat4 ViewProjection;
|
||||
uniform mat4 ModelTransform;
|
||||
|
||||
layout(location = 0) in vec4 in_position;
|
||||
//in vec3 in_position;
|
||||
layout(location = 1) in vec2 in_st;
|
||||
layout(location = 2) in vec3 in_normal;
|
||||
|
||||
out vec2 vs_st;
|
||||
out vec4 vs_normal;
|
||||
out vec4 vs_position;
|
||||
out float s;
|
||||
|
||||
#include "PowerScaling/powerScaling_vs.hglsl"
|
||||
|
||||
void main()
|
||||
{
|
||||
// set variables
|
||||
vs_st = in_st;
|
||||
//vs_stp = in_position.xyz;
|
||||
vs_position = in_position;
|
||||
vec4 tmp = in_position;
|
||||
|
||||
// this is wrong for the normal. The normal transform is the transposed inverse of the model transform
|
||||
vs_normal = normalize(ModelTransform * vec4(in_normal,0));
|
||||
|
||||
vec4 position = pscTransform(tmp, ModelTransform);
|
||||
vs_position = tmp;
|
||||
position = ViewProjection * position;
|
||||
gl_Position = z_normalization(position);
|
||||
}
|
||||
@@ -40,6 +40,7 @@ Fragment getFragment()
|
||||
vec4 diffuse;
|
||||
|
||||
vec2 texCoord = vs_st;
|
||||
// Why is this here? ---abock
|
||||
texCoord.s = 1 - texCoord.s;
|
||||
texCoord.t = 1 - texCoord.y;
|
||||
|
||||
|
||||
3
modules/iswa/include.cmake
Normal file
3
modules/iswa/include.cmake
Normal file
@@ -0,0 +1,3 @@
|
||||
set (OPENSPACE_DEPENDENCIES
|
||||
base
|
||||
)
|
||||
@@ -43,7 +43,6 @@ namespace openspace {
|
||||
{}
|
||||
|
||||
void ISWAModule::internalInitialize(){
|
||||
FactoryManager::ref().addFactory(std::make_unique<ghoul::TemplateFactory<ScreenSpaceRenderable>>());
|
||||
auto fRenderable = FactoryManager::ref().factory<Renderable>();
|
||||
ghoul_assert(fRenderable, "No renderable factory existed");
|
||||
|
||||
|
||||
@@ -208,7 +208,7 @@ void DataPlane::setUniforms(){
|
||||
|
||||
int activeTransferfunctions = _transferFunctions.size();
|
||||
|
||||
ghoul::opengl::TextureUnit txUnits[activeTextures];
|
||||
ghoul::opengl::TextureUnit txUnits[10];
|
||||
int j = 0;
|
||||
for(int option : selectedOptions){
|
||||
if(_textures[option]){
|
||||
@@ -223,7 +223,7 @@ void DataPlane::setUniforms(){
|
||||
}
|
||||
}
|
||||
|
||||
ghoul::opengl::TextureUnit tfUnits[activeTransferfunctions];
|
||||
ghoul::opengl::TextureUnit tfUnits[10];
|
||||
j = 0;
|
||||
|
||||
if((activeTransferfunctions == 1) && (_textures.size() != _transferFunctions.size())){
|
||||
@@ -538,7 +538,7 @@ void DataPlane::setTransferFunctions(std::string tfPath){
|
||||
|
||||
if(tfFile.is_open()){
|
||||
while(getline(tfFile, line)){
|
||||
std::shared_ptr<TransferFunction> tf = std::make_shared<TransferFunction>(line);
|
||||
std::shared_ptr<TransferFunction> tf = std::make_shared<TransferFunction>(absPath(line));
|
||||
if(tf)
|
||||
tfs.push_back(tf);
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ ScreenSpaceCygnet::ScreenSpaceCygnet(const ghoul::Dictionary& dictionary)
|
||||
: ScreenSpaceRenderable(dictionary)
|
||||
, _updateInterval("updateInterval", "Update Interval", 1.0, 0.0 , 10.0)
|
||||
{
|
||||
// hacky, have to first get as float and the cast to int.
|
||||
// hacky, have to first get as float and then cast to int.
|
||||
float cygnetid;
|
||||
dictionary.getValue("CygnetId", cygnetid);
|
||||
_cygnetId = (int)cygnetid;
|
||||
@@ -135,12 +135,17 @@ bool ScreenSpaceCygnet::isReady() const{
|
||||
}
|
||||
|
||||
void ScreenSpaceCygnet::updateTexture(){
|
||||
_memorybuffer = "";
|
||||
// If a download is in progress, dont send another request.
|
||||
//What if image failed to download?
|
||||
if(_futureTexture && !_futureTexture->isFinished)
|
||||
return;
|
||||
|
||||
_memorybuffer = "";
|
||||
std::shared_ptr<DownloadManager::FileFuture> future = ISWAManager::ref().downloadImageToMemory(_cygnetId, _memorybuffer);
|
||||
if(future){
|
||||
_futureTexture = future;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ScreenSpaceCygnet::loadTexture() {
|
||||
|
||||
@@ -103,10 +103,6 @@ void ISWAManager::addISWACygnet(std::string info){
|
||||
}
|
||||
|
||||
addISWACygnet(cygnetId);
|
||||
|
||||
/*if(data == "")
|
||||
else*/
|
||||
|
||||
}
|
||||
|
||||
void ISWAManager::addISWACygnet(int id, std::string info, int group){
|
||||
@@ -116,7 +112,6 @@ void ISWAManager::addISWACygnet(int id, std::string info, int group){
|
||||
std::shared_ptr<MetadataFuture> metaFuture = std::make_shared<MetadataFuture>();
|
||||
metaFuture->id = id;
|
||||
metaFuture->group = group;
|
||||
|
||||
if(info == _type[CygnetType::Texture]){
|
||||
metaFuture->type = CygnetType::Texture;
|
||||
metaFuture->geom = CygnetGeometry::Plane;
|
||||
|
||||
@@ -68,7 +68,7 @@ public:
|
||||
~ISWAManager();
|
||||
|
||||
void addISWACygnet(std::string info);
|
||||
void addISWACygnet(int id, std::string info = "TEXTURE", int group = -1);
|
||||
void addISWACygnet(int id, std::string info = "Texture", int group = -1);
|
||||
void deleteISWACygnet(std::string);
|
||||
|
||||
// std::shared_ptr<DownloadManager::FileFuture> downloadImage(int, std::string);
|
||||
|
||||
@@ -64,6 +64,8 @@ source_group("Source Files" FILES ${SOURCE_FILES})
|
||||
set(SHADER_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders/crawlingline_fs.glsl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders/crawlingline_vs.glsl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders/fboPass_fs.glsl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders/fboPass_vs.glsl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders/fov_fs.glsl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders/fov_vs.glsl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders/projectiveTexture_fs.glsl
|
||||
|
||||
@@ -275,13 +275,20 @@ void RenderablePlaneProjection::updatePlane(const Image img, double currentTime)
|
||||
|
||||
const GLfloat vertex_data[] = { // square of two triangles drawn within fov in target coordinates
|
||||
// x y z w s t
|
||||
projection[1][0], projection[1][1], projection[1][2], projection[1][3], 0, 1, // Lower left 1
|
||||
projection[3][0], projection[3][1], projection[3][2], projection[3][3], 1, 0, // Upper right 2
|
||||
projection[2][0], projection[2][1], projection[2][2], projection[2][3], 0, 0, // Upper left 3
|
||||
projection[1][0], projection[1][1], projection[1][2], projection[1][3], 0, 1, // Lower left 4 = 1
|
||||
projection[0][0], projection[0][1], projection[0][2], projection[0][3], 1, 1, // Lower right 5
|
||||
projection[3][0], projection[3][1], projection[3][2], projection[3][3], 1, 0, // Upper left 6 = 2
|
||||
projection[1][0], projection[1][1], projection[1][2], projection[1][3], 0, 0, // Lower left 1
|
||||
projection[3][0], projection[3][1], projection[3][2], projection[3][3], 1, 1, // Upper right 2
|
||||
projection[2][0], projection[2][1], projection[2][2], projection[2][3], 0, 1, // Upper left 3
|
||||
projection[1][0], projection[1][1], projection[1][2], projection[1][3], 0, 0, // Lower left 4 = 1
|
||||
projection[0][0], projection[0][1], projection[0][2], projection[0][3], 1, 0, // Lower right 5
|
||||
projection[3][0], projection[3][1], projection[3][2], projection[3][3], 1, 1, // Upper left 6 = 2
|
||||
};
|
||||
//projection[1][0], projection[1][1], projection[1][2], projection[1][3], 0, 1, // Lower left 1
|
||||
// projection[3][0], projection[3][1], projection[3][2], projection[3][3], 1, 0, // Upper right 2
|
||||
// projection[2][0], projection[2][1], projection[2][2], projection[2][3], 0, 0, // Upper left 3
|
||||
// projection[1][0], projection[1][1], projection[1][2], projection[1][3], 0, 1, // Lower left 4 = 1
|
||||
// projection[0][0], projection[0][1], projection[0][2], projection[0][3], 1, 1, // Lower right 5
|
||||
// projection[3][0], projection[3][1], projection[3][2], projection[3][3], 1, 0, // Upper left 6 = 2
|
||||
|
||||
|
||||
glBindVertexArray(_quad); // bind array
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _vertexPositionBuffer); // bind buffer
|
||||
|
||||
@@ -255,8 +255,8 @@ bool RenderablePlanetProjection::initialize() {
|
||||
}
|
||||
|
||||
_fboProgramObject = ghoul::opengl::ProgramObject::Build("fboPassProgram",
|
||||
"${SHADERS}/fboPass_vs.glsl",
|
||||
"${SHADERS}/fboPass_fs.glsl");
|
||||
"${MODULES}/newhorizons/shaders/fboPass_vs.glsl",
|
||||
"${MODULES}/newhorizons/shaders/fboPass_fs.glsl");
|
||||
|
||||
loadTexture();
|
||||
loadProjectionTexture();
|
||||
|
||||
95
modules/newhorizons/shaders/fboPass_fs.glsl
Normal file
95
modules/newhorizons/shaders/fboPass_fs.glsl
Normal file
@@ -0,0 +1,95 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* 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__
|
||||
|
||||
uniform sampler2D texture1;
|
||||
uniform sampler2D texture2;
|
||||
uniform mat4 ProjectorMatrix;
|
||||
uniform mat4 ModelTransform;
|
||||
uniform vec2 _scaling;
|
||||
uniform vec4 _radius;
|
||||
uniform int _segments;
|
||||
|
||||
uniform float projectionFading;
|
||||
|
||||
in vec4 vs_position;
|
||||
|
||||
uniform vec3 boresight;
|
||||
|
||||
out vec4 color;
|
||||
|
||||
#define M_PI 3.14159265358979323846
|
||||
|
||||
vec4 uvToModel(vec2 uv, vec4 radius, float segments){
|
||||
float fj = uv.x * segments;
|
||||
float fi = (1.0 - uv.y) * segments;
|
||||
|
||||
float theta = fi * float(M_PI) / segments; // 0 -> PI
|
||||
float phi = fj * float(M_PI) * 2.0f / segments;
|
||||
|
||||
float x = radius[0] * sin(phi) * sin(theta); //
|
||||
float y = radius[1] * cos(theta); // up
|
||||
float z = radius[2] * cos(phi) * sin(theta); //
|
||||
|
||||
return vec4(x, y, z, radius[3]);
|
||||
|
||||
return vec4(0.0);
|
||||
}
|
||||
|
||||
#include "PowerScaling/powerScaling_vs.hglsl"
|
||||
|
||||
bool inRange(float x, float a, float b){
|
||||
return (x >= a && x <= b);
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec2 uv = (vs_position.xy + vec2(1.0)) / vec2(2.0);
|
||||
|
||||
vec4 vertex = uvToModel(uv, _radius, _segments);
|
||||
|
||||
vec4 raw_pos = psc_to_meter(vertex, _scaling);
|
||||
vec4 projected = ProjectorMatrix * ModelTransform * raw_pos;
|
||||
|
||||
projected.x /= projected.w;
|
||||
projected.y /= projected.w;
|
||||
|
||||
vec3 normal = normalize((ModelTransform*vec4(vertex.xyz,0)).xyz);
|
||||
|
||||
vec3 v_b = normalize(boresight);
|
||||
|
||||
if((inRange(projected.x, 0, 1) &&
|
||||
inRange(projected.y, 0, 1)) &&
|
||||
dot(v_b, normal) < 0 )
|
||||
{
|
||||
// The 1-x is in this texture call because of flipped textures
|
||||
// to be fixed soon ---abock
|
||||
color = texture(texture1, vec2(projected.x, 1-projected.y));
|
||||
}else{
|
||||
color = texture(texture2, uv);
|
||||
color.a = projectionFading;
|
||||
}
|
||||
|
||||
// color.a = 0.1f;//1.f - abs(uv.x - 0.55) / (0.6 - 0.5); // blending
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2016 *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* 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 *
|
||||
@@ -22,25 +22,23 @@
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __DYNAMICEPHEMERIS_H__
|
||||
#define __DYNAMICEPHEMERIS_H__
|
||||
#version __CONTEXT__
|
||||
|
||||
#include <openspace/scene/ephemeris.h>
|
||||
uniform mat4 ProjectorMatrix;
|
||||
uniform mat4 ModelTransform;
|
||||
uniform vec2 _scaling;
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class DynamicEphemeris: public Ephemeris {
|
||||
public:
|
||||
DynamicEphemeris(const ghoul::Dictionary& dictionary
|
||||
= ghoul::Dictionary());
|
||||
virtual ~DynamicEphemeris();
|
||||
virtual const psc& position() const;
|
||||
virtual void update(const UpdateData& data) override;
|
||||
void setPosition(psc pos);
|
||||
private:
|
||||
psc _position;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
layout(location = 0) in vec4 in_position;
|
||||
|
||||
#endif // __DYNAMICEPHEMERIS_H__
|
||||
uniform vec3 boresight;
|
||||
uniform vec2 radius;
|
||||
|
||||
out vec4 vs_position;
|
||||
|
||||
#include "PowerScaling/powerScaling_vs.hglsl"
|
||||
|
||||
void main() {
|
||||
vs_position = in_position;
|
||||
gl_Position = vec4(in_position.xy, 0.0, 1.0);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user