mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-05 03:00:58 -06:00
Enable shifting the meridian of a RenderablePlanetProjection by 180 for Pluto
This commit is contained in:
@@ -57,6 +57,7 @@ namespace {
|
||||
|
||||
const char* keyGeometry = "Geometry";
|
||||
const char* keyProjection = "Projection";
|
||||
const char* keyMeridianShift = "Textures.MeridianShift";
|
||||
const char* keyColorTexture = "Textures.Color";
|
||||
const char* keyHeightTexture = "Textures.Height";
|
||||
|
||||
@@ -91,6 +92,13 @@ documentation::Documentation RenderablePlanetProjection::Documentation() {
|
||||
"Contains information about projecting onto this planet.",
|
||||
Optional::No
|
||||
},
|
||||
{
|
||||
keyMeridianShift,
|
||||
new BoolVerifier,
|
||||
"Determines whether the meridian of the planet should be shifted by 180 "
|
||||
"degrees. The default value is 'false'",
|
||||
Optional::Yes
|
||||
},
|
||||
{
|
||||
keyColorTexture,
|
||||
new StringVerifier,
|
||||
@@ -118,6 +126,7 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary&
|
||||
, _heightMapTexturePath("heightMap", "Heightmap Texture")
|
||||
, _rotation("rotation", "Rotation", 0, 0, 360)
|
||||
, _heightExaggeration("heightExaggeration", "Height Exaggeration", 1.f, 0.f, 100.f)
|
||||
, _shiftMeridianBy180("shiftMeiridian", "Shift Meridian by 180 deg", false)
|
||||
, _debugProjectionTextureRotation("debug.projectionTextureRotation", "Projection Texture Rotation", 0.f, 0.f, 360.f)
|
||||
, _programObject(nullptr)
|
||||
, _fboProgramObject(nullptr)
|
||||
@@ -152,14 +161,19 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary&
|
||||
// as the requirements are fixed (ab)
|
||||
std::string texturePath = "";
|
||||
success = dictionary.getValue("Textures.Color", texturePath);
|
||||
if (success){
|
||||
if (success) {
|
||||
_colorTexturePath = absPath(texturePath);
|
||||
}
|
||||
|
||||
std::string heightMapPath = "";
|
||||
success = dictionary.getValue("Textures.Height", heightMapPath);
|
||||
if (success)
|
||||
if (success) {
|
||||
_heightMapTexturePath = absPath(heightMapPath);
|
||||
}
|
||||
|
||||
if (dictionary.hasKeyAndValue<bool>(keyMeridianShift)) {
|
||||
_shiftMeridianBy180 = dictionary.value<bool>(keyMeridianShift);
|
||||
}
|
||||
|
||||
glm::vec2 radius = glm::vec2(1.0, 9.0);
|
||||
dictionary.getValue(keyRadius, radius);
|
||||
@@ -176,6 +190,8 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary&
|
||||
|
||||
addProperty(_heightExaggeration);
|
||||
addProperty(_debugProjectionTextureRotation);
|
||||
|
||||
addProperty(_shiftMeridianBy180);
|
||||
}
|
||||
|
||||
RenderablePlanetProjection::~RenderablePlanetProjection() {}
|
||||
@@ -416,7 +432,9 @@ void RenderablePlanetProjection::render(const RenderData& data) {
|
||||
//_programObject->setUniform("debug_projectionTextureRotation", glm::radians(_debugProjectionTextureRotation.value()));
|
||||
|
||||
//setPscUniforms(*_programObject.get(), data.camera, data.position);
|
||||
|
||||
|
||||
_programObject->setUniform("shiftMeridian", _shiftMeridianBy180);
|
||||
|
||||
ghoul::opengl::TextureUnit unit[3];
|
||||
unit[0].activate();
|
||||
_baseTexture->bind();
|
||||
|
||||
@@ -76,6 +76,8 @@ private:
|
||||
std::unique_ptr<ghoul::opengl::Texture> _baseTexture;
|
||||
std::unique_ptr<ghoul::opengl::Texture> _heightMapTexture;
|
||||
|
||||
properties::BoolProperty _shiftMeridianBy180;
|
||||
|
||||
properties::FloatProperty _heightExaggeration;
|
||||
properties::FloatProperty _debugProjectionTextureRotation;
|
||||
|
||||
|
||||
@@ -83,8 +83,6 @@ void main() {
|
||||
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(projectionTexture, vec2(projected.x, projected.y));
|
||||
stencil = vec4(1.0);
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ in vec2 vs_st;
|
||||
|
||||
uniform sampler2D baseTexture;
|
||||
uniform sampler2D projectionTexture;
|
||||
uniform bool shiftMeridian;
|
||||
|
||||
uniform float _projectionFading;
|
||||
|
||||
@@ -39,6 +40,11 @@ uniform vec4 objpos;
|
||||
uniform vec3 sun_pos;
|
||||
|
||||
Fragment getFragment() {
|
||||
vec2 st = vs_st;
|
||||
if (shiftMeridian) {
|
||||
st.s += 0.5;
|
||||
}
|
||||
|
||||
// directional lighting
|
||||
vec3 origin = vec3(0.0);
|
||||
vec4 spec = vec4(0.0);
|
||||
@@ -49,13 +55,12 @@ Fragment getFragment() {
|
||||
vec3 l_dir = normalize(l_pos-objpos.xyz);
|
||||
float terminatorBrightness = 0.4;
|
||||
float intensity = min(max(5*dot(n,l_dir), terminatorBrightness), 1);
|
||||
|
||||
float shine = 0.0001;
|
||||
|
||||
vec4 specular = vec4(0.1);
|
||||
vec4 ambient = vec4(0.f,0.f,0.f,1);
|
||||
|
||||
vec4 textureColor = texture(baseTexture, vs_st);
|
||||
vec4 textureColor = texture(baseTexture, st);
|
||||
vec4 projectionColor = texture(projectionTexture, vs_st);
|
||||
if (projectionColor.a != 0.0) {
|
||||
textureColor.rgb = mix(
|
||||
|
||||
@@ -44,9 +44,16 @@ uniform mat4 modelViewProjectionTransform;
|
||||
uniform bool _hasHeightMap;
|
||||
uniform float _heightExaggeration;
|
||||
uniform sampler2D heightTexture;
|
||||
uniform bool shiftMeridian;
|
||||
|
||||
void main() {
|
||||
vs_st = in_st;
|
||||
|
||||
vec2 st = in_st;
|
||||
if (shiftMeridian) {
|
||||
st.s += 0.5;
|
||||
}
|
||||
|
||||
vec4 tmp = in_position;
|
||||
|
||||
// this is wrong for the normal.
|
||||
@@ -55,7 +62,7 @@ void main() {
|
||||
|
||||
|
||||
if (_hasHeightMap) {
|
||||
float height = texture(heightTexture, in_st).r;
|
||||
float height = texture(heightTexture, st).s;
|
||||
vec3 displacementDirection = (normalize(tmp.xyz));
|
||||
float displacementFactor = height * _heightExaggeration / 750.0;
|
||||
tmp.xyz = tmp.xyz + displacementDirection * displacementFactor;
|
||||
|
||||
Reference in New Issue
Block a user