Changeset 2200
- Timestamp:
- Jan 4, 2013, 2:57:10 PM (10 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/image/color/cie1931.cpp
r2199 r2200 696 696 0.616053f, 0.99911f, 0.001091f, 697 697 0.633948f, 0.99977f, 0.000711f, 698 0.651901f, 1 f, 0.000407f,698 0.651901f, 1.f, 0.000407f, 699 699 0.669824f, 0.99971f, 0.000184f, 700 700 0.687632f, 0.99885f, 0.000047f, … … 974 974 vec3 Color::WavelengthToCIExyY(float nm) 975 975 { 976 if (nm < 360.0f || nm > 830.0f) 977 return vec3(0.0f, 0.0f); 978 979 int index = (int)nm * 3; 980 float x = cie_1931_xyz[index]; 981 float y = cie_1931_xyz[index + 1]; 982 float z = cie_1931_xyz[index + 2]; 983 984 return vec3(x, y, 100.0f); 976 nm -= 360.f; 977 978 int i = (int)nm; 979 if (i < 0 || i > 830 - 360) 980 return vec3(0.0f); 981 982 float t = nm - i, s = 1.0 - t; 983 float x = s * cie_1931_xyz[i * 3 + 0] + t * cie_1931_xyz[i * 3 + 3]; 984 float y = s * cie_1931_xyz[i * 3 + 1] + t * cie_1931_xyz[i * 3 + 4]; 985 float z = s * cie_1931_xyz[i * 3 + 2] + t * cie_1931_xyz[i * 3 + 5]; 986 float normalize = 1.f / (x + y + z); 987 988 return vec3(x * normalize, y * normalize, 100.0f); 985 989 } 986 990 -
trunk/src/lol/image/color.h
r2199 r2200 277 277 278 278 /* Convert a wavelength to an xyY fully saturated colour */ 279 vec3 WavelengthToCIExyY(float nm);279 static vec3 WavelengthToCIExyY(float nm); 280 280 }; 281 281
Note: See TracChangeset
for help on using the changeset viewer.