@@ -860,6 +860,9 @@ void Trace::ComputeLightedTexture(MathColour& resultColour, ColourChannel& resul
860860 else
861861 att = layCol.Opacity ();
862862
863+ if (layer->Finish ->AlphaKnockout )
864+ listWNRX->back ().reflec *= att;
865+
863866 // now compute the BRDF or BSSRDF contribution
864867 tmpCol.Clear ();
865868
@@ -964,7 +967,12 @@ void Trace::ComputeLightedTexture(MathColour& resultColour, ColourChannel& resul
964967 // (We don't need to do this for (non-radiosity) rays during pretrace, as it does not affect radiosity sampling)
965968 if (!ray.IsPretraceRay ())
966969 {
967- if ((layer->Finish ->Diffuse != 0.0 ) || (layer->Finish ->DiffuseBack != 0.0 ) || (layer->Finish ->Specular != 0.0 ) || (layer->Finish ->Phong != 0.0 ))
970+ if (((layer->Finish ->Diffuse != 0.0 ) ||
971+ (layer->Finish ->DiffuseBack != 0.0 ) ||
972+ (layer->Finish ->Specular != 0.0 ) ||
973+ (layer->Finish ->Phong != 0.0 )) &&
974+ ((!layer->Finish ->AlphaKnockout ) ||
975+ (att != 0.0 )))
968976 {
969977 MathColour classicContribution;
970978
@@ -1643,18 +1651,22 @@ void Trace::ComputeOneDiffuseLight(const LightSource &lightsource, const Vector3
16431651 // surface-only diffuse term, they should use layered textures.
16441652 ComputeDiffuseColour (finish, lightsourceray.Direction , eye.Direction , layer_normal, tmpCol, lightcolour, layer_pigment_colour, relativeIor, attenuation, backside);
16451653
1654+ MathColour tempLightColour = (finish->AlphaKnockout ? lightcolour * attenuation : lightcolour);
1655+
16461656 // NK rad - don't compute highlights for radiosity gather rays, since this causes
16471657 // problems with colors being far too bright
16481658 // don't compute highlights for diffuse backside illumination
16491659 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)?
16501660 {
16511661 if (finish->Phong > 0.0 )
16521662 {
1653- ComputePhongColour (finish, lightsourceray.Direction , eye.Direction , layer_normal, tmpCol, lightcolour, layer_pigment_colour, relativeIor);
1663+ ComputePhongColour (finish, lightsourceray.Direction , eye.Direction , layer_normal, tmpCol,
1664+ tempLightColour, layer_pigment_colour, relativeIor);
16541665 }
16551666
16561667 if (finish->Specular > 0.0 )
1657- ComputeSpecularColour (finish, lightsourceray.Direction , -eye.Direction , layer_normal, tmpCol, lightcolour, layer_pigment_colour, relativeIor);
1668+ ComputeSpecularColour (finish, lightsourceray.Direction , -eye.Direction , layer_normal, tmpCol,
1669+ tempLightColour, layer_pigment_colour, relativeIor);
16581670 }
16591671
16601672 if (finish->Irid > 0.0 )
0 commit comments