Skip to content

Commit

Permalink
Improve occlusion for light
Browse files Browse the repository at this point in the history
  • Loading branch information
iaomw committed Jan 5, 2024
1 parent f3011ba commit d8f3adf
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions zenovis/xinxinoptix/Light.cu
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,11 @@ extern "C" __global__ void __anyhit__shadow_cutout()
light_index = rect_idx + params.firstRectLightIdx;
}

if (light_index == prd->lightIdx) {
//printf("maxDistance = %f tmax = %f \n", prd->maxDistance, optixGetRayTmax());
ignore = true;
}

if (ignore) {
optixIgnoreIntersection();
return;
Expand Down
6 changes: 6 additions & 0 deletions zenovis/xinxinoptix/Light.h
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,10 @@ void DirectLighting(RadiancePRD *prd, ShadowPRD& shadowPRD, const float3& shadin
}
}

lsr.p -= params.cam.eye;
//lsr.p = rtgems::offset_ray(lsr.p, lsr.n);
lsr.dist = length(lsr.p - shadowPRD.origin);

if (!cihouMaxDistanceContinue(lsr, light)) { return; }

float3 emission = cihouLightEmission(lsr, light, prd->depth);
Expand All @@ -402,7 +406,9 @@ void DirectLighting(RadiancePRD *prd, ShadowPRD& shadowPRD, const float3& shadin

if (lsr.NoL > _FLT_EPL_ && lsr.PDF > _FLT_EPL_) {

shadowPRD.lightIdx = lighIdx;
shadowPRD.maxDistance = lsr.dist;

traceOcclusion(params.handle, shadowPRD.origin, lsr.dir, 0, lsr.dist, &shadowPRD);
light_attenuation = shadowPRD.attanuation;

Expand Down
2 changes: 2 additions & 0 deletions zenovis/xinxinoptix/TraceStuff.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ struct VolumePRD {
struct ShadowPRD {
bool test_distance;
float maxDistance;
uint32_t lightIdx = UINT_MAX;

float3 origin;
uint32_t seed;
float3 attanuation;
Expand Down

0 comments on commit d8f3adf

Please sign in to comment.