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 tracer 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 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.