I'm currently developing a modified glass material for Luxcore on behalf of a client of mine, but I'm getting some behaviour out of the Sample function which I don't understand, and I wonder if you can provide some advice?
Inside Sample, I have code like this (rather like that from glass.cpp):
Code: Select all
if (passThroughEvent < threshold) {
// Transmit
*localSampledDir = -localFixedDir;
*event = SPECULAR | TRANSMIT;
*pdfW = threshold;
return kt; // kt is the precomputed transmit colour
}
else if (passThroughEvent > threshold) { // reason for this will become apparent in a moment.
// Reflection
//again, standard code, elided for clarity
}
else return Spectrum ();
Code: Select all
if (passThroughEvent < threshold/2.f) {
// Transmit
*localSampledDir = -localFixedDir;
*event = SPECULAR | TRANSMIT;
*pdfW = threshold;
return kt * 2;
}
else if (passThroughEvent > threshold) {
// Reflection
// ...
}
else return Spectrum ();
Code: Select all
if (passThroughEvent < threshold/2.f) {
// Transmit
*localSampledDir = -localFixedDir;
*event = SPECULAR | TRANSMIT;
*pdfW = threshold;
return kt * 20; // Loads of gain
}
else if (passThroughEvent > threshold) {
// Reflection
// ...
}
else return Spectrum ();
As far as I can see, the only place where the transmitted colour is set is in this function, so I don't understand how the additional gain can be used some of the times and not others. So, may I ask, please:
1. Why/how is the brightness of the colour treated differently depending on whether we're looking through it or shining light through it?
2. What do I need to do to create high-gain transmission?
3. What is the role of pdfW here? I fiddled with it, but couldn't see any noticeable effect.
Thanks