scale by illuminant

parent 6bfd8638
......@@ -276,9 +276,9 @@ void coloritto_ensure (Luz *luz, Coloritto *color, ColorittoDef color_type)
if ((!got_xyz && (color->set & COLORITTO_SPECTRUM_ON_WHITE) )||
(!got_xyz && (color->set & COLORITTO_SPECTRUM_ON_WHITE_AND_BLACK)))
{
luz_spectrum_to_xyz (luz, &color->on_white, &color->xyz[0],
&color->xyz[1],
&color->xyz[2]);
luz_reflectance_to_xyz (luz, &color->on_white, &color->xyz[0],
&color->xyz[1],
&color->xyz[2]);
color->computed |= COLORITTO_XYZ;
got_xyz = 1;
}
......
......@@ -140,9 +140,6 @@ static const char *config_internal =
// default configuration:
"observer_x=observer_x_1931\n"
"observer_y=observer_y_1931\n"
"observer_z=observer_z_1931\n"
"observer_x=observer_x_1964\n"
"observer_y=observer_y_1964\n"
......@@ -152,9 +149,11 @@ static const char *config_internal =
"observer_y=observer_y_1931jv\n"
"observer_z=observer_z_1931jv\n"
"illuminant=D65\n"
"observer_x=observer_x_1931\n"
"observer_y=observer_y_1931\n"
"observer_z=observer_z_1931\n"
"illuminant=D50\n"
"diffusion=0.55\n"
......
......@@ -232,22 +232,32 @@ illuminant_to_rev_y_scale (Luz *luz,
}
static inline void
spectrum_to_xyz (Luz *luz,
const Spectrum *observed,
luz_emissive_to_xyz (Luz *luz,
const Spectrum *spectrum,
float *x,
float *y,
float *z)
{
Spectrum rescaled = *observed;
*x = spectrum_integrate (&rescaled, &luz->STANDARD_OBSERVER_X) *
*x = spectrum_integrate (spectrum, &luz->STANDARD_OBSERVER_X) *
luz->rev_y_scale;
*y = spectrum_integrate (&rescaled, &luz->STANDARD_OBSERVER_Y) *
*y = spectrum_integrate (spectrum, &luz->STANDARD_OBSERVER_Y) *
luz->rev_y_scale;
*z = spectrum_integrate (&rescaled, &luz->STANDARD_OBSERVER_Z) *
*z = spectrum_integrate (spectrum, &luz->STANDARD_OBSERVER_Z) *
luz->rev_y_scale;
}
void
luz_reflectance_to_xyz (Luz *luz,
const Spectrum *spec,
float *x,
float *y,
float *z)
{
Spectrum rescaled;
spectrum_scale (&rescaled, spec, &luz->illuminant);
luz_emissive_to_xyz (luz, &rescaled, x, y, z);
}
void
luz_spectrum_to_xyz (Luz *luz,
const Spectrum *observed,
......@@ -255,7 +265,7 @@ luz_spectrum_to_xyz (Luz *luz,
float *y,
float *z)
{
spectrum_to_xyz (luz, observed, x, y, z);
luz_emissive_to_xyz (luz, observed, x, y, z);
}
static inline void
......@@ -264,7 +274,7 @@ spectrum_to_rgb (Luz *luz,
float *rgb)
{
float xyz[3];
spectrum_to_xyz (luz, observed, &xyz[0], &xyz[1], &xyz[2]);
luz_reflectance_to_xyz (luz, observed, &xyz[0], &xyz[1], &xyz[2]);
/* use babl instead */
rgb[0] = xyz[0] * 3.134274799724 +
xyz[1] * -1.617275708956 +
......@@ -356,7 +366,7 @@ luz_coats_to_xyz (Luz *luz,
float *xyz)
{
Spectrum perceived_spec = coats_to_spectrum (luz, coat_levels);
spectrum_to_xyz (luz, &perceived_spec, &xyz[0], &xyz[1], &xyz[2]);
luz_reflectance_to_xyz (luz, &perceived_spec, &xyz[0], &xyz[1], &xyz[2]);
}
static inline float
......
......@@ -74,6 +74,12 @@ void luz_spectrum_to_rgb (Luz *luz,
const Spectrum *spectrum,
float *rgb);
void luz_reflectance_to_xyz (Luz *luz,
const Spectrum *spec,
float *x,
float *y,
float *z);
void luz_spectrum_to_xyz (Luz *luz,
const Spectrum *spectrum,
float *x,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment