@@ -7,11 +7,10 @@ void instr_eval_execute(in instr_t instr, in MC_precomputed_t precomp, inout irr
7
7
{
8
8
const uint op = instr_getOpcode(instr);
9
9
const bool is_bxdf = op_isBXDF(op);
10
- const bool is_bsdf = ! op_isBRDF(op); // note it actually tells if op is BSDF or BUMPMAP or SET_GEOM_NORMAL (divergence reasons )
10
+ const bool is_bsdf = ! op_isBRDF(op); // note: true for everything besides BRDF ops (combiners, SET_GEOM_NORMAL and BUMPMAP too )
11
11
const float cosFactor = irr_glsl_conditionalAbsOrMax(is_bsdf, s.NdotL, 0.0 );
12
12
const float NdotV = irr_glsl_conditionalAbsOrMax(is_bsdf, currInteraction.inner.isotropic.NdotV, 0.0 );
13
- bool is_valid = (NdotV > FLT_MIN);
14
- const bool positiveCosFactor = cosFactor > FLT_MIN && is_valid;
13
+ const bool positiveCosFactors = (cosFactor > FLT_MIN) && (NdotV > FLT_MIN);
15
14
const bool is_bxdf_or_combiner = op_isBXDForCoatOrBlend(op);
16
15
17
16
uvec3 regs = instr_decodeRegisters(instr);
@@ -21,7 +20,7 @@ void instr_eval_execute(in instr_t instr, in MC_precomputed_t precomp, inout irr
21
20
MC_microfacet_t microfacet;
22
21
bsdf_data_t bsdf_data;
23
22
24
- const bool run = ! skip && positiveCosFactor ;
23
+ const bool run = ! skip && positiveCosFactors ;
25
24
26
25
if (run && is_bxdf_or_combiner)
27
26
{
@@ -39,6 +38,7 @@ void instr_eval_execute(in instr_t instr, in MC_precomputed_t precomp, inout irr
39
38
const float rcp_eta = 1.0 / eta;
40
39
41
40
bool refraction = false;
41
+ bool is_valid = true;
42
42
#ifdef OP_DIELECTRIC
43
43
if (op == OP_DIELECTRIC && irr_glsl_isTransmissionPath(currInteraction.inner.isotropic.NdotV, s.NdotL))
44
44
{
@@ -54,12 +54,12 @@ void instr_eval_execute(in instr_t instr, in MC_precomputed_t precomp, inout irr
54
54
55
55
const vec3 albedo = params_getReflectance(params);
56
56
const float a = params_getAlpha(params);
57
- const float a2 = a * a;
57
+ const float a2 = a* a;
58
58
59
59
#if defined(OP_DIFFUSE) || defined(OP_DIFFTRANS)
60
60
if (op_isDiffuse(op))
61
61
{
62
- result = albedo * irr_glsl_oren_nayar_cos_eval(s, currInteraction.inner.isotropic, a2 );
62
+ result = albedo * (is_bsdf ? 0.5 : 1.0 ) * irr_glsl_oren_nayar_cos_eval_wo_clamps(a2, s.VdotL, cosFactor, NdotV );
63
63
}
64
64
else
65
65
#endif
0 commit comments