Address path tracer merge leftover comments#991
Conversation
…mek's remove_core_matrix branch, added create from mat3x3
…c cast to/from truncated quat
|
|
include/nbl/builtin/hlsl/sampling/projected_spherical_triangle.hlsl
Outdated
Show resolved
Hide resolved
include/nbl/builtin/hlsl/sampling/projected_spherical_triangle.hlsl
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
most parameters should be members #966 (comment)
There was a problem hiding this comment.
Also #966 (comment)
There was a problem hiding this comment.
for next sampling PR, to rework in line with concepts of #1001
| return retval; | ||
| } | ||
|
|
||
| vector4_type computeBilinearPatch(const vector3_type receiverNormal, bool isBSDF) |
There was a problem hiding this comment.
why is this returning vector4_type instead of sampling::bilinear
There was a problem hiding this comment.
ok sampling PR
| static ProjectedSphericalTriangle<T> create(NBL_CONST_REF_ARG(shapes::SphericalTriangle<T>) tri) | ||
| { | ||
| ProjectedSphericalTriangle<T> retval; | ||
| retval.tri = tri; | ||
| return retval; | ||
| } |
There was a problem hiding this comment.
remove, see #966 (comment)
There was a problem hiding this comment.
ok sampling PR
| 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); |
There was a problem hiding this comment.
should be precomputed and stored as members #966 (comment)
There was a problem hiding this comment.
ok sampling PR
There was a problem hiding this comment.
again function with bazillion parameters that are really local members
There was a problem hiding this comment.
ok sampling PR
|
|
||
| scalar_type bxdfPdfThreshold; | ||
| scalar_type lumaContributionThreshold; // OETF smallest perceptible value | ||
| measure_type spectralTypeToLumaCoeffs; |
There was a problem hiding this comment.
measure_type is NOT the same thing as spectral_type I'll want to return normals, albedo and other things from the measure
There was a problem hiding this comment.
@keptsecret still a TODO
| scalar_type rcpChoiceProb; | ||
| sampling::PartitionRandVariable<scalar_type> partitionRandVariable; | ||
| partitionRandVariable.leftProb = neeProbability; | ||
| assert(neeProbability >= 0.0 && neeProbability <= 1.0) |
There was a problem hiding this comment.
missing ; at EOL
There was a problem hiding this comment.
@keptsecret you still have a missing semicolon after the asseert
| // We don't allow non watertight transmitters in this renderer | ||
| // but if we allowed non-watertight transmitters (single water surface), it would make sense just to apply this line by itself | ||
| const scalar_type monochromeEta = materialSystem.setMonochromeEta(matID, throughputCIE_Y); | ||
| bxdf::fresnel::OrientedEtas<monochrome_type> orientedEta = bxdf::fresnel::OrientedEtas<monochrome_type>::create(interaction.getNdotV(), hlsl::promote<monochrome_type>(monochromeEta)); | ||
| anisocache_type _cache = anisocache_type::template create<anisotropic_interaction_type, sample_type>(interaction, nee_sample, orientedEta); | ||
|
|
||
| if (neeContrib.pdf > scalar_type(0.0)) | ||
| { | ||
| // example only uses isotropic bxdfs | ||
| quotient_pdf_type bsdf_quotient_pdf = materialSystem.quotient_and_pdf(matID, nee_sample, interaction.isotropic, _cache.iso_cache); |
There was a problem hiding this comment.
this whole clump of code is super weird, it wont generalize to multi-layer materials, etc.
the cache shouldn't be exposed here at all (your material system in userspace could keep a cache around as a hidden variable)
The cache only applies to cook torrance materials and those are a high specialization.
You're abusing a quotient_and_pdf to just give you the pdf of a light sample, you shouldf be using pdf and eval separately instead.
Our dirac delta BxDFs will return Quotient of 1 and PDF of INF always!
Simply because the quotient still has dirac deltas in it, and the pdf does too, if you're doing NEE, you're supposed to completely remove those from the lighting integral - otherwise if you accidentally hit a Dirac Delta lobe the MIS weight for NEE goes to 0 which means that any non-dirac (such as plastic material which has diffuse mixed by fresnel with specular) lobes won't get any NEE at all!
also this can cause your problems with MIS weights not liking the NEE PDF being high!
There was a problem hiding this comment.
There was a problem hiding this comment.
after leave comment that we'll need an eval_and_mis_weight https://discord.com/channels/593902898015109131/1400024201682747512/1400024205050908783
There was a problem hiding this comment.
There was a problem hiding this comment.
Ok you can let the material system define a cache_type but then its geenrate must initialize it and pass it to quotient_and_pdf
There was a problem hiding this comment.
@keptsecret next item on the agenda
| // 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; |
There was a problem hiding this comment.
pass full aniso interaction, let the material system deal with only using the isotropic part
Also your PDF is mismatched.
There was a problem hiding this comment.
@keptsecret still using the wrong PDF to pair with eval
…n interaction instead of just isBSDF
| 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) |
There was a problem hiding this comment.
not sure how an empty struct tests any better than a real default aniso interaction
There was a problem hiding this comment.
I didn't want to include the bxdf/common.hlsl in here.
But could change to surface_interaction::SIsotropic if that's better?
| ((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 |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
(well or possible, but you'd need to re-intersect the BLAS just for that)
There was a problem hiding this comment.
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*/); |
There was a problem hiding this comment.
huh? why 1.0 ?
| 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; |
There was a problem hiding this comment.
material system shall always take aniso interaction
| 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); |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
in essence this should be an unused variable and removed
| 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; | ||
| } |
There was a problem hiding this comment.
cool, now this needs to in the interaction
| if (bxdfPdf > bxdfPdfThreshold && getLuma(throughput) > lumaThroughputThreshold) | ||
| { | ||
| scalar_type otherTechniqueHeuristic = neeProbability / bxdfPdf; // numerically stable, don't touch | ||
| ray.setPayloadMISWeights(throughput, otherTechniqueHeuristic * otherTechniqueHeuristic); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
setInteraction maybe would be a better name ?
| int32_t PackedRcpLog2BaseAndLog2BaseRoot; | ||
| float32_t BrightSampleLumaBias; |
There was a problem hiding this comment.
why do ou have two members now !?
| 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); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
you don't need depth
…e internally to use iso
…rsected ray and gives intersection
Makes changes left from #966