Skip to content

Address path tracer merge leftover comments#991

Open
keptsecret wants to merge 81 commits intomasterfrom
path_tracer_leftover_cleanup
Open

Address path tracer merge leftover comments#991
keptsecret wants to merge 81 commits intomasterfrom
path_tracer_leftover_cleanup

Conversation

@keptsecret
Copy link
Contributor

Makes changes left from #966

@keptsecret
Copy link
Contributor Author

hlsl/matrix_utils/transformation_matrix_utils.hlsl removed because of https://github.com/Devsh-Graphics-Programming/Nabla/pull/966/files#r2618467323

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

most parameters should be members #966 (comment)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for next sampling PR, to rework in line with concepts of #1001

return retval;
}

vector4_type computeBilinearPatch(const vector3_type receiverNormal, bool isBSDF)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this returning vector4_type instead of sampling::bilinear

Copy link
Member

@devshgraphicsprogramming devshgraphicsprogramming Feb 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok sampling PR

Comment on lines 29 to 34
static ProjectedSphericalTriangle<T> create(NBL_CONST_REF_ARG(shapes::SphericalTriangle<T>) tri)
{
ProjectedSphericalTriangle<T> retval;
retval.tri = tri;
return retval;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove, see #966 (comment)

Copy link
Member

@devshgraphicsprogramming devshgraphicsprogramming Feb 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok sampling PR

Comment on lines +67 to +68
vector3_type cos_vertices, sin_vertices;
const scalar_type solidAngle = tri.solidAngleOfTriangle(cos_vertices, sin_vertices, cos_a, cos_c, csc_b, csc_c);
const scalar_type solidAngle = tri.solidAngle(cos_vertices, sin_vertices);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be precomputed and stored as members #966 (comment)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok sampling PR

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again function with bazillion parameters that are really local members

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok sampling PR

Comment on lines +119 to +122
// example only uses isotropic bxdfs
quotient_pdf_type bsdf_quotient_pdf = materialSystem.quotient_and_pdf(matID, nee_sample, interaction.isotropic, _cache.iso_cache);
neeContrib.quotient *= materialSystem.eval(matID, nee_sample, interaction.isotropic, _cache.iso_cache) * rcpChoiceProb;
const scalar_type otherGenOverLightAndChoice = bsdf_quotient_pdf.pdf * rcpChoiceProb / neeContrib.pdf;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pass full aniso interaction, let the material system deal with only using the isotropic part

Also your PDF is mismatched.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@keptsecret still using the wrong PDF to pair with eval

Comment on lines +35 to +45
namespace impl
{
struct DummyInteraction {};
}

#define NBL_CONCEPT_NAME Ray
#define NBL_CONCEPT_TPLT_PRM_KINDS (typename)
#define NBL_CONCEPT_TPLT_PRM_NAMES (T)
#define NBL_CONCEPT_PARAM_0 (ray, T)
#define NBL_CONCEPT_PARAM_1 (v, typename T::vector3_type)
#define NBL_CONCEPT_PARAM_2 (b, bool)
#define NBL_CONCEPT_PARAM_2 (interaction, impl::DummyInteraction)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure how an empty struct tests any better than a real default aniso interaction

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't want to include the bxdf/common.hlsl in here.
But could change to surface_interaction::SIsotropic if that's better?

Comment on lines +330 to +343
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((scene.getNormal(id, intersectP)), ::nbl::hlsl::is_same_v, typename T::vector3_type))
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((scene.template getInteraction<impl::DummyRay>(id, intersectP, ray)), ::nbl::hlsl::is_same_v, typename T::interaction_type))
);
#undef ray

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are you still adamant on the scene giving you an interaction and not the closestHit trace ray of the intersector !?

