Skip to content

Commit e205d77

Browse files
committed
Add feature to knock out highlights and reflections depending on pigment transparency.
1 parent 79ed353 commit e205d77

File tree

7 files changed

+28
-5
lines changed

7 files changed

+28
-5
lines changed

changes.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ Prior to the release of 3.7.1, the following items still need urgent attention:
4949
New Features
5050
------------
5151

52+
- A new finish parameter, `use_alpha BOOL`, has been added. If set to `on`,
53+
pigment transparency suppresses highlights and reflections. The default
54+
setting is `off`.
55+
5256
- A new pattern, `potential`, has been added to define a pattern based on the
5357
potential field of a blob or isosurface object.
5458

source/base/version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
#define OFFICIAL_VERSION_STRING "3.7.1"
4646
#define OFFICIAL_VERSION_NUMBER 371
4747

48-
#define POV_RAY_PRERELEASE "alpha"
48+
#define POV_RAY_PRERELEASE "x.knockout.8881807"
4949

5050
#if (POV_RAY_IS_AUTOBUILD == 1) && ((POV_RAY_IS_OFFICIAL == 1) || (POV_RAY_IS_SEMI_OFFICIAL == 1))
5151
#ifdef POV_RAY_PRERELEASE

source/core/material/texture.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,6 +1187,8 @@ FINISH *Create_Finish()
11871187
New->SubsurfaceTranslucency.Clear();
11881188
New->SubsurfaceAnisotropy.Clear();
11891189

1190+
New->AlphaKnockout = false;
1191+
11901192
return(New);
11911193
}
11921194

source/core/material/texture.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ struct Finish_Struct
132132
SNGL Reflect_Metallic; // MBP
133133
int Conserve_Energy; // added by NK Dec 19 1999
134134
bool UseSubsurface; // whether to use subsurface light transport
135+
bool AlphaKnockout; // whether pigment alpha knocks out finish effects
135136
};
136137

137138

source/core/render/trace.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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)

source/parser/parser_materials.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2632,6 +2632,10 @@ void Parser::Parse_Finish (FINISH **Finish_Ptr)
26322632
Parse_End();
26332633
END_CASE
26342634

2635+
CASE (USE_ALPHA_TOKEN)
2636+
New->AlphaKnockout = ((int) Allow_Float(1.0) != 0);
2637+
END_CASE
2638+
26352639
OTHERWISE
26362640
UNGET
26372641
EXIT

unix/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.7.1-alpha
1+
3.7.1-x.knockout.8881807

0 commit comments

Comments
 (0)