From fd1572a3a3f7a03d4f785d55abeacaff71e242c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 4 Aug 2018 15:24:40 +0200 Subject: [PATCH] Shaders: default ambient color in Phong to transparent black. Makes it possible to support alpha-masked drawing out of the box, shouldn't have any negative effect on anything else. --- doc/changelog.dox | 7 +++++++ src/Magnum/Shaders/Phong.cpp | 2 +- src/Magnum/Shaders/Phong.frag | 2 +- src/Magnum/Shaders/Phong.h | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/doc/changelog.dox b/doc/changelog.dox index d7425cc6b..4cedf8449 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -165,6 +165,9 @@ See also: @ref Shaders::Phong::bindTextures() now assert that the shader was created with the corresponding flag enabled to prevent accidental "black screen of death" errors. +- Ambient color in untextured @ref Shaders::Phong now defaults to + @cpp 0x00000000_rgbaf @ce in order to support alpha-masked drawing out of + the box @subsubsection changelog-latest-changes-texturetools TextureTools library @@ -265,6 +268,10 @@ See also: with the corresponding flag enabled to prevent accidental "black screen of death" errors. This might cause your application to abort if it was calling these functions when not needed. +- Ambient color in untextured @ref Shaders::Phong now defaults to + @cpp 0x00000000_rgbaf @ce in order to support alpha-masked drawing out of + the box. This may break code that assumed the alpha channel being opaque by + default. - @ref Trade::PhongMaterialData::ambientColor(), @ref Trade::PhongMaterialData::diffuseColor() "diffuseColor()" and @ref Trade::PhongMaterialData::specularColor() "specularColor()" now return diff --git a/src/Magnum/Shaders/Phong.cpp b/src/Magnum/Shaders/Phong.cpp index 2a682269c..e20beac6a 100644 --- a/src/Magnum/Shaders/Phong.cpp +++ b/src/Magnum/Shaders/Phong.cpp @@ -117,7 +117,7 @@ Phong::Phong(const Flags flags): _flags(flags) { #ifdef MAGNUM_TARGET_GLES /* Default to fully opaque white so we can see the textures */ if(flags & Flag::AmbientTexture) setAmbientColor(Color4{1.0f}); - else setAmbientColor(Color4{0.0f, 1.0f}); + else setAmbientColor(Color4{0.0f}); setDiffuseColor(Color4{1.0f}); setSpecularColor(Color4{1.0f}); setLightColor(Color4{1.0f}); diff --git a/src/Magnum/Shaders/Phong.frag b/src/Magnum/Shaders/Phong.frag index 8436b7b89..fbae0d82c 100644 --- a/src/Magnum/Shaders/Phong.frag +++ b/src/Magnum/Shaders/Phong.frag @@ -46,7 +46,7 @@ layout(location = 4) uniform lowp vec4 ambientColor #ifndef GL_ES #ifndef AMBIENT_TEXTURE - = vec4(0.0, 0.0, 0.0, 1.0) + = vec4(0.0) #else = vec4(1.0) #endif diff --git a/src/Magnum/Shaders/Phong.h b/src/Magnum/Shaders/Phong.h index 238349931..20d1ecca3 100644 --- a/src/Magnum/Shaders/Phong.h +++ b/src/Magnum/Shaders/Phong.h @@ -209,7 +209,7 @@ class MAGNUM_SHADERS_EXPORT Phong: public GL::AbstractShaderProgram { * * If @ref Flag::AmbientTexture is set, default value is * @cpp 0xffffffff_rgbaf @ce and the color will be multiplied with - * ambient texture, otherwise default value is @cpp 0x000000ff_rgbaf @ce. + * ambient texture, otherwise default value is @cpp 0x00000000_rgbaf @ce. * @see @ref bindAmbientTexture() */ Phong& setAmbientColor(const Color4& color) {