Browse Source

Shaders: fix default alpha mask in a zero-light Phong on GLES.

A corner case of a corner case, of a corner case. Adapted the test to
check the defaults as well.
pull/430/head
Vladimír Vondruš 6 years ago
parent
commit
0329721405
  1. 2
      doc/changelog.dox
  2. 4
      src/Magnum/Shaders/Phong.cpp
  3. 6
      src/Magnum/Shaders/Test/PhongGLTest.cpp

2
doc/changelog.dox

@ -391,6 +391,8 @@ See also:
- @ref Resource was unnecessarily querying the @ref ResourceManager for
updated data even in cases where no resource update was done since last
check
- For a @ref Shaders::Phong with zero lights, alpha mask default value was
incorrectly @cpp 0.0f @ce instead of @cpp 0.5f @ce on OpenGL ES
@subsection changelog-latest-deprecated Deprecated APIs

4
src/Magnum/Shaders/Phong.cpp

@ -191,12 +191,12 @@ Phong::Phong(const Flags flags, const UnsignedInt lightCount): _flags{flags}, _l
setDiffuseColor(Magnum::Color4{1.0f});
setSpecularColor(Magnum::Color4{1.0f});
setShininess(80.0f);
if(flags & Flag::AlphaMask) setAlphaMask(0.5f);
/* Object ID is zero by default */
setLightColors(Containers::Array<Magnum::Color4>{Containers::DirectInit, lightCount, Magnum::Color4{1.0f}});
/* Light position is zero by default */
setNormalMatrix({});
}
if(flags & Flag::AlphaMask) setAlphaMask(0.5f);
/* Object ID is zero by default */
#endif
}

6
src/Magnum/Shaders/Test/PhongGLTest.cpp

@ -1063,7 +1063,9 @@ void PhongGLTest::renderAlpha() {
.setSpecularColor(0xffffff00_rgbaf)
.bindTextures(&ambient, &diffuse, nullptr, nullptr);
if(data.flags & Phong::Flag::AlphaMask)
/* Test that the default is correct by not setting the threshold if it's
equal to the default */
if(data.flags & Phong::Flag::AlphaMask && data.threshold != 0.5f)
shader.setAlphaMask(data.threshold);
/* For proper Z order draw back faces first and then front faces */
@ -1213,7 +1215,7 @@ void PhongGLTest::renderZeroLights() {
Matrix4::rotationY(-15.0_degf)*
Matrix4::rotationX(15.0_degf))
.setProjectionMatrix(Matrix4::perspectiveProjection(60.0_degf, 1.0f, 0.1f, 10.0f))
.setAlphaMask(0.5f)
/* Keep alpha mask at the default 0.5 to test the default */
#ifndef MAGNUM_TARGET_GLES2
.setObjectId(65534)
#endif

Loading…
Cancel
Save