Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserve shadow test origin in camera space #1676

Merged
merged 1 commit into from
Dec 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions zenovis/xinxinoptix/DeflMatShader.cu
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -868,15 +864,19 @@ 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 = {};
float3* dummy_prt = nullptr;
if (mats.shadowReceiver > 0.5f) {
dummy_prt = &radianceNoShadow;
}
auto SP = shadingP + params.cam.eye;
DirectLighting<true>(prd, shadow_prd, SP, ray_dir, evalBxDF, &taskAux, dummy_prt);

DirectLighting<true>(prd, shadow_prd, shadingP, ray_dir, evalBxDF, &taskAux, dummy_prt);
if(mats.shadowReceiver > 0.5f)
{
auto radiance = length(prd->radiance);
Expand Down
5 changes: 2 additions & 3 deletions zenovis/xinxinoptix/Light.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -453,15 +453,14 @@ 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__) {
return;
}
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);
Expand Down
4 changes: 2 additions & 2 deletions zenovis/xinxinoptix/volume.cu
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down
Loading