diff --git a/zenovis/xinxinoptix/DeflMatShader.cu b/zenovis/xinxinoptix/DeflMatShader.cu index 6b92420590..0a4a475f3c 100644 --- a/zenovis/xinxinoptix/DeflMatShader.cu +++ b/zenovis/xinxinoptix/DeflMatShader.cu @@ -820,13 +820,9 @@ extern "C" __global__ void __closesthit__radiance() prd->attenuation *= reflectance; prd->depth++; - auto shadingP = rtgems::offset_ray(P, prd->geometryNormal); - prd->radiance = make_float3(0.0f,0.0f,0.0f); - if(prd->depth>=3) mats.roughness = clamp(mats.roughness, 0.5f,0.99f); - auto evalBxDF = [&](const float3& _wi_, const float3& _wo_, float& thisPDF) -> float3 { const auto& L = _wi_; // pre-normalized @@ -868,6 +864,10 @@ extern "C" __global__ void __closesthit__radiance() shadow_prd.shadowAttanuation = make_float3(1.0f, 1.0f, 1.0f); shadow_prd.nonThinTransHit = (mats.thin == false && mats.specTrans > 0) ? 1 : 0; + shadow_prd.origin = rtgems::offset_ray(P, prd->geometryNormal); // camera space + auto shadingP = rtgems::offset_ray(P + params.cam.eye, prd->geometryNormal); // world space + + prd->radiance = {}; prd->direction = normalize(wi); float3 radianceNoShadow = {}; @@ -875,8 +875,8 @@ extern "C" __global__ void __closesthit__radiance() if (mats.shadowReceiver > 0.5f) { dummy_prt = &radianceNoShadow; } - auto SP = shadingP + params.cam.eye; - DirectLighting(prd, shadow_prd, SP, ray_dir, evalBxDF, &taskAux, dummy_prt); + + DirectLighting(prd, shadow_prd, shadingP, ray_dir, evalBxDF, &taskAux, dummy_prt); if(mats.shadowReceiver > 0.5f) { auto radiance = length(prd->radiance); diff --git a/zenovis/xinxinoptix/Light.h b/zenovis/xinxinoptix/Light.h index 60a554f151..3cfa0f5d07 100644 --- a/zenovis/xinxinoptix/Light.h +++ b/zenovis/xinxinoptix/Light.h @@ -400,7 +400,7 @@ void DirectLighting(RadiancePRD *prd, RadiancePRD& shadow_prd, const float3& sha if (lsr.NoL > _FLT_EPL_ && lsr.PDF > _FLT_EPL_) { shadow_prd.depth = 0; - traceOcclusion(params.handle, shadingP - params.cam.eye, lsr.dir, 0, lsr.dist, &shadow_prd); + traceOcclusion(params.handle, shadow_prd.origin, lsr.dir, 0, lsr.dist, &shadow_prd); light_attenuation = shadow_prd.shadowAttanuation; if (nullptr==RadianceWithoutShadow && lengthSquared(light_attenuation) == 0.0f) return; @@ -453,7 +453,6 @@ void DirectLighting(RadiancePRD *prd, RadiancePRD& shadow_prd, const float3& sha .45, 15., 1.030725f * 0.3f, params.elapsedTime, tmpPdf)); if(tmpPdf <= 0.0f) { return; } - auto LP = shadingP; auto Ldir = sun_dir; if (envpdf < __FLT_DENORM_MIN__) { @@ -461,7 +460,7 @@ void DirectLighting(RadiancePRD *prd, RadiancePRD& shadow_prd, const float3& sha } shadow_prd.depth = 0; //LP = rtgems::offset_ray(LP, sun_dir); - traceOcclusion(params.handle, LP - params.cam.eye, sun_dir, + traceOcclusion(params.handle, shadow_prd.origin, sun_dir, 1e-5f, // tmin 1e16f, // tmax, &shadow_prd); diff --git a/zenovis/xinxinoptix/volume.cu b/zenovis/xinxinoptix/volume.cu index ef71a07f1d..2ddfece051 100644 --- a/zenovis/xinxinoptix/volume.cu +++ b/zenovis/xinxinoptix/volume.cu @@ -178,9 +178,9 @@ extern "C" __global__ void __closesthit__radiance_volume() RadiancePRD shadow_prd {}; shadow_prd.seed = prd->seed; - shadow_prd.nonThinTransHit = 0; + shadow_prd.origin = new_orig; //camera sapce shadow_prd.shadowAttanuation = vec3(1.0f); - + auto evalBxDF = [&](const float3& _wi_, const float3& _wo_, float& thisPDF) -> float3 { pbrt::HenyeyGreenstein hg { vol_out.anisotropy };