mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-04 02:29:49 -06:00
Fix height mapping bugs in renderable planet
This commit is contained in:
@@ -236,6 +236,7 @@ RenderablePlanet::RenderablePlanet(const ghoul::Dictionary& dictionary)
|
||||
if (dictionary.hasKey(PerformShadingInfo.identifier)) {
|
||||
_performShading = dictionary.value<bool>(PerformShadingInfo.identifier);
|
||||
}
|
||||
addProperty(_performShading);
|
||||
|
||||
addPropertySubOwner(_geometry.get());
|
||||
|
||||
@@ -256,11 +257,6 @@ RenderablePlanet::RenderablePlanet(const ghoul::Dictionary& dictionary)
|
||||
}
|
||||
addProperty(_heightExaggeration);
|
||||
|
||||
if (dictionary.hasKey(HeightExaggerationInfo.identifier)) {
|
||||
_performShading = dictionary.value<bool>(HeightExaggerationInfo.identifier);
|
||||
}
|
||||
addProperty(_performShading);
|
||||
|
||||
//================================================================
|
||||
//======== Reads Shadow (Eclipses) Entries in mod file ===========
|
||||
//================================================================
|
||||
|
||||
@@ -40,6 +40,9 @@ uniform mat4 ModelTransform;
|
||||
uniform dmat4 modelViewTransform;
|
||||
uniform mat4 modelViewProjectionTransform;
|
||||
|
||||
uniform sampler2D heightTex;
|
||||
uniform bool _hasHeightMap;
|
||||
uniform float _heightExaggeration;
|
||||
|
||||
void main() {
|
||||
vs_st = in_st;
|
||||
@@ -53,6 +56,13 @@ void main() {
|
||||
|
||||
vec4 position = vec4(in_position.xyz * pow(10, in_position.w), 1.0);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
// G-Buffer
|
||||
vs_gPosition = vec4(modelViewTransform * position); // Must be in SGCT eye space;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user