From 5c06009446fce163bf86f96bc058f8095973b257 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 12 Jun 2013 14:13:44 +0200 Subject: [PATCH] Reverted interval in distancefield-related things. 1.0 is taken as shape center (white), 0.0 as shape surroundings (black). It was unintuitive to have it reverted, updated documentation to make it right. --- src/Shaders/DistanceFieldVector.frag | 8 ++++---- src/Shaders/DistanceFieldVector.h | 8 ++++---- src/TextureTools/DistanceField.h | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Shaders/DistanceFieldVector.frag b/src/Shaders/DistanceFieldVector.frag index 1f525eca7..07d9bbe2a 100644 --- a/src/Shaders/DistanceFieldVector.frag +++ b/src/Shaders/DistanceFieldVector.frag @@ -32,12 +32,12 @@ #ifdef EXPLICIT_UNIFORM_LOCATION layout(location = 1) uniform lowp vec4 color; layout(location = 2) uniform lowp vec4 outlineColor; -layout(location = 3) uniform lowp vec2 outlineRange = vec2(0.5, 0.0); +layout(location = 3) uniform lowp vec2 outlineRange = vec2(0.5, 1.0); layout(location = 4) uniform lowp float smoothness = 0.04; #else uniform lowp vec4 color; uniform lowp vec4 outlineColor; -uniform lowp vec2 outlineRange = vec2(0.5, 0.0); +uniform lowp vec2 outlineRange = vec2(0.5, 1.0); uniform lowp float smoothness = 0.04; #endif #else @@ -66,9 +66,9 @@ void main() { fragmentColor = smoothstep(outlineRange.x-smoothness, outlineRange.x+smoothness, intensity)*color; /* Outline */ - if(outlineRange.x < outlineRange.y) { + if(outlineRange.x > outlineRange.y) { lowp float mid = (outlineRange.x + outlineRange.y)/2.0; - lowp float half = (outlineRange.y - outlineRange.x)/2.0; + lowp float half = (outlineRange.x - outlineRange.y)/2.0; fragmentColor += smoothstep(half+smoothness, half-smoothness, distance(mid, intensity))*outlineColor; } } diff --git a/src/Shaders/DistanceFieldVector.h b/src/Shaders/DistanceFieldVector.h index 06bd4c8dc..72ef45949 100644 --- a/src/Shaders/DistanceFieldVector.h +++ b/src/Shaders/DistanceFieldVector.h @@ -81,12 +81,12 @@ template class MAGNUM_SHADERS_EXPORT DistanceFieldVector * @return Pointer to self (for method chaining) * * Parameter @p start describes where fill ends and possible outline - * starts. Initial value is `0.5f`, smaller values will make the vector - * art look thinner, larger will make it look thicker. + * starts. Initial value is `0.5f`, larger values will make the vector + * art look thinner, smaller will make it look thicker. * * Parameter @p end describes where outline ends. If set to value - * smaller than @p start the outline is not drawn. Initial value is - * `0.0f`. + * larger than @p start the outline is not drawn. Initial value is + * `1.0f`. * * @see setOutlineColor() */ diff --git a/src/TextureTools/DistanceField.h b/src/TextureTools/DistanceField.h index fba73a37a..6685395db 100644 --- a/src/TextureTools/DistanceField.h +++ b/src/TextureTools/DistanceField.h @@ -56,9 +56,9 @@ foundation for features like outlining, glow or drop shadow essentialy for free. For each pixel inside @p rectangle the algorithm looks at corresponding pixel in @p input and tries to find nearest pixel of opposite color in area given by @p radius. Signed distance between the points is then saved as value of given -pixel in @p output. Value of `0` means that the pixel was originally colored -white and nearest black pixel is farther than @p radius, value of `1` means that -the pixel was originally black and nearest white pixel is farther than +pixel in @p output. Value of `1.0` means that the pixel was originally colored +white and nearest black pixel is farther than @p radius, value of `0.0` means +that the pixel was originally black and nearest white pixel is farther than @p radius. Values around `0.5` are around edges. The resulting texture can be used with bilinear filtering. It can be converted