Enable fading of projection layer

This commit is contained in:
Alexander Bock
2016-06-03 16:57:24 +02:00
parent 239ac0ab4e
commit 89d5e69da4
3 changed files with 8 additions and 5 deletions

View File

@@ -82,6 +82,7 @@ RenderableModelProjection::RenderableModelProjection(const ghoul::Dictionary& di
, _fboProgramObject(nullptr)
, _baseTexture(nullptr)
, _projectionTexture(nullptr)
, _projectionFading("projectionFading", "Projection Fading", 1.f, 0.f, 1.f)
, _geometry(nullptr)
, _alpha(1.f)
, _performShading("performShading", "Perform Shading", true)
@@ -113,6 +114,8 @@ RenderableModelProjection::RenderableModelProjection(const ghoul::Dictionary& di
addPropertySubOwner(_geometry);
addProperty(_projectionFading);
addProperty(_colorTexturePath);
_colorTexturePath.onChange(std::bind(&RenderableModelProjection::loadTextures, this));
@@ -351,6 +354,7 @@ void RenderableModelProjection::render(const RenderData& data) {
_programObject->setUniform("sun_pos", _sunPosition.vec3());
_programObject->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
_programObject->setUniform("ModelTransform", _transform);
_programObject->setUniform("_projectionFading", _projectionFading);
setPscUniforms(*_programObject, data.camera, data.position);
_geometry->setUniforms(*_programObject);

View File

@@ -85,6 +85,8 @@ namespace openspace {
std::unique_ptr<ghoul::opengl::Texture> _baseTexture;
std::unique_ptr<ghoul::opengl::Texture> _projectionTexture;
properties::FloatProperty _projectionFading;
modelgeometry::ModelGeometry* _geometry;
float _alpha;

View File

@@ -36,8 +36,7 @@ uniform vec3 camdir;
uniform sampler2D baseTexture;
uniform sampler2D projectionTexture;
uniform bool _performShading;
uniform float _projectionFading;
uniform vec3 sun_pos;
Fragment getFragment() {
@@ -75,12 +74,10 @@ Fragment getFragment() {
textureColor.rgb = mix(
textureColor.rgb,
projectionColor.rgb,
min(1.0, projectionColor.a)
min(_projectionFading, projectionColor.a)
);
}
// textureColor = projectionColor;
Fragment frag;
frag.color = max(intensity * textureColor, ambient);
frag.depth = depth;