Skip to content

Commit fc2e8be

Browse files
committed
Safeguard Lommel-Seeliger and Oren-Nayar related code with preprocessor flags.
1 parent dd851ba commit fc2e8be

File tree

10 files changed

+79
-6
lines changed

10 files changed

+79
-6
lines changed

source/base/version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
/// where `N` is a serial number starting at 1 in each phase, `TIME` is the number of minutes
101101
/// since 2000-01-01 00:00, and `FEATURE` is an arbitrary alphanumeric moniker for a particular
102102
/// experimental feature.
103-
#define POV_RAY_PRERELEASE "x.diffuse.10021406"
103+
#define POV_RAY_PRERELEASE "x.diffuse.10021912"
104104

105105
#if defined(DOXYGEN) && !defined(POV_RAY_PRERELEASE)
106106
// Work around doxygen being unable to document undefined macros.

source/core/configcore.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,20 @@
5353
///
5454
/// @{
5555

56+
/// @def POV_EXPERIMENTAL_LOMMEL_SEELIGER
57+
/// Whether experimental Lommel-Seeliger diffuse reflection should be enabled.
58+
///
59+
#ifndef POV_EXPERIMENTAL_LOMMEL_SEELIGER
60+
#define POV_EXPERIMENTAL_LOMMEL_SEELIGER 1
61+
#endif
62+
63+
/// @def POV_EXPERIMENTAL_OREN_NAYAR
64+
/// Whether experimental Oren-Nayar diffuse reflection should be enabled.
65+
///
66+
#ifndef POV_EXPERIMENTAL_OREN_NAYAR
67+
#define POV_EXPERIMENTAL_OREN_NAYAR 1
68+
#endif
69+
5670
//******************************************************************************
5771
///
5872
/// @name PooledSimpleVector Sizes

source/core/material/texture.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,13 @@ FINISH *Create_Finish()
239239
#endif
240240
New->DiffuseAlbedoAdjust = 1.0;
241241
New->DiffuseAlbedoAdjustRad = 1.0;
242+
#if POV_EXPERIMENTAL_LOMMEL_SEELIGER
242243
New->LommelSeeligerWeight = 0.0;
244+
#endif
245+
#if POV_EXPERIMENTAL_OREN_NAYAR
243246
New->OrenNayarA = 1.0;
244247
New->OrenNayarB = 0.0;
248+
#endif
245249
New->Phong = 0.0;
246250
New->Phong_Size = 40.0;
247251
New->Specular = 0.0;

source/core/material/texture.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ struct Finish_Struct
114114
#endif
115115
SNGL DiffuseAlbedoAdjust, DiffuseAlbedoAdjustRad;
116116

117+
#if POV_EXPERIMENTAL_LOMMEL_SEELIGER
118+
117119
/// How much of the diffuse contribution should be computed using the Lommel-Seeliger model.
118120
///
119121
/// By default, POV-Ray uses a Lambertian-based diffuse reflectivity model. While this model is useful for
@@ -122,6 +124,10 @@ struct Finish_Struct
122124
/// is frequently used.
123125
SNGL LommelSeeligerWeight;
124126

127+
#endif
128+
129+
#if POV_EXPERIMENTAL_OREN_NAYAR
130+
125131
/// @name Oren-Nayar diffuse model parameters.
126132
///
127133
/// By default, POV-Ray uses a Lambertian-based diffuse reflectivity model. While this model is useful for
@@ -137,6 +143,8 @@ struct Finish_Struct
137143
/// Factor B of the simplified Oren-Nayar model, defaulting to 0.0 for the Lambertian model.
138144
SNGL OrenNayarB;
139145

146+
#endif
147+
140148
/// @}
141149

142150
SNGL Specular, Roughness;
@@ -155,6 +163,8 @@ struct Finish_Struct
155163
bool UseSubsurface; // whether to use subsurface light transport
156164
bool AlphaKnockout; // whether pigment alpha knocks out finish effects
157165

