Fix height mapping bugs in renderable planet

This commit is contained in:
Emil Axelsson
2018-01-16 17:05:46 +01:00
parent f9d4290af1
commit d569b8235e
2 changed files with 11 additions and 5 deletions

View File

@@ -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 ===========
//================================================================

View 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;