Skip to content

Commit

Permalink
Fixed a bug causing fireflies when using light tracing for caustics i…
Browse files Browse the repository at this point in the history
…n some case (#329)
  • Loading branch information
Dade916 committed May 5, 2020
1 parent 8031aac commit 40dadc2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
9 changes: 6 additions & 3 deletions include/slg/utils/pathinfo_funcs.cl
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,10 @@ OPENCL_FORCE_INLINE void EyePathInfo_AddVertex(__global EyePathInfo *pathInfo,
// EyePathInfo::AddVertex()
//--------------------------------------------------------------------------

// Update isNearlyCaustic
pathInfo->isNearlyCaustic = (pathInfo->depth.depth == 0) ?
// Update
//
// Note: depth.depth has been already incremented by 1 with the depth.IncDepths(event);
pathInfo->isNearlyCaustic = (pathInfo->depth.depth == 1) ?
// First vertex must a nearly diffuse
(!isNewVertexNearlySpecular) :
// All other vertices must be nearly specular
Expand All @@ -108,6 +110,7 @@ OPENCL_FORCE_INLINE void EyePathInfo_AddVertex(__global EyePathInfo *pathInfo,

OPENCL_FORCE_INLINE bool EyePathInfo_IsCausticPath(__global EyePathInfo *pathInfo,
const BSDFEvent event, const float glossiness, const float glossinessThreshold) {
return pathInfo->isNearlyCaustic && (pathInfo->depth.depth > 1) &&
// Note: the +1 is there for the event passed as method arguments
return pathInfo->isNearlyCaustic && (pathInfo->depth.depth + 1 > 1) &&
EyePathInfo_IsNearlySpecular(pathInfo, event, glossiness, glossinessThreshold);
}
1 change: 1 addition & 0 deletions release-notes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
* Fixed a problem in automatic cache radius estimation of PhotonGI when using Orthographic camera (issue #324)
* Fixed an OpenCL compilation error when using large number of objects on some old GPUs
* Fixed a problem with BlendLuxCore when parsing more than 9 image pipelines (#336)
* Fixed a bug causing fireflies when using light tracing for caustics in some case (#329)

Note: due to Glossycoating updated support for bump mapping on GPUs, some old scene using this kind of material/bump map combination may require some fix.

Expand Down
4 changes: 2 additions & 2 deletions scenes/causticcube/render.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
film.width = 1000
film.height = 600
##
path.hybridbackforward.enable = 0
path.hybridbackforward.enable = 1
path.hybridbackforward.partition = 0.0
##batch.haltspp = 0
#batch.haltthreshold = 0.0001
Expand Down Expand Up @@ -65,7 +65,7 @@ path.photongi.indirect.lookup.radius = 0.15000000596046448
path.photongi.indirect.maxsize = 100000
path.photongi.indirect.usagethresholdscale = 4
#
path.photongi.caustic.enabled = 1
path.photongi.caustic.enabled = 0
#path.photongi.caustic.lookup.maxcount = 8192
#path.photongi.caustic.lookup.normalangle = 9.9999997090929202
path.photongi.caustic.lookup.radius = 0.04
Expand Down
7 changes: 5 additions & 2 deletions src/slg/utils/pathinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ void EyePathInfo::AddVertex(const BSDF &bsdf,
//--------------------------------------------------------------------------

// Update isNearlyCaustic
isNearlyCaustic = (depth.depth == 0) ?
//
// Note: depth.depth has been already incremented by 1 with the depth.IncDepths(event);
isNearlyCaustic = (depth.depth == 1) ?
// First vertex must a nearly diffuse
(!isNewVertexNearlySpecular) :
// All other vertices must be nearly specular
Expand All @@ -103,7 +105,8 @@ void EyePathInfo::AddVertex(const BSDF &bsdf,

bool EyePathInfo::IsCausticPath(const BSDFEvent event,
const float glossiness, const float glossinessThreshold) const {
return isNearlyCaustic && (depth.depth > 1) &&
// Note: the +1 is there for the event passed as method arguments
return isNearlyCaustic && (depth.depth + 1 > 1) &&
IsNearlySpecular(event, glossiness, glossinessThreshold);
}

Expand Down

0 comments on commit 40dadc2

Please sign in to comment.