Skip to content

Resampled Importance Sampling bxdfs#1027

Merged
devshgraphicsprogramming merged 39 commits intomasterfrom
ris_bxdfs
Apr 18, 2026
Merged

Resampled Importance Sampling bxdfs#1027
devshgraphicsprogramming merged 39 commits intomasterfrom
ris_bxdfs

Conversation

@devshgraphicsprogramming
Copy link
Copy Markdown
Member

Description

Testing

TODO list:

@devshgraphicsprogramming devshgraphicsprogramming changed the title Ris bxdfs Resampled Importance Sampling bxdfs Mar 20, 2026
Comment thread include/nbl/builtin/hlsl/bxdf/base/lambertian.hlsl Outdated
Comment thread include/nbl/builtin/hlsl/bxdf/common.hlsl Outdated
Comment thread include/nbl/builtin/hlsl/bxdf/common.hlsl Outdated
Comment thread tools/nsc/main.cpp
Comment on lines +155 to +205
if (!system || outputPath.empty())
return false;

const auto parent = outputPath.parent_path();
if (!parent.empty() && !system->isDirectory(parent))
{
if (!system->createDirectory(parent))
return false;
}

auto tempPath = outputPath;
tempPath += ".tmp";
system->deleteFile(tempPath);

smart_refctd_ptr<IFile> outputFile;
{
ISystem::future_t<smart_refctd_ptr<IFile>> future;
system->createFile(future, tempPath, IFileBase::ECF_WRITE);
if (!future.wait())
return false;

auto lock = future.acquire();
if (!lock)
return false;
lock.move_into(outputFile);
}
if (!outputFile)
return false;

if (!content.empty())
{
IFile::success_t success;
outputFile->write(success, content.data(), 0ull, content.size());
if (!success)
{
outputFile = nullptr;
system->deleteFile(tempPath);
return false;
}
}
outputFile = nullptr;

system->deleteFile(outputPath);
const auto moveError = system->moveFileOrDirectory(tempPath, outputPath);
if (moveError)
{
system->deleteFile(tempPath);
return false;
}

return true;
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@AnastaZIuk do you think you could add an option to createFile flags (or pack the path+ IFileBase flaggs into a strcut) to create all the directories needed on the way to the path ?

cold be useful

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ay

Comment thread include/nbl/builtin/hlsl/path_tracing/concepts.hlsl Outdated
Comment thread include/nbl/builtin/hlsl/path_tracing/concepts.hlsl Outdated
Comment thread include/nbl/builtin/hlsl/path_tracing/unidirectional.hlsl Outdated
Comment thread include/nbl/builtin/hlsl/bxdf/base/cook_torrance_base.hlsl Outdated
Comment thread include/nbl/builtin/hlsl/bxdf/base/cook_torrance_base.hlsl Outdated
Comment thread include/nbl/builtin/hlsl/bxdf/base/cook_torrance_base.hlsl
Comment thread include/nbl/builtin/hlsl/bxdf/base/cook_torrance_base.hlsl Outdated
Comment thread include/nbl/builtin/hlsl/bxdf/base/cook_torrance_base.hlsl Outdated
Comment thread include/nbl/builtin/hlsl/bxdf/base/cook_torrance_base.hlsl Outdated
Comment thread include/nbl/builtin/hlsl/bxdf/base/cook_torrance_base.hlsl
Comment thread include/nbl/builtin/hlsl/bxdf/common.hlsl Outdated
Comment thread include/nbl/builtin/hlsl/bxdf/common.hlsl Outdated
Comment thread include/nbl/builtin/hlsl/bxdf/common.hlsl
Comment thread include/nbl/builtin/hlsl/bxdf/base/cook_torrance_base.hlsl Outdated
Comment thread include/nbl/builtin/hlsl/bxdf/common.hlsl
Comment thread include/nbl/builtin/hlsl/bxdf/common.hlsl
Base automatically changed from sampler-concepts to master April 16, 2026 21:17
Comment thread include/nbl/builtin/hlsl/path_tracing/unidirectional.hlsl
Comment thread include/nbl/builtin/hlsl/path_tracing/unidirectional.hlsl
Comment thread include/nbl/builtin/hlsl/path_tracing/unidirectional.hlsl
Comment thread include/nbl/builtin/hlsl/bxdf/fresnel.hlsl
Comment thread include/nbl/builtin/hlsl/bxdf/common.hlsl
Comment on lines 900 to +907
((NBL_CONCEPT_REQ_TYPE)(T::scalar_type))
((NBL_CONCEPT_REQ_TYPE)(T::anisotropic_interaction_type))
((NBL_CONCEPT_REQ_TYPE)(T::sample_type))
((NBL_CONCEPT_REQ_TYPE)(T::anisocache_type))
((NBL_CONCEPT_REQ_TYPE)(T::spectral_type))
((NBL_CONCEPT_REQ_TYPE)(T::quotient_pdf_type))
((NBL_CONCEPT_REQ_TYPE)(T::quotient_weight_type))
((NBL_CONCEPT_REQ_TYPE)(T::value_weight_type))
((NBL_CONCEPT_REQ_TYPE)(T::random_type))
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

TODO: can we check NBL_CONCEPT_REQ_TYPE_ALIAS_CONCEPT that these are correct:

  1. fundamental scalar
  2. interaction
  3. sample
  4. spectral type is a vector ?
  5. quotient and pdf type is quotient and pdf
  6. value and weight is value and weight
  7. random type is a floating point vectorial

We should probably remove quotient_pdf_type

Comment on lines 957 to +958
((NBL_CONCEPT_REQ_TYPE)(T::isotropic_interaction_type))
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((bxdf.eval(_sample, iso)), ::nbl::hlsl::is_same_v, typename T::spectral_type))
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((bxdf.pdf(_sample, iso)), ::nbl::hlsl::is_same_v, typename T::scalar_type))
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((bxdf.quotient_and_pdf(_sample, iso)), ::nbl::hlsl::is_same_v, typename T::quotient_pdf_type))
((NBL_CONCEPT_REQ_TYPE_ALIAS_CONCEPT)(concepts::FloatingPointLikeVectorial, typename T::spectral_type))
((NBL_CONCEPT_REQ_TYPE)(T::isocache_type))
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

TODO: check iso types meet concepts

Comment thread include/nbl/builtin/hlsl/bxdf/common.hlsl
Comment thread include/nbl/builtin/hlsl/bxdf/common.hlsl
@devshgraphicsprogramming devshgraphicsprogramming merged commit edfcbc2 into master Apr 18, 2026
15 of 22 checks passed
@devshgraphicsprogramming devshgraphicsprogramming deleted the ris_bxdfs branch April 18, 2026 00:34
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.

3 participants