You do realize that in general thats not possible with a ray, intersection position and an object ID ?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(well or possible, but you'd need to re-intersect the BLAS just for that)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scene already does give a closest hit ray. This is for filling out the interaction member of the closest hit return struct.
Regardless, I've now made the scene handle all of creating the closest hit return struct.

vector3_type direction = bxdfSample;
ray.init(origin, direction);
ray.template initInteraction<anisotropic_interaction_type>(interaction);
ray.setT(1.0/*kSceneSize*/);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

huh? why 1.0 ?

Copy link
Contributor Author

@keptsecret keptsecret Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

t is used in the Tolerance::adjust function to control ray origin. It was also 1.0 in the glsl version but with the comment kSceneSize, I guess it should be that but not sure how to get it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed it

Comment on lines +124 to +125
quotient_pdf_type bsdf_quotient_pdf = materialSystem.quotient_and_pdf(matID, nee_sample, iso_interaction, _cache.iso_cache);
neeContrib.quotient *= materialSystem.eval(matID, nee_sample, iso_interaction, _cache.iso_cache) * rcpChoiceProb;
Copy link
Member

@devshgraphicsprogramming devshgraphicsprogramming Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

material system shall always take aniso interaction

Comment on lines +148 to +153
quotient_pdf_type bsdf_quotient_pdf = materialSystem.quotient_and_pdf(matID, bsdf_sample, interaction.isotropic, _cache.iso_cache);
quotient_pdf_type bsdf_quotient_pdf = materialSystem.quotient_and_pdf(matID, bsdf_sample, iso_interaction, _cache.iso_cache);
Copy link
Member

@devshgraphicsprogramming devshgraphicsprogramming Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

material system shall always take aniso interaction

{
anisotropic_interaction_type interaction = intersectData.getInteraction();
isotropic_interaction_type iso_interaction = interaction.isotropic;
isotropic_interaction_type iso_interaction = interaction.getIsotropic();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in essence this should be an unused variable and removed

Comment on lines +93 to +97
const vector3_type throughputCIE_Y = hlsl::normalize(spectralTypeToLumaCoeffs * throughput);
measure_type throughputCIE_Y = spectralTypeToLumaCoeffs * throughput;
{
scalar_type sum_throughput = throughputCIE_Y[0];
NBL_UNROLL for (uint16_t i = 1; i < vector_traits<measure_type>::Dimension; i++)
sum_throughput += throughputCIE_Y[i];
throughputCIE_Y /= sum_throughput;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool, now this needs to in the interaction

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this update your thoroughput in the payload as well?

Then rename the function to updateThroughputAndMISWeights

vector3_type direction = bxdfSample;
ray.initData(origin, direction, interaction.getN(), isBSDF);
ray.init(origin, direction);
ray.template initInteraction<anisotropic_interaction_type>(interaction);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setInteraction maybe would be a better name ?

Comment on lines +33 to +34
int32_t PackedRcpLog2BaseAndLog2BaseRoot;
float32_t BrightSampleLumaBias;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do ou have two members now !?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh? It was always 2 members. Both combined unpack to 4 vars for SSplattingParameters, but since we removed one then it's 1 packed and 1 as is.

nee_ray.init(origin, direction);
nee_ray.template initInteraction<anisotropic_interaction_type>(interaction);
nee_ray.setT(t);
tolerance_method_type::template adjust<ray_type>(nee_ray, direction, depth);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't the direction already in the ray ?

you need to give it the geometric normal (not the interaction which has the shading normal) if you want to know why read the PBRT book, but offsetting the origin by geo normal keeps your t modification small, while offsetting along the ray can be potentially unbounded with a surface-grazing ray if you want to not self-intersect

rayAlive = closestHitProgram(d, sampleIndex, ray, intersection);
continuePath = intersection.foundHit();
if (continuePath)
continuePath &= closestHitProgram(d, sampleIndex, ray, intersection);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't even need a &= just a = will do, you're in the if statement, so its already true

materialSystem, scene, intersectP, interaction,
isBSDF, eps0, depth
scene, materialSystem, intersectP, interaction,
eps0, depth

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't need depth

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

depth is used to adjust newRayMaxT inside the nee though?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants