Skip to content

Commit

Permalink
Add a functional background reflect
Browse files Browse the repository at this point in the history
  • Loading branch information
gkjohnson committed Nov 25, 2022
1 parent 1bb778b commit 66f50ec
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/materials/PhysicalPathTracingMaterial.js
Original file line number Diff line number Diff line change
Expand Up @@ -481,10 +481,10 @@ export class PhysicalPathTracingMaterial extends MaterialBase {
if ( ! hit ) {
if ( i == 0 || transmissiveRay ) {
if ( i == 0 || transmissiveRay || i == 1 && ! isShadowRay ) {
gl_FragColor.rgb += sampleBackground( environmentRotation * rayDirection ) * throughputColor;
gl_FragColor.a = backgroundAlpha;
gl_FragColor.a = i == 1 && ! isShadowRay ? 1.0 : backgroundAlpha;
} else {
Expand Down Expand Up @@ -877,6 +877,14 @@ export class PhysicalPathTracingMaterial extends MaterialBase {
float envPdf = randomEnvMapSample( envMapInfo, envColor, envDirection );
envDirection = invEnvironmentRotation * envDirection;
// TODO: This shadow ray needs to be determined by whether the _new_ evn-sampled direction is a shadow ray
// not the last randomly sampled ray direction
if ( i <= 1 && ! isShadowRay ) {
envColor = sampleBackground( envDirection );
}
// this env sampling is not set up for transmissive sampling and yields overly bright
// results so we ignore the sample in this case.
// TODO: this should be improved but how? The env samples could traverse a few layers?
Expand Down

0 comments on commit 66f50ec

Please sign in to comment.