提交 50acd8a5 编写于 作者: M Matt Pharr

Update from book source. No functional changes.

上级 f7028c27
......@@ -258,7 +258,7 @@ extern "C" __global__ void __raygen__shadow() {
Trace(params.traversable, sr.ray, 1e-5f /* tMin */, sr.tMax, OPTIX_RAY_FLAG_NONE,
missed);
RecordShadowRayIntersection(sr, &params.pixelSampleState, !missed);
RecordShadowRayResult(sr, &params.pixelSampleState, !missed);
}
extern "C" __global__ void __miss__shadow() {
......
......@@ -59,7 +59,7 @@ void CPUAggregate::IntersectShadow(int maxRays, ShadowRayQueue *shadowRayQueue,
ParallelFor(0, shadowRayQueue->Size(), [=](int index) {
const ShadowRayWorkItem w = (*shadowRayQueue)[index];
bool hit = aggregate.IntersectP(w.ray, w.tMax);
RecordShadowRayIntersection(w, pixelSampleState, hit);
RecordShadowRayResult(w, pixelSampleState, hit);
});
}
......
......@@ -630,7 +630,7 @@ void WavefrontPathIntegrator::HandleEmissiveIntersection() {
// Compute area light's weighted radiance contribution to the path
SampledSpectrum L(0.f);
if (w.depth == 0 || w.isSpecularBounce) {
if (w.depth == 0 || w.specularBounce) {
L = w.T_hat * Le / w.uniPathPDF.Average();
} else {
// Compute MIS-weighted radiance contribution from area light
......
......@@ -28,9 +28,9 @@ inline PBRT_CPU_GPU void EnqueueWorkAfterMiss(RayWorkItem r,
}
}
inline PBRT_CPU_GPU void RecordShadowRayIntersection(
const ShadowRayWorkItem w, SOA<PixelSampleState> *pixelSampleState,
bool foundIntersection) {
inline PBRT_CPU_GPU void RecordShadowRayResult(const ShadowRayWorkItem w,
SOA<PixelSampleState> *pixelSampleState,
bool foundIntersection) {
if (foundIntersection) {
PBRT_DBG("Shadow ray was occluded\n");
return;
......@@ -66,7 +66,7 @@ inline PBRT_CPU_GPU void EnqueueWorkAfterIntersection(
r.lightPathPDF,
r.pixelIndex,
r.prevIntrCtx,
r.isSpecularBounce,
r.specularBounce,
r.anyNonSpecularBounces,
r.etaScale,
intr.areaLight,
......@@ -103,7 +103,7 @@ inline PBRT_CPU_GPU void EnqueueWorkAfterIntersection(
Ray newRay = intr.SpawnRay(r.ray.d);
nextRayQueue->PushIndirectRay(newRay, r.depth, r.prevIntrCtx, r.T_hat,
r.uniPathPDF, r.lightPathPDF, r.lambda, r.etaScale,
r.isSpecularBounce, r.anyNonSpecularBounces,
r.specularBounce, r.anyNonSpecularBounces,
r.pixelIndex);
return;
}
......@@ -116,7 +116,7 @@ inline PBRT_CPU_GPU void EnqueueWorkAfterIntersection(
hitAreaLightQueue->Push(
HitAreaLightWorkItem{intr.areaLight, intr.p(), intr.n, intr.uv, intr.wo,
r.lambda, r.depth, r.T_hat, r.uniPathPDF, r.lightPathPDF,
r.prevIntrCtx, (int)r.isSpecularBounce, r.pixelIndex});
r.prevIntrCtx, (int)r.specularBounce, r.pixelIndex});
}
FloatTexture displacement = material.GetDisplacement();
......
......@@ -181,10 +181,9 @@ void WavefrontPathIntegrator::SampleMediumInteraction(int wavefrontDepth) {
if (escapedRayQueue) {
PBRT_DBG("Adding ray to escapedRayQueue pixel index %d depth %d\n",
w.pixelIndex, w.depth);
escapedRayQueue->Push(
EscapedRayWorkItem{ray.o, ray.d, w.depth, lambda, w.pixelIndex,
T_hat, (int)w.isSpecularBounce, uniPathPDF,
lightPathPDF, w.prevIntrCtx});
escapedRayQueue->Push(EscapedRayWorkItem{
ray.o, ray.d, w.depth, lambda, w.pixelIndex, T_hat,
(int)w.specularBounce, uniPathPDF, lightPathPDF, w.prevIntrCtx});
}
return;
}
......@@ -207,7 +206,7 @@ void WavefrontPathIntegrator::SampleMediumInteraction(int wavefrontDepth) {
Ray newRay = intr.SpawnRay(ray.d);
nextRayQueue->PushIndirectRay(newRay, w.depth, w.prevIntrCtx, T_hat,
uniPathPDF, lightPathPDF, lambda,
w.etaScale, w.isSpecularBounce,
w.etaScale, w.specularBounce,
w.anyNonSpecularBounces, w.pixelIndex);
return;
}
......@@ -217,10 +216,10 @@ void WavefrontPathIntegrator::SampleMediumInteraction(int wavefrontDepth) {
"Ray hit an area light: adding to hitAreaLightQueue pixel index %d "
"depth %d\n",
w.pixelIndex, w.depth);
hitAreaLightQueue->Push(HitAreaLightWorkItem{
w.areaLight, Point3f(w.pi), w.n, w.uv, -ray.d, lambda, w.depth, T_hat,
uniPathPDF, lightPathPDF, w.prevIntrCtx, w.isSpecularBounce,
w.pixelIndex});
hitAreaLightQueue->Push(
HitAreaLightWorkItem{w.areaLight, Point3f(w.pi), w.n, w.uv, -ray.d,
lambda, w.depth, T_hat, uniPathPDF, lightPathPDF,
w.prevIntrCtx, w.specularBounce, w.pixelIndex});
}
FloatTexture displacement = material.GetDisplacement();
......@@ -355,13 +354,13 @@ void WavefrontPathIntegrator::SampleMediumScattering(int wavefrontDepth) {
}
Ray ray(w.p, phaseSample->wi, w.time, w.medium);
bool isSpecularBounce = false;
bool specularBounce = false;
bool anyNonSpecularBounces = true;
// Spawn indirect ray.
nextRayQueue->PushIndirectRay(
ray, w.depth + 1, ctx, T_hat, uniPathPDF, lightPathPDF, w.lambda,
w.etaScale, isSpecularBounce, anyNonSpecularBounces, w.pixelIndex);
w.etaScale, specularBounce, anyNonSpecularBounces, w.pixelIndex);
PBRT_DBG("Enqueuing indirect medium ray at depth %d pixel index %d\n",
w.depth + 1, w.pixelIndex);
});
......
......@@ -71,15 +71,15 @@ template <typename ConcreteMaterial, typename TextureEvaluator>
void WavefrontPathIntegrator::EvaluateMaterialAndBSDF(MaterialEvalQueue *evalQueue,
int wavefrontDepth) {
// Get BSDF for items in _evalQueue_ and sample illumination
// Construct _name_ for material/texture evaluator kernel
std::string name = StringPrintf(
// Construct _desc_ for material/texture evaluation kernel
std::string desc = StringPrintf(
"%s + BxDF eval (%s tex)", ConcreteMaterial::Name(),
std::is_same_v<TextureEvaluator, BasicTextureEvaluator> ? "Basic" : "Universal");
RayQueue *nextRayQueue = NextRayQueue(wavefrontDepth);
auto queue = evalQueue->Get<MaterialEvalWorkItem<ConcreteMaterial>>();
ForAllQueued(
name.c_str(), queue, maxQueueSize,
desc.c_str(), queue, maxQueueSize,
PBRT_CPU_GPU_LAMBDA(const MaterialEvalWorkItem<ConcreteMaterial> w) {
// Evaluate material and BSDF for ray intersection
TextureEvaluator texEval;
......@@ -116,6 +116,7 @@ void WavefrontPathIntegrator::EvaluateMaterialAndBSDF(MaterialEvalQueue *evalQue
FloatTexture displacement = w.material->GetDisplacement();
const Image *normalMap = w.material->GetNormalMap();
if (displacement || normalMap) {
// Call _Bump()_ to find shading geometry
if (displacement)
DCHECK(texEval.CanEvaluate({displacement}, {}));
BumpEvalContext bctx = w.GetBumpEvalContext(dudx, dudy, dvdx, dvdy);
......
......@@ -139,7 +139,7 @@ struct RayWorkItem {
SampledSpectrum T_hat, uniPathPDF, lightPathPDF;
LightSampleContext prevIntrCtx;
Float etaScale;
int isSpecularBounce;
int specularBounce;
int anyNonSpecularBounces;
};
......@@ -169,7 +169,7 @@ struct HitAreaLightWorkItem {
int depth;
SampledSpectrum T_hat, uniPathPDF, lightPathPDF;
LightSampleContext prevIntrCtx;
int isSpecularBounce;
int specularBounce;
int pixelIndex;
};
......@@ -241,7 +241,7 @@ struct MediumSampleWorkItem {
SampledSpectrum lightPathPDF;
int pixelIndex;
LightSampleContext prevIntrCtx;
int isSpecularBounce;
int specularBounce;
int anyNonSpecularBounces;
Float etaScale;
......@@ -353,8 +353,7 @@ class RayQueue : public WorkQueue<RayWorkItem> {
const SampledSpectrum &T_hat, const SampledSpectrum &uniPathPDF,
const SampledSpectrum &lightPathPDF,
const SampledWavelengths &lambda, Float etaScale,
bool isSpecularBounce, bool anyNonSpecularBounces,
int pixelIndex);
bool specularBounce, bool anyNonSpecularBounces, int pixelIndex);
};
// RayQueue Inline Methods
......@@ -371,7 +370,7 @@ inline int RayQueue::PushCameraRay(const Ray &ray, const SampledWavelengths &lam
this->anyNonSpecularBounces[index] = false;
this->uniPathPDF[index] = SampledSpectrum(1.f);
this->lightPathPDF[index] = SampledSpectrum(1.f);
this->isSpecularBounce[index] = false;
this->specularBounce[index] = false;
return index;
}
......@@ -380,7 +379,7 @@ inline int RayQueue::PushIndirectRay(
const Ray &ray, int depth, const LightSampleContext &prevIntrCtx,
const SampledSpectrum &T_hat, const SampledSpectrum &uniPathPDF,
const SampledSpectrum &lightPathPDF, const SampledWavelengths &lambda, Float etaScale,
bool isSpecularBounce, bool anyNonSpecularBounces, int pixelIndex) {
bool specularBounce, bool anyNonSpecularBounces, int pixelIndex) {
int index = AllocateEntry();
DCHECK(!ray.HasNaN());
this->ray[index] = ray;
......@@ -392,7 +391,7 @@ inline int RayQueue::PushIndirectRay(
this->lightPathPDF[index] = lightPathPDF;
this->lambda[index] = lambda;
this->anyNonSpecularBounces[index] = anyNonSpecularBounces;
this->isSpecularBounce[index] = isSpecularBounce;
this->specularBounce[index] = specularBounce;
this->etaScale[index] = etaScale;
return index;
}
......@@ -414,7 +413,7 @@ class EscapedRayQueue : public WorkQueue<EscapedRayWorkItem> {
inline int EscapedRayQueue::Push(RayWorkItem r) {
return Push(EscapedRayWorkItem{r.ray.o, r.ray.d, r.depth, r.lambda, r.pixelIndex,
r.T_hat, (int)r.isSpecularBounce, r.uniPathPDF,
r.T_hat, (int)r.specularBounce, r.uniPathPDF,
r.lightPathPDF, r.prevIntrCtx});
}
......@@ -482,7 +481,7 @@ class MediumSampleQueue : public WorkQueue<MediumSampleWorkItem> {
PBRT_CPU_GPU
int Push(Ray ray, Float tMax, SampledWavelengths lambda, SampledSpectrum T_hat,
SampledSpectrum uniPathPDF, SampledSpectrum lightPathPDF, int pixelIndex,
LightSampleContext prevIntrCtx, int isSpecularBounce,
LightSampleContext prevIntrCtx, int specularBounce,
int anyNonSpecularBounces, Float etaScale) {
int index = AllocateEntry();
this->ray[index] = ray;
......@@ -493,7 +492,7 @@ class MediumSampleQueue : public WorkQueue<MediumSampleWorkItem> {
this->lightPathPDF[index] = lightPathPDF;
this->pixelIndex[index] = pixelIndex;
this->prevIntrCtx[index] = prevIntrCtx;
this->isSpecularBounce[index] = isSpecularBounce;
this->specularBounce[index] = specularBounce;
this->anyNonSpecularBounces[index] = anyNonSpecularBounces;
this->etaScale[index] = etaScale;
return index;
......@@ -502,7 +501,7 @@ class MediumSampleQueue : public WorkQueue<MediumSampleWorkItem> {
PBRT_CPU_GPU
int Push(RayWorkItem r, Float tMax) {
return Push(r.ray, tMax, r.lambda, r.T_hat, r.uniPathPDF, r.lightPathPDF,
r.pixelIndex, r.prevIntrCtx, r.isSpecularBounce,
r.pixelIndex, r.prevIntrCtx, r.specularBounce,
r.anyNonSpecularBounces, r.etaScale);
}
};
......
......@@ -45,7 +45,7 @@ soa RayWorkItem {
SampledSpectrum T_hat, uniPathPDF, lightPathPDF;
LightSampleContext prevIntrCtx;
Float etaScale;
int isSpecularBounce;
int specularBounce;
int anyNonSpecularBounces;
};
......@@ -70,7 +70,7 @@ soa HitAreaLightWorkItem {
Vector3f wo;
int depth;
LightSampleContext prevIntrCtx;
int isSpecularBounce;
int specularBounce;
int pixelIndex;
};
......@@ -131,7 +131,7 @@ soa MediumSampleWorkItem {
Vector3f wo;
Point2f uv;
LightSampleContext prevIntrCtx;
int isSpecularBounce;
int specularBounce;
Material material;
Normal3f ns;
Vector3f dpdus, dpdvs;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册