Skip to content

Commit 66f50ec

Browse files
committed
Add a functional background reflect
1 parent 1bb778b commit 66f50ec

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/materials/PhysicalPathTracingMaterial.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,10 +481,10 @@ export class PhysicalPathTracingMaterial extends MaterialBase {
481481
482482
if ( ! hit ) {
483483
484-
if ( i == 0 || transmissiveRay ) {
484+
if ( i == 0 || transmissiveRay || i == 1 && ! isShadowRay ) {
485485
486486
gl_FragColor.rgb += sampleBackground( environmentRotation * rayDirection ) * throughputColor;
487-
gl_FragColor.a = backgroundAlpha;
487+
gl_FragColor.a = i == 1 && ! isShadowRay ? 1.0 : backgroundAlpha;
488488
489489
} else {
490490
@@ -877,6 +877,14 @@ export class PhysicalPathTracingMaterial extends MaterialBase {
877877
float envPdf = randomEnvMapSample( envMapInfo, envColor, envDirection );
878878
envDirection = invEnvironmentRotation * envDirection;
879879
880+
// TODO: This shadow ray needs to be determined by whether the _new_ evn-sampled direction is a shadow ray
881+
// not the last randomly sampled ray direction
882+
if ( i <= 1 && ! isShadowRay ) {
883+
884+
envColor = sampleBackground( envDirection );
885+
886+
}
887+
880888
// this env sampling is not set up for transmissive sampling and yields overly bright
881889
// results so we ignore the sample in this case.
882890
// TODO: this should be improved but how? The env samples could traverse a few layers?

0 commit comments

Comments
 (0)