STARK: Surfaces can be drawn with a B&W saturation effect

This commit is contained in:
Bastien Bouclet 2015-12-24 18:37:18 +01:00
parent b358f025a1
commit defa657429
4 changed files with 17 additions and 8 deletions

View File

@ -56,8 +56,7 @@ void OpenGLSSurfaceRenderer::render(const Texture *texture, const Common::Point
_gfx->start2DMode();
_shader->use();
_shader->setUniform("textured", true);
_shader->setUniform("color", Math::Vector4d(1.0f, 1.0f, 1.0f, 1.0f));
_shader->setUniform1f("fadeLevel", _fadeLevel);
_shader->setUniform("verOffsetXY", normalizeOriginalCoordinates(sLeft, sTop));
if (_noScalingOverride) {
_shader->setUniform("verSizeWH", normalizeCurrentCoordinates(sWidth, sHeight));

View File

@ -26,7 +26,8 @@ namespace Stark {
namespace Gfx {
SurfaceRenderer::SurfaceRenderer() :
_noScalingOverride(false) {
_noScalingOverride(false),
_fadeLevel(0) {
}
@ -38,5 +39,9 @@ void SurfaceRenderer::setNoScalingOverride(bool noScalingOverride) {
_noScalingOverride = noScalingOverride;
}
void SurfaceRenderer::setFadeLevel(float fadeLevel) {
_fadeLevel = fadeLevel;
}
} // End of namespace Gfx
} // End of namespace Stark

View File

@ -51,8 +51,16 @@ public:
*/
void setNoScalingOverride(bool noScalingOverride);
/**
* The fade level is added to the color value of each pixel
*
* It is a value between -1 and 1
*/
void setFadeLevel(float fadeLevel);
protected:
bool _noScalingOverride;
float _fadeLevel;
};
} // End of namespace Gfx

View File

@ -2,12 +2,9 @@ in vec2 Texcoord;
OUTPUT
uniform bool textured;
uniform vec4 color;
uniform float fadeLevel;
uniform sampler2D tex;
void main() {
outColor = color;
if (textured)
outColor = outColor * texture(tex, Texcoord);
outColor = texture(tex, Texcoord) + vec4(fadeLevel, fadeLevel, fadeLevel, 0);
}