Skip to content

Commit 5bc48a3

Browse files
committed
Matt's snippet
1 parent 972ce0e commit 5bc48a3

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

include/irr/builtin/material_compiler/glsl/common.glsl

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -688,18 +688,25 @@ void instr_eval_and_pdf_execute(in instr_t instr, in MC_precomputed_t precomp, i
688688
}
689689
#endif
690690

691-
eval = vec3(eval_scalar_part);
692-
#ifdef OP_CONDUCTOR
693-
if (op == OP_CONDUCTOR)
694-
eval *= fr;
695-
else
696-
#endif
691+
#ifndef NO_BSDF
692+
if (is_bsdf)
697693
{
694+
float LdotH = microfacet.isotropic.LdotH;
695+
float VdotHLdotH = microfacet.isotropic.VdotH * LdotH;
696+
LdotH = abs(LdotH);
697+
#ifdef NDF_GGX
698+
if (ndf == NDF_GGX)
699+
eval_scalar_part = irr_glsl_ggx_microfacet_to_light_measure_transform(eval_scalar_part, NdotL, refraction, VdotH, LdotH, VdotHLdotH, eta);
700+
else
701+
#endif
702+
eval_scalar_part = irr_glsl_microfacet_to_light_measure_transform(eval_scalar_part, NdotV, refraction, VdotH, LdotH, VdotHLdotH, eta);
703+
698704
float reflectance = colorToScalar(fr);
699705
reflectance = refraction ? (1.0 - reflectance) : reflectance;
700706
pdf *= reflectance;
701-
eval *= reflectance;
702707
}
708+
#endif
709+
eval = fr * eval_scalar_part;
703710
} else
704711
#endif
705712
{}

0 commit comments

Comments
 (0)