diff --git a/doc/changelog.dox b/doc/changelog.dox index 72489ec1d..ad7b82e10 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -292,6 +292,11 @@ See also: also with @ref Corrade::Containers::ArrayView, @ref Corrade::Containers::StridedArrayView and friends +@subsubsection changelog-latest-changes-shaders Shaders library + +- @ref Shaders::Phong now clamps the specular factor to minimize artifacts + when shininess is near zero + @subsubsection changelog-latest-changes-texturetools TextureTools library - @ref TextureTools::distanceField() was updated to work on ES3 SwiftShader diff --git a/src/Magnum/Shaders/Phong.frag b/src/Magnum/Shaders/Phong.frag index 34e82be94..0e0575509 100644 --- a/src/Magnum/Shaders/Phong.frag +++ b/src/Magnum/Shaders/Phong.frag @@ -181,7 +181,7 @@ void main() { /* Add specular color, if needed */ if(intensity > 0.001) { highp vec3 reflection = reflect(-normalizedLightDirection, normalizedTransformedNormal); - mediump float specularity = pow(max(0.0, dot(normalize(cameraDirection), reflection)), shininess); + mediump float specularity = clamp(pow(max(0.0, dot(normalize(cameraDirection), reflection)), shininess), 0.0, 1.0); color += vec4(finalSpecularColor.rgb*specularity, finalSpecularColor.a); } }