Skip to content

Env map importance sampling#969

Open
kevyuu wants to merge 125 commits intomasterfrom
env_map_importance_sampling
Open

Env map importance sampling#969
kevyuu wants to merge 125 commits intomasterfrom
env_map_importance_sampling

Conversation

@kevyuu
Copy link
Copy Markdown
Contributor

@kevyuu kevyuu commented Dec 19, 2025

Description

Rework environment map importance sampling to vulkan and hlsl

Testing

Rework example 0 to use vulkan and hlsl
Unit Test Pull Request

TODO list:

  • Implement Warpmap Generation in hlsl
  • Implement Warpmap hierarchical map sampling in hlsl

@devshgraphicsprogramming
Copy link
Copy Markdown
Member

@kevyuu you've somehow reverted the submodule pointers

Comment on lines +68 to +85
weight_type forwardWeight(const domain_type v, const cache_type cache)
{
return scalar_type(1) / (scalar_type(2) * cache.sinTheta * numbers::pi<scalar_type> *numbers::pi<scalar_type>);
}

density_type backwardPdf(const codomain_type v)
{
const density_type cosTheta = v.y;
const density_type rcpSinTheta = hlsl::rsqrt(density_type(1) - (cosTheta * cosTheta));
return rcpSinTheta / (density_type(2) * numbers::pi<density_type> * numbers::pi<density_type>);
}

weight_type backwardWeight(const codomain_type v)
{
const density_type cosTheta = v.y;
const density_type rcpSinTheta = hlsl::rsqrt(density_type(1) - (cosTheta * cosTheta));
return rcpSinTheta / (density_type(2) * numbers::pi<density_type> * numbers::pi<density_type>);
}
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.

make the weight call the PDF function so there's no duplicate code

Comment on lines +21 to +31
uint16_t lumaMapLayer;
};

struct SWarpGenPushConstants
{
uint32_t lumaMapWidth : 16;
uint32_t lumaMapHeight : 16;
uint32_t warpMapWidth : 16;
uint32_t warpMapHeight : 16;
// Both warpMap and lumaMap should have the same layer count
uint16_t lumaMapLayer;
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.

you cannot use uint16 in push constants (AMD), have to use uint32_t and use a bitfield instead

namespace hierarchical_image
{

NBL_CONSTEXPR_INLINE_NSPC_SCOPE_VAR float32_t3 LumaRgbCoefficients = { 0.2126729f, 0.7151522f, 0.0721750f };
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.

use numbers from the OETF/EOTF headers

{

// TODO: Add some constraint into PostWarpT
// Ask(kevin): Should we add constraint so the WarpAccessor::scalar_type is the same as LuminanceAccessorT::value_type. One is a uv and the other is luminance. Technically, they can have different type.
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.

no we shouldn't, luma could be float32_t due to extreme HDR but warpmap could be unorm16 / float16_t if the luma is low res enough

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