166+
#if POV_EXPERIMENTAL_OREN_NAYAR
167+
158168
void SetOrenNayarSigma(double sigma)
159169
{
160170
SetOrenNayarSigmaSqr(sigma*sigma);
@@ -164,6 +174,8 @@ struct Finish_Struct
164174
OrenNayarA = 1.0 - 0.50 * sigmaSqr / (sigmaSqr + 0.57);
165175
OrenNayarB = 0.45 * sigmaSqr / (sigmaSqr + 0.09);
166176
}
177+
178+
#endif
167179
};
168180

169181

source/core/render/trace.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2444,9 +2444,17 @@ void Trace::ComputeDiffuseColour(const FINISH *finish, const Vector3d& lightDire
24442444
else
24452445
intensity = cos_in;
24462446

2447-
if (finish->Fresnel || (finish->LommelSeeligerWeight != 0.0) || (finish->OrenNayarB != 0.0))
2447+
bool needCosOut = finish->Fresnel;
2448+
#if POV_EXPERIMENTAL_LOMMEL_SEELIGER
2449+
needCosOut = needCosOut || (finish->LommelSeeligerWeight != 0.0);
2450+
#endif
2451+
#if POV_EXPERIMENTAL_OREN_NAYAR
2452+
needCosOut = needCosOut || (finish->OrenNayarB != 0.0);
2453+
#endif
2454+
if (needCosOut)
24482455
cos_out = fabs(dot(layer_normal, eyeDirection));
24492456

2457+
#if POV_EXPERIMENTAL_OREN_NAYAR
24502458
if (finish->OrenNayarA != 1.0)
24512459
intensity *= finish->OrenNayarA;
24522460
if (finish->OrenNayarB != 0.0)
@@ -2460,12 +2468,15 @@ void Trace::ComputeDiffuseColour(const FINISH *finish, const Vector3d& lightDire
24602468
double beta = min(theta_in, theta_out);
24612469
intensity += finish->OrenNayarB * cos_in * max(0.0,cos_phi) * sin(alpha) * tan(beta);
24622470
}
2471+
#endif
24632472

2473+
#if POV_EXPERIMENTAL_LOMMEL_SEELIGER
24642474
if (finish->LommelSeeligerWeight != 0.0)
24652475
{
24662476
intensity *= (1.0 - finish->LommelSeeligerWeight);
24672477
intensity += finish->LommelSeeligerWeight * cos_in / (cos_in + cos_out);
24682478
}
2479+
#endif
24692480

24702481
intensity *= diffuse * attenuation;
24712482

source/parser/parser.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,10 +341,14 @@ void Parser::Run()
341341

342342
if(mExperimentalFlags.backsideIllumination) featureList.push_back("backside illumination");
343343
if(mExperimentalFlags.functionHf) featureList.push_back("function '.hf'");
344+
#if POV_EXPERIMENTAL_LOMMEL_SEELIGER
344345
if(mExperimentalFlags.lommelSeeliger) featureList.push_back("Lommel-Seeliger diffuse model");
346+
#endif
345347
if(mExperimentalFlags.meshCamera) featureList.push_back("mesh camera");
346348
if(mExperimentalFlags.objImport) featureList.push_back("wavefront obj import");
349+
#if POV_EXPERIMENTAL_OREN_NAYAR
347350
if(mExperimentalFlags.orenNayar) featureList.push_back("Oren-Nayar diffuse model");
351+
#endif
348352
if(mExperimentalFlags.slopeAltitude) featureList.push_back("slope pattern altitude");
349353
if(mExperimentalFlags.spline) featureList.push_back("spline");
350354
if(mExperimentalFlags.subsurface) featureList.push_back("subsurface light transport");

source/parser/parser.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,14 @@ struct ExperimentalFlags
157157
{
158158
bool backsideIllumination : 1;
159159
bool functionHf : 1;
160+
#if POV_EXPERIMENTAL_LOMMEL_SEELIGER
160161
bool lommelSeeliger : 1;
162+
#endif
161163
bool meshCamera : 1;
162164
bool objImport : 1;
165+
#if POV_EXPERIMENTAL_OREN_NAYAR
163166
bool orenNayar : 1;
167+
#endif
164168
bool slopeAltitude : 1;
165169
bool spline : 1;
166170
bool subsurface : 1;
@@ -170,10 +174,14 @@ struct ExperimentalFlags
170174
ExperimentalFlags() :
171175
backsideIllumination(false),
172176
functionHf(false),
177+
#if POV_EXPERIMENTAL_LOMMEL_SEELIGER
173178
lommelSeeliger(false),
179+
#endif
174180
meshCamera(false),
175181
objImport(false),
182+
#if POV_EXPERIMENTAL_OREN_NAYAR
176183
orenNayar(false),
184+
#endif
177185
slopeAltitude(false),
178186
spline(false),
179187
subsurface(false),

source/parser/parser_materials.cpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2313,17 +2313,21 @@ void Parser::Parse_Finish (FINISH **Finish_Ptr)
23132313
mExperimentalFlags.backsideIllumination = true;
23142314
END_CASE
23152315

2316+
#if POV_EXPERIMENTAL_LOMMEL_SEELIGER
23162317
CASE (LOMMEL_SEELIGER_TOKEN)
23172318
New->LommelSeeligerWeight = Parse_Float ();
23182319
mExperimentalFlags.lommelSeeliger = true;
23192320
END_CASE
2321+
#endif
23202322

2323+
#if POV_EXPERIMENTAL_OREN_NAYAR
23212324
CASE (OREN_NAYAR_TOKEN)
23222325
New->SetOrenNayarSigma(Parse_Float ());
23232326
mExperimentalFlags.orenNayar = true;
23242327
PossibleError("Parameterization of the Oren-Nayar diffuse model has not been finalized yet."
23252328
" Expect future versions of POV-Ray to render this scene differently without warning.");
23262329
END_CASE
2330+
#endif
23272331

23282332
CASE (REFLECTION_TOKEN)
23292333
{
@@ -2542,21 +2546,25 @@ void Parser::Parse_Finish (FINISH **Finish_Ptr)
25422546
END_EXPECT /* End of finish_mods */
25432547
#endif
25442548

2545-
if ((New->OrenNayarA != 1.0) || (New->OrenNayarB != 0.0))
2549+
#if POV_EXPERIMENTAL_LOMMEL_SEELIGER
2550+
if (New->LommelSeeligerWeight != 0.0)
25462551
{
25472552
if (New->Fresnel)
2548-
PossibleError("Finish-level 'fresnel' keyword found in combination with the Oren-Nayar diffuse model."
2553+
PossibleError("Finish-level 'fresnel' keyword found in combination with the Lommel-Seeliger diffuse model."
25492554
" The interaction of these features has not been finalized yet, and is known to be bogus."
25502555
" Expect future versions of POV-Ray to render this scene differently without warning.");
25512556
}
2557+
#endif
25522558

2553-
if (New->LommelSeeligerWeight != 0.0)
2559+
#if POV_EXPERIMENTAL_OREN_NAYAR
2560+
if ((New->OrenNayarA != 1.0) || (New->OrenNayarB != 0.0))
25542561
{
25552562
if (New->Fresnel)
2556-
PossibleError("Finish-level 'fresnel' keyword found in combination with the Lommel-Seeliger diffuse model."
2563+
PossibleError("Finish-level 'fresnel' keyword found in combination with the Oren-Nayar diffuse model."
25572564
" The interaction of these features has not been finalized yet, and is known to be bogus."
25582565
" Expect future versions of POV-Ray to render this scene differently without warning.");
25592566
}
2567+
#endif
25602568

25612569
if ((sceneData->EffectiveLanguageVersion() >= 370) && ambientSet)
25622570
{
@@ -2584,15 +2592,19 @@ void Parser::Parse_Finish (FINISH **Finish_Ptr)
25842592
// so that a user-specified value of 1.0 corresponds to a
25852593
// backscattering of 100% of the incoming light
25862594
double EffectiveBihemisphericalReflectance = 2.0 / (New->Brilliance + 1.0);
2595+
#if POV_EXPERIMENTAL_OREN_NAYAR
25872596
if (New->OrenNayarA != 1.0)
25882597
EffectiveBihemisphericalReflectance *= New->OrenNayarA;
25892598
if (New->OrenNayarB != 0.0)
25902599
EffectiveBihemisphericalReflectance += New->OrenNayarB * (2.0/3.0 - (64.0/45.0)*(1.0/M_PI));
2600+
#endif
2601+
#if POV_EXPERIMENTAL_LOMMEL_SEELIGER
25912602
if (New->LommelSeeligerWeight != 0.0)
25922603
{
25932604
EffectiveBihemisphericalReflectance *= (1.0 - New->LommelSeeligerWeight);
25942605
EffectiveBihemisphericalReflectance += New->LommelSeeligerWeight * ((8.0 * (1.0-log(2.0))) / 3.0);
25952606
}
2607+
#endif
25962608
if (diffuseAdjust)
25972609
{
25982610
New->DiffuseAlbedoAdjust = 1.0 / EffectiveBihemisphericalReflectance;

source/parser/reservedwords.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,9 @@ const RESERVED_WORD Reserved_Words[] = {
307307
{ LOCAL_TOKEN, "local" },
308308
{ LOCATION_TOKEN, "location" },
309309
{ LOG_TOKEN, "log" },
310+
#if POV_EXPERIMENTAL_LOMMEL_SEELIGER
310311
{ LOMMEL_SEELIGER_TOKEN, "lommel_seeliger "},
312+
#endif
311313
{ LOOK_AT_TOKEN, "look_at" },
312314
{ LOOKS_LIKE_TOKEN, "looks_like" },
313315
{ LOW_ERROR_FACTOR_TOKEN, "low_error_factor" },
@@ -380,7 +382,9 @@ const RESERVED_WORD Reserved_Words[] = {
380382
{ ONION_TOKEN, "onion" },
381383
{ OPEN_TOKEN, "open" },
382384
{ OPTIONAL_TOKEN, "optional" },
385+
#if POV_EXPERIMENTAL_OREN_NAYAR
383386
{ OREN_NAYAR_TOKEN, "oren_nayar "},
387+
#endif
384388
{ ORIENT_TOKEN, "orient" },
385389
{ ORIENTATION_TOKEN, "orientation" },
386390
{ ORTHOGRAPHIC_TOKEN, "orthographic" },

source/parser/reservedwords.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,9 @@ enum TokenId : int
457457
LOAD_FILE_TOKEN,
458458
LOCAL_TOKEN,
459459
LOCATION_TOKEN,
460+
#if POV_EXPERIMENTAL_LOMMEL_SEELIGER
460461
LOMMEL_SEELIGER_TOKEN,
462+
#endif
461463
LOOK_AT_TOKEN,
462464
LOOKS_LIKE_TOKEN,
463465
LOW_ERROR_FACTOR_TOKEN,
@@ -527,7 +529,9 @@ enum TokenId : int
527529
ONION_TOKEN,
528530
OPEN_TOKEN,
529531
OPTIONAL_TOKEN,
532+
#if POV_EXPERIMENTAL_OREN_NAYAR
530533
OREN_NAYAR_TOKEN,
534+
#endif
531535
ORIENT_TOKEN,
532536
ORIENTATION_TOKEN,
533537
ORTHOGRAPHIC_TOKEN,

0 commit comments

Comments
 (0)