Changeset 2307 for trunk/src/lol/image/color.h
 Timestamp:
 Feb 1, 2013, 12:30:44 AM (10 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/src/lol/image/color.h
r2271 r2307 89 89 float K = 0.f; 90 90 91 if (src. b  src.g > 1e20f)91 if (src.g < src.b) 92 92 src = src.rbg, K = 1.f; 93 93 94 if (src. g  src.r > 1e20f)94 if (src.r < src.g) 95 95 src = src.grb, K = 2.f / 6.f  K; 96 96 97 97 float chroma = src.r  min(src.g, src.b); 98 return vec3(abs(K + (src.g  src.b) / (6.f * chroma + 1e20f)), 98 /* XXX: we use min() here because numerical stability is not 99 * guaranteed with ffastmath, I’ve seen it fail on i386. */ 100 return vec3(min(abs(K + (src.g  src.b) / (6.f * chroma)), 1.f), 99 101 chroma / (src.r + 1e20f), 100 102 src.r); … … 113 115 float K = 0.f; 114 116 115 /* FIXME: this appears to be needed for numerical stability on 116 * i386 hardware using ffastmath. Otherwise if (src.g < src.b) 117 * would suffice. */ 118 if (src.b  src.g > 1e20f) 117 if (src.g < src.b) 119 118 src = src.rbg, K = 1.f; 120 119 121 if (src. g  src.r > 1e20f)120 if (src.r < src.g) 122 121 src = src.grb, K = 2.f / 6.f  K; 123 122 124 123 float chroma = src.r  min(src.g, src.b); 125 124 float luma = src.r + min(src.g, src.b); 126 return vec3(abs(K + (src.g  src.b) / (6.f * chroma + 1e20f)),127 chroma / (min(luma, 2.f  luma) + 1e20f),128 125 float h = min(abs(K + (src.g  src.b) / (6.f * chroma)), 1.f); 126 float s = clamp(chroma / (min(luma, 2.f  luma)), 0.f, 1.f); 127 return vec3(h, s, 0.5f * luma); 129 128 } 130 129
Note: See TracChangeset
for help on using the changeset viewer.