Changeset 2309


Ignore:
Timestamp:
Feb 1, 2013, 2:28:08 AM (6 years ago)
Author:
sam
Message:

color: fix a logic error in RGBToHSL.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lol/image/color.h

    r2308 r2309  
    123123        float chroma = src.r - min(src.g, src.b);
    124124        float luma = src.r + min(src.g, src.b);
     125        /* XXX: we use min() here because numerical stability is not
     126         * guaranteed with -ffast-math, I’ve seen it fail on i386. */
    125127        float h = min(abs(K + (src.g - src.b) / (6.f * chroma)), 1.f);
    126         float s = min(abs(chroma / (min(luma, 2.f - luma))), 1.f);
     128        float s = clamp(chroma / (min(luma, 2.f - luma)), 0.f, 1.f);
    127129        return vec3(h, s, 0.5f * luma);
    128130    }
Note: See TracChangeset for help on using the changeset viewer.