diff --git a/src/Shaders/Flat.cpp b/src/Shaders/Flat.cpp index a6f94d830..d729f85ed 100644 --- a/src/Shaders/Flat.cpp +++ b/src/Shaders/Flat.cpp @@ -78,7 +78,7 @@ template Flat::Flat(const Flags flags): tran #endif { transformationProjectionMatrixUniform = uniformLocation("transformationProjectionMatrix"); - if(!(flags & Flag::Textured)) colorUniform = uniformLocation("color"); + colorUniform = uniformLocation("color"); } #ifndef MAGNUM_TARGET_GLES @@ -87,6 +87,11 @@ template Flat::Flat(const Flags flags): tran { if(flags & Flag::Textured) setUniform(uniformLocation("textureData"), TextureLayer); } + + /* Set defaults in OpenGL ES (for desktop they are set in shader code itself) */ + #ifdef MAGNUM_TARGET_GLES + setColor(Color4(1.0f)); // Default to white, with full transperancy (so we can see the texture) + #endif } template class Flat<2>; diff --git a/src/Shaders/Flat.frag b/src/Shaders/Flat.frag index 35e85bfcd..c2ea645cf 100644 --- a/src/Shaders/Flat.frag +++ b/src/Shaders/Flat.frag @@ -34,12 +34,20 @@ layout(binding = 0) uniform sampler2D textureData; #else uniform sampler2D textureData; #endif -#else +#endif + #ifdef EXPLICIT_UNIFORM_LOCATION +# ifndef GL_ES +layout(location = 1) uniform vec4 color = vec4(1.0f, 1.0f, 1.0f, 1.0f); +# else layout(location = 1) uniform vec4 color; +# endif #else -uniform lowp vec4 color; -#endif +# ifndef GL_ES +uniform lowp vec4 color = vec4(1.0f, 1.0f, 1.0f, 1.0f); +# else +unfirom lowp vec4 color; +# endif #endif #ifdef TEXTURED @@ -52,7 +60,7 @@ out lowp vec4 fragmentColor; void main() { #ifdef TEXTURED - fragmentColor = texture(textureData, interpolatedTextureCoordinates); + fragmentColor = color * texture(textureData, interpolatedTextureCoordinates); #else fragmentColor = color; #endif diff --git a/src/Shaders/Flat.h b/src/Shaders/Flat.h index 8e2b69627..955a62f2e 100644 --- a/src/Shaders/Flat.h +++ b/src/Shaders/Flat.h @@ -124,7 +124,8 @@ template class MAGNUM_SHADERS_EXPORT Flat: public Abstra * @brief Set color * @return Reference to self (for method chaining) * - * Has no effect if @ref Flag::Textured is set. + * Color will be multiplied with texture + * if @ref Flag::Textured is set. */ Flat& setColor(const Color4& color); @@ -144,7 +145,7 @@ typedef Flat<3> Flat3D; CORRADE_ENUMSET_OPERATORS(Implementation::FlatFlags) template inline Flat& Flat::setColor(const Color4& color) { - if(!(_flags & Flag::Textured)) setUniform(colorUniform, color); + setUniform(colorUniform, color); return *this; }