Conversation
…ate so can make lights static const array members
…(12 bitfield) with invalid id
| if (hlsl::isinf(pdf)) | ||
| { | ||
| retval.quotient_pdf = quotient_pdf_type::create(hlsl::promote<spectral_type>(0.0), 0.0); |
There was a problem hiding this comment.
@keptsecret you need a very good comment to justify this, because normally thats a point light
So write something about PDF being inf when SolidAngle is 0, so the quotient of finite area emission would be 0 due to division by int
also comment that the "PDF" getting returned is really a thing for a MIS weight
| ray_dir_info_t V; | ||
| V.setDirection(-ray.direction); | ||
| interaction_type interaction = interaction_type::create(V, N); | ||
| interaction.luminosityContributionHint = hlsl::normalize(colorspace::scRGBtoXYZ[1] * ray.getPayloadThroughput()); |
There was a problem hiding this comment.
this is a good default, just rmemeber that our Unidirectional PT will overwrite it anyway
| using spectral_t = vector<float, 3>; | ||
| using bxdfnode_type = BxDFNode<spectral_t>; | ||
|
|
||
| static const bxdfnode_type bxdfs[SceneBase::SCENE_BXDF_COUNT] = { | ||
| bxdfnode_type::create(MaterialType::DIFFUSE, false, float2(0,0), spectral_t(0.8,0.8,0.8)), | ||
| bxdfnode_type::create(MaterialType::DIFFUSE, false, float2(0,0), spectral_t(0.8,0.4,0.4)), | ||
| bxdfnode_type::create(MaterialType::DIFFUSE, false, float2(0,0), spectral_t(0.4,0.8,0.4)), | ||
| bxdfnode_type::create(MaterialType::CONDUCTOR, false, float2(0,0), spectral_t(1.02,1.02,1.3), spectral_t(1.0,1.0,2.0)), | ||
| bxdfnode_type::create(MaterialType::CONDUCTOR, false, float2(0,0), spectral_t(1.02,1.3,1.02), spectral_t(1.0,2.0,1.0)), | ||
| bxdfnode_type::create(MaterialType::CONDUCTOR, false, float2(0.15,0.15), spectral_t(1.02,1.3,1.02), spectral_t(1.0,2.0,1.0)), | ||
| bxdfnode_type::create(MaterialType::DIELECTRIC, false, float2(0.0625,0.0625), spectral_t(1,1,1), spectral_t(1.4,1.45,1.5)), | ||
| bxdfnode_type::create(MaterialType::IRIDESCENT_CONDUCTOR, false, 0.0, 505.0, spectral_t(1.39,1.39,1.39), spectral_t(1.2,1.2,1.2), spectral_t(0.5,0.5,0.5)), | ||
| bxdfnode_type::create(MaterialType::IRIDESCENT_DIELECTRIC, false, 0.0, 400.0, spectral_t(1.7,1.7,1.7), spectral_t(1.0,1.0,1.0), spectral_t(0,0,0)), | ||
| bxdfnode_type::create(MaterialType::EMISSIVE, LightEminence) | ||
| }; |
There was a problem hiding this comment.
erm, shouldn't the table of bxdfs be in the material system and not the scene ?
|
|
||
| NBL_CONSTEXPR_STATIC_INLINE uint32_t SCENE_SPHERE_COUNT = 10u; | ||
| NBL_CONSTEXPR_STATIC_INLINE uint32_t SCENE_LIGHT_COUNT = 1u; | ||
| NBL_CONSTEXPR_STATIC_INLINE uint32_t SCENE_BXDF_COUNT = 10u; |
There was a problem hiding this comment.
material system ?
There was a problem hiding this comment.
the BXDF count that is
| ray_dir_info_type L; | ||
| L.makeInvalid(); | ||
| return sample_type::create(L, hlsl::promote<vector3_type>(0.0)); | ||
| } | ||
| } | ||
|
|
||
| ray_dir_info_type L; | ||
| L.makeInvalid(); | ||
| return sample_type::create(L, hlsl::promote<vector3_type>(0.0)); |
There was a problem hiding this comment.
put a break in the switch, or remove the unreachable code after the switch
| return iridescentDielectricBxDF.generate(interaction, u, _cache); | ||
| } | ||
| break; |
There was a problem hiding this comment.
if you return from a case label, you don't need to break, Clang actually warns you about that in C++
| DiffuseBxDF diffuseBxDF; | ||
| ConductorBxDF conductorBxDF; | ||
| DielectricBxDF dielectricBxDF; | ||
| IridescentConductorBxDF iridescentConductorBxDF; | ||
| IridescentDielectricBxDF iridescentDielectricBxDF; |
There was a problem hiding this comment.
compiler and perf will hate you because these are live variables.
I think I have a solution for this
There was a problem hiding this comment.
see Devsh-Graphics-Programming/Nabla#991 (comment)
Basically make the "cache" more generic, and instead of it just being an aniso cache, also slap the BxDF in there so it doesn't need to be live state here.
Obviously this means some very light weight serialization to emulate a union
I wish we could have KHR_shader_untyped_pointers that work on any storage class, then unions would be easy
KhronosGroup/Vulkan-Docs#2684
…DF + add config for that, refactor stuff around ray and nee methods changes in concept
| } | ||
| else | ||
| { | ||
| retval.quotient_pdf = quotient_pdf_type::create(1.0, 0.0); |
There was a problem hiding this comment.
why when the sample is invalid or below the hemisphere are you returning 1 for the quotient?
| } | ||
|
|
||
| light_type lights[scene_type::SCENE_LIGHT_COUNT]; | ||
| uint32_t lightCount; |
There was a problem hiding this comment.
make it a constant, not a variable, will speed us up a lot
There was a problem hiding this comment.
basically remove it and use scene_type::SCENE_LIGHT_COUNT in its place
| if (hlsl::isinf(pdf)) | ||
| { | ||
| retval.quotient_pdf = quotient_pdf_type::create(hlsl::promote<spectral_type>(0.0), 0.0); | ||
| return retval; | ||
| } | ||
|
|
||
| if (retval.sample_.getNdotL() > numeric_limits<scalar_type>::min && retval.sample_.isValid()) | ||
| { |
There was a problem hiding this comment.
also you could join the failure cases if you write enough comments
if (pdf < Inf && NdotL > min && retval.sample_.isValid())normally you'd have to do conditionalMaxOrAbs(NdotL,0.0f,isBSDF) > min because BSDFs should receive light from the backside, and its only in this scene that they can't because the scene has watertight geometry everywhere
There was a problem hiding this comment.
P.S. do you even need to check if the sample is valid, I thought invalid samples produce NaN or 0
so I guess first check if the pdf is non-zero and finite (with comment about finiteness being due to area lights) and the NdotL (with a comment)
then create the sample and do the rest
@keptsecret after you merge
masteragain, you'll probably have the UI mess up and show changed from the merge commit, so close and reopen againTODO