-
Hello, I created a simple toy project to demonstrate the issue. The scene contains two quads, each with a different texture. One of the quads is slightly offset toward the camera. In the final render, the front quad uses a Mask BSDF to control its alpha. When extracting the albedo using the aov integrator, I only get the texture from the front-most quad, regardless of its transparency. However, I would like to pass the albedo of the quad behind to Optix for denoising (not included in the toy project). Question Additional info
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hi @vinlo I don't think there's a way to do this out-of-the box. But it's a fairly simple change in |
Beta Was this translation helpful? Give feedback.
-
@njroussel thanks for the answer! I followed your suggestion and used
With both approaches, after compiling and running the toy project (with a small tweak so the front quad doesn’t fully cover the one behind), the albedo pass only shows the front quad’s texture, which is the opposite of what I was aiming for. I'm still fairly new to the codebase and the concepts involved—could you confirm if I'm on the right track with the code below? // modifying aov.cpp / std::pair<Spectrum, Mask> sample(...) function
std::pair<Spectrum, Mask> result{ 0.f, false };
// SurfaceInteraction3f si = scene->ray_intersect(ray, (uint32_t)cur_ray RayFlags::All, true, active);
// dr::masked(si, !si.is_valid()) = dr::zeros<SurfaceInteraction3f>();
RayDifferential3f cur_ray = ray;
SurfaceInteraction3f si;
BSDFPtr m_bsdf;
for (int iter = 0; iter < 5; ++iter) {
si = scene->ray_intersect(cur_ray, (uint32_t) RayFlags::All, true, active);
dr::masked(si, !si.is_valid()) = dr::zeros<SurfaceInteraction3f>();
m_bsdf = si.bsdf(cur_ray);
// 1st method
Mask is_transparent = has_flag(m_bsdf->flags(), BSDFFlags::Null);
if (dr::any(is_transparent)) {
cur_ray = si.spawn_ray(cur_ray.d);
cur_ray.wavelengths = ray.wavelengths;
cur_ray.time = ray.time;
continue;
}
// 2nd method
// std::string attr = "opacity";
// if (dr::any(m_bsdf->has_attribute(attr)) ) {
// cur_ray = si.spawn_ray(cur_ray.d);
// cur_ray.wavelengths = ray.wavelengths;
// cur_ray.time = ray.time;
// continue;
// }
break;
}
// m_bsdf and the cur_ray variables are then used in the `switch` case
// where the RGB values for the albedo are written. |
Beta Was this translation helpful? Give feedback.
Following up on the discussion, in case it’s useful to someone, the final piece of code I ended up with doesn’t fully answer the original question, but it goes a step further for my specific use case. It handles transparency by accumulating the albedo color at each intersection.