@@ -858,6 +858,9 @@ void Trace::ComputeLightedTexture(MathColour& resultColour, ColourChannel& resul
858858 else
859859 att = layCol.Opacity ();
860860
861+ if (layer->Finish ->AlphaKnockout )
862+ listWNRX->back ().reflec *= att;
863+
861864 // now compute the BRDF or BSSRDF contribution
862865 tmpCol.Clear ();
863866
@@ -962,7 +965,12 @@ void Trace::ComputeLightedTexture(MathColour& resultColour, ColourChannel& resul
962965 // (We don't need to do this for (non-radiosity) rays during pretrace, as it does not affect radiosity sampling)
963966 if (!ray.IsPretraceRay ())
964967 {
965- if ((layer->Finish ->Diffuse != 0.0 ) || (layer->Finish ->DiffuseBack != 0.0 ) || (layer->Finish ->Specular != 0.0 ) || (layer->Finish ->Phong != 0.0 ))
968+ if (((layer->Finish ->Diffuse != 0.0 ) ||
969+ (layer->Finish ->DiffuseBack != 0.0 ) ||
970+ (layer->Finish ->Specular != 0.0 ) ||
971+ (layer->Finish ->Phong != 0.0 )) &&
972+ ((!layer->Finish ->AlphaKnockout ) ||
973+ (att != 0.0 )))
966974 {
967975 MathColour classicContribution;
968976
@@ -1641,18 +1649,22 @@ void Trace::ComputeOneDiffuseLight(const LightSource &lightsource, const Vector3
16411649 // surface-only diffuse term, they should use layered textures.
16421650 ComputeDiffuseColour (finish, lightsourceray.Direction , eye.Direction , layer_normal, tmpCol, lightcolour, layer_pigment_colour, relativeIor, attenuation, backside);
16431651
1652+ MathColour tempLightColour = (finish->AlphaKnockout ? lightcolour * attenuation : lightcolour);
1653+
16441654 // NK rad - don't compute highlights for radiosity gather rays, since this causes
16451655 // problems with colors being far too bright
16461656 // don't compute highlights for diffuse backside illumination
16471657 if ((lightsource.Light_Type != FILL_LIGHT_SOURCE) && !eye.IsRadiosityRay () && !backside) // TODO FIXME radiosity - is this really the right way to do it (speaking of realism)?
16481658 {
16491659 if (finish->Phong > 0.0 )
16501660 {
1651- ComputePhongColour (finish, lightsourceray.Direction , eye.Direction , layer_normal, tmpCol, lightcolour, layer_pigment_colour, relativeIor);
1661+ ComputePhongColour (finish, lightsourceray.Direction , eye.Direction , layer_normal, tmpCol,
1662+ tempLightColour, layer_pigment_colour, relativeIor);
16521663 }
16531664
16541665 if (finish->Specular > 0.0 )
1655- ComputeSpecularColour (finish, lightsourceray.Direction , -eye.Direction , layer_normal, tmpCol, lightcolour, layer_pigment_colour, relativeIor);
1666+ ComputeSpecularColour (finish, lightsourceray.Direction , -eye.Direction , layer_normal, tmpCol,
1667+ tempLightColour, layer_pigment_colour, relativeIor);
16561668 }
16571669
16581670 if (finish->Irid > 0.0 )
0 commit comments