From b4ed8740810f20cf0612d615d9505468b2d2a4d1 Mon Sep 17 00:00:00 2001 From: iaomw Date: Wed, 15 Jan 2025 19:42:11 +0800 Subject: [PATCH] fix importance singularity --- zenovis/xinxinoptix/LightBounds.cpp | 5 ++++- zenovis/xinxinoptix/LightTree.h | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/zenovis/xinxinoptix/LightBounds.cpp b/zenovis/xinxinoptix/LightBounds.cpp index 018c99c74f..5c90944ad2 100644 --- a/zenovis/xinxinoptix/LightBounds.cpp +++ b/zenovis/xinxinoptix/LightBounds.cpp @@ -44,7 +44,10 @@ float LightBounds::importance(Vector3f p, Vector3f n) const { return 0; // Return final importance at reference point - float importance = phi * cosThetap / d2; + //float importance = phi * cosThetap / d2; + float r2 = 1.0f; float d = sqrtf(d2); + float importance = phi * cosThetap * 2.0f / ( d * sqrtf(d2 + r2) + d2 + r2 ); + DCHECK(importance >= -1e-3); // Account for $\cos\theta_\roman{i}$ in importance at surfaces if (n[0]!=0 && n[1]!=0 && n[2]!=0) { diff --git a/zenovis/xinxinoptix/LightTree.h b/zenovis/xinxinoptix/LightTree.h index e2f1dd7d9d..c2ce16ca7f 100644 --- a/zenovis/xinxinoptix/LightTree.h +++ b/zenovis/xinxinoptix/LightTree.h @@ -154,7 +154,10 @@ struct CompactLightBounds { return 0; // Return final importance at reference point - float importance = phi * cosThetap / d2; + //float importance = phi * cosThetap / d2; + float r2 = 1.0f; float d = sqrtf(d2); + float importance = phi * cosThetap * 2.0f / ( d * sqrtf(d2 + r2) + d2 + r2 ); + DCHECK(importance >= -1e-3f); if (n[0]!=0 && n[1]!=0 && n[2]!=0) {