mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-03 09:20:26 -05:00
solve merge conflict with develop
This commit is contained in:
@@ -58,15 +58,19 @@ namespace openspace {
|
||||
RenderablePlanet::RenderablePlanet(const ghoul::Dictionary& dictionary)
|
||||
: Renderable(dictionary)
|
||||
, _colorTexturePath("colorTexture", "Color Texture")
|
||||
, _nightTexturePath("nightTexture", "Night Texture")
|
||||
, _heightMapTexturePath("heightMap", "Heightmap Texture")
|
||||
, _heightExaggeration("heightExaggeration", "Height Exaggeration", 1.f, 0.f, 10.f)
|
||||
, _programObject(nullptr)
|
||||
, _texture(nullptr)
|
||||
, _nightTexture(nullptr)
|
||||
, _heightMapTexture(nullptr)
|
||||
, _geometry(nullptr)
|
||||
, _performShading("performShading", "Perform Shading", true)
|
||||
, _rotation("rotation", "Rotation", 0, 0, 360)
|
||||
, _alpha(1.f)
|
||||
, _nightTexturePath("")
|
||||
, _hasNightTexture(false)
|
||||
, _hasHeightTexture(false)
|
||||
{
|
||||
std::string name;
|
||||
bool success = dictionary.getValue(SceneGraphNode::KeyName, name);
|
||||
@@ -100,17 +104,31 @@ RenderablePlanet::RenderablePlanet(const ghoul::Dictionary& dictionary)
|
||||
|
||||
std::string nightTexturePath = "";
|
||||
dictionary.getValue("Textures.Night", nightTexturePath);
|
||||
|
||||
if (nightTexturePath != ""){
|
||||
_hasNightTexture = true;
|
||||
_nightTexturePath = absPath(nightTexturePath);
|
||||
}
|
||||
|
||||
std::string heightMapTexturePath = "";
|
||||
dictionary.getValue("Textures.Height", heightMapTexturePath);
|
||||
if (heightMapTexturePath != "") {
|
||||
_hasHeightTexture = true;
|
||||
_heightMapTexturePath = absPath(heightMapTexturePath);
|
||||
}
|
||||
|
||||
addPropertySubOwner(_geometry);
|
||||
|
||||
addProperty(_colorTexturePath);
|
||||
_colorTexturePath.onChange(std::bind(&RenderablePlanet::loadTexture, this));
|
||||
|
||||
addProperty(_nightTexturePath);
|
||||
_nightTexturePath.onChange(std::bind(&RenderablePlanet::loadTexture, this));
|
||||
|
||||
addProperty(_heightMapTexturePath);
|
||||
_heightMapTexturePath.onChange(std::bind(&RenderablePlanet::loadTexture, this));
|
||||
|
||||
addProperty(_heightExaggeration);
|
||||
|
||||
if (dictionary.hasKeyAndValue<bool>(keyShading)) {
|
||||
bool shading;
|
||||
dictionary.getValue(keyShading, shading);
|
||||
@@ -142,11 +160,13 @@ bool RenderablePlanet::initialize() {
|
||||
"pscstandard",
|
||||
"${MODULE_BASE}/shaders/pscstandard_vs.glsl",
|
||||
"${MODULE_BASE}/shaders/pscstandard_fs.glsl");
|
||||
if (!_programObject) return false;
|
||||
if (!_programObject)
|
||||
return false;
|
||||
|
||||
}
|
||||
using IgnoreError = ghoul::opengl::ProgramObject::IgnoreError;
|
||||
_programObject->setIgnoreSubroutineUniformLocationError(IgnoreError::Yes);
|
||||
_programObject->setIgnoreUniformLocationError(IgnoreError::Yes);
|
||||
|
||||
loadTexture();
|
||||
_geometry->initialize(this);
|
||||
@@ -218,20 +238,32 @@ void RenderablePlanet::render(const RenderData& data)
|
||||
|
||||
_programObject->setUniform("_performShading", _performShading);
|
||||
|
||||
_programObject->setUniform("_hasHeightMap", _hasHeightTexture);
|
||||
_programObject->setUniform("_heightExaggeration", _heightExaggeration);
|
||||
|
||||
// Bind texture
|
||||
ghoul::opengl::TextureUnit dayUnit;
|
||||
ghoul::opengl::TextureUnit nightUnit;
|
||||
ghoul::opengl::TextureUnit heightUnit;
|
||||
|
||||
|
||||
dayUnit.activate();
|
||||
_texture->bind();
|
||||
_programObject->setUniform("texture1", dayUnit);
|
||||
|
||||
// Bind possible night texture
|
||||
if (_hasNightTexture) {
|
||||
ghoul::opengl::TextureUnit nightUnit;
|
||||
nightUnit.activate();
|
||||
_nightTexture->bind();
|
||||
_programObject->setUniform("nightTex", nightUnit);
|
||||
}
|
||||
|
||||
if (_hasHeightTexture) {
|
||||
heightUnit.activate();
|
||||
_heightMapTexture->bind();
|
||||
_programObject->setUniform("heightTex", heightUnit);
|
||||
}
|
||||
|
||||
glEnable(GL_CULL_FACE);
|
||||
glCullFace(GL_BACK);
|
||||
|
||||
@@ -264,7 +296,7 @@ void RenderablePlanet::loadTexture() {
|
||||
}
|
||||
if (_hasNightTexture) {
|
||||
_nightTexture = nullptr;
|
||||
if (_nightTexturePath != "") {
|
||||
if (_nightTexturePath.value() != "") {
|
||||
_nightTexture = std::move(ghoul::io::TextureReader::ref().loadTexture(absPath(_nightTexturePath)));
|
||||
if (_nightTexture) {
|
||||
LDEBUG("Loaded texture from '" << _nightTexturePath << "'");
|
||||
@@ -274,6 +306,19 @@ void RenderablePlanet::loadTexture() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (_hasHeightTexture) {
|
||||
_heightMapTexture = nullptr;
|
||||
if (_heightMapTexturePath.value() != "") {
|
||||
_heightMapTexture = std::move(ghoul::io::TextureReader::ref().loadTexture(absPath(_heightMapTexturePath)));
|
||||
if (_heightMapTexture) {
|
||||
LDEBUG("Loaded texture from '" << _heightMapTexturePath << "'");
|
||||
_heightMapTexture->uploadTexture();
|
||||
_heightMapTexture->setFilter(ghoul::opengl::Texture::FilterMode::Linear);
|
||||
//_nightTexture->setFilter(ghoul::opengl::Texture::FilterMode::AnisotropicMipMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -62,19 +62,26 @@ protected:
|
||||
|
||||
private:
|
||||
properties::StringProperty _colorTexturePath;
|
||||
properties::StringProperty _nightTexturePath;
|
||||
properties::StringProperty _heightMapTexturePath;
|
||||
|
||||
std::unique_ptr<ghoul::opengl::ProgramObject> _programObject;
|
||||
std::unique_ptr<ghoul::opengl::Texture> _texture;
|
||||
std::unique_ptr<ghoul::opengl::Texture> _nightTexture;
|
||||
std::unique_ptr<ghoul::opengl::Texture> _heightMapTexture;
|
||||
|
||||
properties::FloatProperty _heightExaggeration;
|
||||
|
||||
planetgeometry::PlanetGeometry* _geometry;
|
||||
properties::BoolProperty _performShading;
|
||||
properties::IntProperty _rotation;
|
||||
float _alpha;
|
||||
|
||||
glm::dmat3 _stateMatrix;
|
||||
std::string _nightTexturePath;
|
||||
std::string _frame;
|
||||
std::string _target;
|
||||
bool _hasNightTexture;
|
||||
bool _hasHeightTexture;
|
||||
double _time;
|
||||
};
|
||||
|
||||
|
||||
@@ -231,19 +231,11 @@ void RenderableTrail::update(const UpdateData& data) {
|
||||
|
||||
psc pscPos = PowerScaledCoordinate::CreatePowerScaledCoordinate(p.x, p.y, p.z);
|
||||
|
||||
|
||||
pscPos[3] += 3; // KM to M
|
||||
_vertexArray[0] = { pscPos[0], pscPos[1], pscPos[2], pscPos[3] };
|
||||
|
||||
if (nValues != 0) {
|
||||
// If we have new values to create, we do that here. nValues should always be
|
||||
// close to 1
|
||||
|
||||
// But you never know
|
||||
nValues = std::min(nValues, int(_vertexArray.size() - 1));
|
||||
//LINFO(nValues);
|
||||
std::vector<TrailVBOLayout> tmp = _vertexArray;
|
||||
|
||||
std::vector<TrailVBOLayout> tmp(nValues);
|
||||
for (int i = nValues; i > 0; --i) {
|
||||
double et = _oldTime + i * _increment;
|
||||
if (start > et)
|
||||
@@ -254,11 +246,13 @@ void RenderableTrail::update(const UpdateData& data) {
|
||||
SpiceManager::ref().targetPosition(_target, _observer, _frame, {}, et, lightTime);
|
||||
pscPos = PowerScaledCoordinate::CreatePowerScaledCoordinate(p.x, p.y, p.z);
|
||||
pscPos[3] += 3;
|
||||
_vertexArray[i] = { pscPos[0], pscPos[1], pscPos[2], pscPos[3] };
|
||||
tmp[nValues - i] = { pscPos[0], pscPos[1], pscPos[2], pscPos[3] };
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < tmp.size() - (nValues + 1); ++i)
|
||||
_vertexArray[nValues + 1 + i] = tmp[i + 1];
|
||||
size_t size = _vertexArray.size();
|
||||
_vertexArray.insert(_vertexArray.begin() + 1, tmp.begin(), tmp.end());
|
||||
_vertexArray.resize(size);
|
||||
|
||||
_oldTime += nValues * _increment;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ SimpleSphereGeometry::SimpleSphereGeometry(const ghoul::Dictionary& dictionary)
|
||||
: PlanetGeometry()
|
||||
, _realRadius("radius", "Radius", glm::vec4(1.f, 1.f, 1.f, 0.f), glm::vec4(-10.f, -10.f, -10.f, -20.f),
|
||||
glm::vec4(10.f, 10.f, 10.f, 20.f))
|
||||
, _segments("segments", "Segments", 20, 1, 50)
|
||||
, _segments("segments", "Segments", 20, 1, 5000)
|
||||
, _sphere(nullptr)
|
||||
{
|
||||
using constants::simplespheregeometry::keyRadius;
|
||||
|
||||
@@ -39,6 +39,7 @@ in vec2 vs_st;
|
||||
in vec2 vs_nightTex;
|
||||
in vec4 vs_normal;
|
||||
in vec4 vs_position;
|
||||
in vec4 test;
|
||||
|
||||
#include "PowerScaling/powerScaling_fs.hglsl"
|
||||
#include "fragment.glsl"
|
||||
@@ -68,7 +69,7 @@ Fragment getFragment() {
|
||||
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);
|
||||
vec4 mixtex = mix(diffuse, diffuse2, (1+dot(n,-l_dir))/2);
|
||||
|
||||
diffuse = (daytex*2 + mixtex)/3;
|
||||
}
|
||||
|
||||
@@ -24,21 +24,25 @@
|
||||
|
||||
#version __CONTEXT__
|
||||
|
||||
uniform mat4 ViewProjection;
|
||||
uniform mat4 ModelTransform;
|
||||
#include "PowerScaling/powerScaling_vs.hglsl"
|
||||
|
||||
|
||||
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;
|
||||
|
||||
|
||||
out vec2 vs_st;
|
||||
out vec4 vs_normal;
|
||||
out vec4 vs_position;
|
||||
out float s;
|
||||
|
||||
#include "PowerScaling/powerScaling_vs.hglsl"
|
||||
uniform mat4 ViewProjection;
|
||||
uniform mat4 ModelTransform;
|
||||
|
||||
uniform sampler2D heightTex;
|
||||
uniform bool _hasHeightMap;
|
||||
uniform float _heightExaggeration;
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
@@ -49,9 +53,19 @@ void main()
|
||||
|
||||
// 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));
|
||||
// vs_normal = vec4(in_normal, 0.0);
|
||||
|
||||
vec4 position = pscTransform(tmp, ModelTransform);
|
||||
vs_position = tmp;
|
||||
|
||||
if (_hasHeightMap) {
|
||||
float height = texture(heightTex, in_st).r;
|
||||
vec3 displacementDirection = abs(normalize(in_normal.xyz));
|
||||
float displacementFactor = height * _heightExaggeration;
|
||||
position.xyz = position.xyz + displacementDirection * displacementFactor;
|
||||
}
|
||||
//
|
||||
position = ViewProjection * position;
|
||||
|
||||
gl_Position = z_normalization(position);
|
||||
}
|
||||
Reference in New Issue
Block a user