# Spectral path tracing - image color/brightness incorrect

I implemented a spectral path tracing using physically base BRDF models such as Oren-Nayar,Specular Reflection and Transmission, Lambertian. All calculation in the path tracer uses standard illuminant and macbeth color checker SPD, spectral power distribution. The result of the path tracer for each pixel is the SPD obtained as a sum of SPD obtained from each sample calculated by the pat tracer. This SPD is then converted to CIE XYZ color and to RGB. The result scene obtained is the following one (in this example taking 500 samples per pixel):

As you can see, everything seems fine, except for the brightness/luminance of the scene. Every object in the scene is darker than it have to be. The floor and the front wall of the cornell box in the scene must be white and neutral8 (from macbeth color checker), but they are dark gray. The following method is the one that trace the samples for a pixel of the path tracer:

Vector3D PathTracer::getPixelColor(const Ray& ray, int bounce) {

Spectrum<constant::spectrumSamples> L(0.0f);
int numberOfSamples = 500;
float sampleWeight = 1.0f/(float)numberOfSamples;

for (int i = 0; i < numberOfSamples; i++) {

Spectrum<constant::spectrumSamples> spectrumSample = trace(ray, bounce);
L = L + spectrumSample * sampleWeight;
}

Spectrum<constant::spectrumSamples> Li = scene->light->spectrum;

ColorMatchingFunction* colorMatchingFunction = new Standard2ObserverColorMatchingFunction();

//Get tristimulus values.
Vector3D tristimulus = CIE1931XYZ::tristimulusValues(L, Li, colorMatchingFunction);

//Convert tristimulus to sRGB.
Vector3D color = CIE1931XYZ::tristimulusTosRGB(tristimulus);

//Apply sRGB gamma correction.
sRGB::sRGBGammaCorrection(color, GammaCompanding);

//Convert to standard 0 - 255 RGB value.
sRGB::sRGBStandardRange(color);

delete colorMatchingFunction;

return color;
}


As you can seen, I already apply a gamma correction to the color obtained. Do you have any idea why my image rendered is so dark? My concerns are in the part where I convert the SPD sum, obtained from the samples, into RGB color. Do you see any error? Am I missing something? Do I need other operation to execute a correct conversion from the SPD obtained from the sampling to an RGB color?

To avoid to write a too long question, I will link the main classes used by the path tracer for the calculation:

The other files/classes used are all on this repository (branch luminance)

https://github.com/chicio/Spectrum-Clara-Lux-Tracer/tree/luminance

Thanks you all guys, I hope someone could help me.

• It is perfectly OK if your material looks dark gray if you illuminate it with weak light source. What is the brightness of the light source? – ivokabel Mar 20 '16 at 23:14
• @ivokabel but my materials should look white and light gray. The SPD of the illuminant used is the D65. Do i need to tweak the spd of the light in some way? – Fabrizio Duroni Mar 20 '16 at 23:17
• @ivokabel Do i need to define a brightness paramter and use it somewhere? – Fabrizio Duroni Mar 20 '16 at 23:17
• If I am not mistaken, D65 only defines the shape of the spectrum, not the intensity. Therefore, you will really have to add a parameter telling the amount of emitting radiance, or something similar. Related topic is the renderer exposure value, but I saw that you take 1 as the limit value, so you don't have to bother with this one. – ivokabel Mar 20 '16 at 23:37
• Thank you @ivokabel for the suggestion about the parameter radiance. Could it be just a constant that will be multiplied with the spd of the illuminant during the tracing of rays? Or do i need to multiply the spd of the illuminant during the conversion from spd to cie xyz? Also I don't understand what you mean with renderer exposure value. Where do I take 1 as its value? – Fabrizio Duroni Mar 20 '16 at 23:45

The problem lies mainly in CIE1931XYZ::tristimulusValues() function, where you normalize the resulting color to the luminance of your illuminant which causes that directly observed light source has luminance 1, but everything else is much darker. That is a nice thing to do if you just want to visualize colours of various reflectance spectra under a given illumination, but is probably not the best thing to do in a global illumination renderer.