Browse Source

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.
pull/268/head
Vladimír Vondruš 8 years ago
parent
commit
fd1572a3a3
  1. 7
      doc/changelog.dox
  2. 2
      src/Magnum/Shaders/Phong.cpp
  3. 2
      src/Magnum/Shaders/Phong.frag
  4. 2
      src/Magnum/Shaders/Phong.h

7
doc/changelog.dox

@ -165,6 +165,9 @@ See also:
@ref Shaders::Phong::bindTextures() now assert that the shader was created @ref Shaders::Phong::bindTextures() now assert that the shader was created
with the corresponding flag enabled to prevent accidental "black screen of with the corresponding flag enabled to prevent accidental "black screen of
death" errors. 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 @subsubsection changelog-latest-changes-texturetools TextureTools library
@ -265,6 +268,10 @@ See also:
with the corresponding flag enabled to prevent accidental "black screen of with the corresponding flag enabled to prevent accidental "black screen of
death" errors. This might cause your application to abort if it was calling death" errors. This might cause your application to abort if it was calling
these functions when not needed. 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::ambientColor(),
@ref Trade::PhongMaterialData::diffuseColor() "diffuseColor()" and @ref Trade::PhongMaterialData::diffuseColor() "diffuseColor()" and
@ref Trade::PhongMaterialData::specularColor() "specularColor()" now return @ref Trade::PhongMaterialData::specularColor() "specularColor()" now return

2
src/Magnum/Shaders/Phong.cpp

@ -117,7 +117,7 @@ Phong::Phong(const Flags flags): _flags(flags) {
#ifdef MAGNUM_TARGET_GLES #ifdef MAGNUM_TARGET_GLES
/* Default to fully opaque white so we can see the textures */ /* Default to fully opaque white so we can see the textures */
if(flags & Flag::AmbientTexture) setAmbientColor(Color4{1.0f}); if(flags & Flag::AmbientTexture) setAmbientColor(Color4{1.0f});
else setAmbientColor(Color4{0.0f, 1.0f}); else setAmbientColor(Color4{0.0f});
setDiffuseColor(Color4{1.0f}); setDiffuseColor(Color4{1.0f});
setSpecularColor(Color4{1.0f}); setSpecularColor(Color4{1.0f});
setLightColor(Color4{1.0f}); setLightColor(Color4{1.0f});

2
src/Magnum/Shaders/Phong.frag

@ -46,7 +46,7 @@ layout(location = 4)
uniform lowp vec4 ambientColor uniform lowp vec4 ambientColor
#ifndef GL_ES #ifndef GL_ES
#ifndef AMBIENT_TEXTURE #ifndef AMBIENT_TEXTURE
= vec4(0.0, 0.0, 0.0, 1.0) = vec4(0.0)
#else #else
= vec4(1.0) = vec4(1.0)
#endif #endif

2
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 * If @ref Flag::AmbientTexture is set, default value is
* @cpp 0xffffffff_rgbaf @ce and the color will be multiplied with * @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() * @see @ref bindAmbientTexture()
*/ */
Phong& setAmbientColor(const Color4& color) { Phong& setAmbientColor(const Color4& color) {

Loading…
Cancel
Save