Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
121 commits
Select commit Hold shift + click to select a range
02d6d0f
initial example
keptsecret Feb 4, 2025
129b50e
use bxdf creation params struct
keptsecret Feb 6, 2025
74261dc
triangle and rectangle shapes
keptsecret Feb 7, 2025
ab3ae20
more sampling methods
keptsecret Feb 10, 2025
355cfec
spherical rectangle
keptsecret Feb 11, 2025
ebf8fca
merge pcg fix from upstream
keptsecret Feb 12, 2025
11180f4
fix aniso cache bug
keptsecret Feb 17, 2025
4516051
init func to modify bxdf params directly
keptsecret Feb 18, 2025
d9a00c9
bug fixes
keptsecret Feb 20, 2025
ffe9029
fix sampling bugs #2
keptsecret Feb 21, 2025
cee192e
update to master
keptsecret Feb 21, 2025
b207312
fix rank type trait for matrix/vector
keptsecret Feb 21, 2025
673f788
merge hlsl bxdfs, resolve conflict
keptsecret Feb 25, 2025
69a257d
temporary fix for dxc bug issue 7154
keptsecret Feb 25, 2025
866e6d7
some bug fixes again
keptsecret Feb 26, 2025
85e955f
fix wrong template usage
keptsecret Feb 27, 2025
3b167ab
merge changes from hlsl_bxdf
keptsecret Feb 28, 2025
19e3a35
merge master/bxdf fixes, resolve conflicts
keptsecret Mar 3, 2025
6b5bf06
Merge branch 'hlsl_bxdfs' into hlsl_path_tracer_example
keptsecret Mar 4, 2025
7b574da
Merge branch 'hlsl_bxdfs' into hlsl_path_tracer_example
keptsecret Mar 4, 2025
1c773d9
fix typo
keptsecret Mar 4, 2025
326c885
Merge branch 'hlsl_bxdfs' into hlsl_path_tracer_example
keptsecret Mar 5, 2025
6132a4e
Merge branch 'revert-some-device-limits' into hlsl_path_tracer_example
keptsecret Mar 6, 2025
0bd26c7
Merge branch 'master' into hlsl_path_tracer_example
keptsecret Mar 6, 2025
ebb1b15
Merge branch 'hlsl_bxdfs' into hlsl_path_tracer_example
keptsecret Mar 7, 2025
7cb977d
Merge branch 'hlsl_bxdfs' into hlsl_path_tracer_example
keptsecret Mar 7, 2025
67c525e
Merge branch 'master' into hlsl_path_tracer_example
keptsecret Mar 10, 2025
a8f209e
Merge branch 'hlsl_bxdfs' into hlsl_path_tracer_example
keptsecret Mar 11, 2025
e8d2ed8
fixed some func usage to nbl ver
keptsecret Mar 14, 2025
c47f446
specify template args
keptsecret Mar 17, 2025
642e46d
fix merge conflicts
keptsecret Mar 17, 2025
1137b6b
update to latest example
keptsecret Mar 17, 2025
5cd4e6c
merge math, fix conflict
keptsecret Mar 19, 2025
7e8dd81
latest example
keptsecret Mar 19, 2025
f86dd0c
Merge remote-tracking branch 'origin/intrinsics_adjustments' into hls…
keptsecret Mar 21, 2025
b154638
fix use of static const in func
keptsecret Mar 21, 2025
7892563
added more morton order stuff
keptsecret Mar 24, 2025
b21b789
latest example
keptsecret Mar 28, 2025
1f461ff
merge master, fix conflicts
keptsecret Apr 3, 2025
df2321a
merge hlsl_bxdfs, fix conflicts
keptsecret Jun 26, 2025
26adf95
latest example
keptsecret Jun 27, 2025
0d80626
Merge branch 'hlsl_bxdfs' into hlsl_path_tracer_example
keptsecret Jun 27, 2025
36910c6
latest example fixes
keptsecret Jun 30, 2025
afc3485
merge bxdf, fix conflicts
keptsecret Aug 28, 2025
19ba15d
Updated examples
Przemog1 Sep 25, 2025
7ec3f39
Created RWMC files
Przemog1 Oct 18, 2025
4dcf56a
Updated examples
Przemog1 Oct 20, 2025
dbbb30a
merge master, fix conflicts
keptsecret Nov 12, 2025
3ae69fa
updated example
keptsecret Nov 12, 2025
1f9bf16
merge iridescent_bxdf, fix conflicts (hope it's merged to master soon)
keptsecret Nov 12, 2025
4cfed1b
use new angle adder
keptsecret Nov 13, 2025
8ecfecf
Merge branch 'master' into hlsl_path_tracer_example
keptsecret Nov 13, 2025
dc8b5bc
initialize invalid ndf return to inf, not 0
keptsecret Nov 13, 2025
434234c
derive trait from cook torrance base
keptsecret Nov 13, 2025
ffeb633
fix angle adder
keptsecret Nov 13, 2025
d75246d
optimizations to iridescent fresnel
keptsecret Nov 13, 2025
494c625
avoid repeat fresnel calc
keptsecret Nov 13, 2025
ab25c17
mix reflectance w/ transmission in getScaledReflectance
keptsecret Nov 13, 2025
2a7db14
Refactored resolve.hlsl
Przemog1 Nov 13, 2025
1acf7d6
some minor fixes to fresnel orientedEta usage
keptsecret Nov 14, 2025
72429cb
refactor usage of angle adding
keptsecret Nov 14, 2025
381bb50
temp? fix for mix_helper on floats
keptsecret Nov 14, 2025
482ef2e
merge rwmc, fix conflicts
keptsecret Nov 14, 2025
a40a025
added missing typename qualifier
keptsecret Nov 14, 2025
b3f6d55
Fixed `ResolveAccessor` concept
Przemog1 Nov 14, 2025
cf6760e
minor fixes to spherical rect, latest example
keptsecret Nov 17, 2025
4a283ba
quaternion struct, renamed spherical tri/rect shapes
keptsecret Nov 18, 2025
0305948
make PartitionRandVar in struct and templated
keptsecret Nov 18, 2025
3134254
precompute values in linear, bilinear sampling; make box muller a struct
keptsecret Nov 18, 2025
8d744a9
precompute cos_sides, csc_sides in shape spherical_tri
keptsecret Nov 19, 2025
2a22cb6
merge new rwmc fix
keptsecret Nov 19, 2025
8292707
fix spherical tri precompute
keptsecret Nov 20, 2025
563e072
latest example
keptsecret Nov 25, 2025
4abbacf
Merge branch 'master' into hlsl_path_tracer_example
keptsecret Nov 25, 2025
229929d
update examples
Erfan-Ahmadi Nov 25, 2025
495924c
Merge branch 'master' into hlsl_path_tracer_example
keptsecret Nov 26, 2025
27fd427
make rwmc accumulator match concept
keptsecret Nov 26, 2025
12cac68
took 1transformation_matrix_utils.hlsl` from Arek's `cameraz` branch
karimsayedre Nov 26, 2025
438aeb5
Merge remote-tracking branch 'origin/hlsl_path_tracer_example' into i…
karimsayedre Nov 26, 2025
d125a0e
pack rwmc params to half 2x16
keptsecret Nov 27, 2025
1ccc4c4
Merge branch 'master' into hlsl_path_tracer_example
keptsecret Nov 27, 2025
aa716ee
merge imguizmo-lights, fix conflicts
keptsecret Nov 28, 2025
8a6939f
latest example
keptsecret Nov 28, 2025
fbfde73
change quaternion struct name to match what it will be
keptsecret Dec 2, 2025
856f828
merge master, fix conflicts
keptsecret Dec 2, 2025
07918be
Merge branch 'master' into hlsl_path_tracer_example_no_quat
keptsecret Dec 4, 2025
37d5c5a
removed temp fix for mix_helper require
keptsecret Dec 4, 2025
6971906
fixes more nan problems + a few bugs in iridescent fresnel
keptsecret Dec 5, 2025
cb68928
fixes iridescent fresnel under transmission
keptsecret Dec 5, 2025
76ed66c
fix wrong get refraction eta in iridescent transmission
keptsecret Dec 5, 2025
4a8f4dc
quantized sequence packing data
keptsecret Dec 8, 2025
b8688be
templated quantized sequence
keptsecret Dec 9, 2025
2146003
Merge branch 'master' into hlsl_path_tracer_example_no_quat
keptsecret Dec 9, 2025
38bbf04
latest example
keptsecret Dec 9, 2025
fae7a80
quantized sequence decode
keptsecret Dec 9, 2025
e23538c
quantized sequence get/set values by index, simplify decode func spec…
keptsecret Dec 10, 2025
6e9160e
quantized sequence encode should right shift input, changed scramble …
keptsecret Dec 10, 2025
6f0d012
added decode variant for scramble before decode
keptsecret Dec 11, 2025
3d53866
Merge branch 'master' into hlsl_path_tracer_example_no_quat
keptsecret Dec 11, 2025
c6462d1
some minor fixes to quantized sequence set, decode
keptsecret Dec 12, 2025
a30f083
fix quantized sequence mask being too small, assert conditions
keptsecret Dec 15, 2025
073a9f3
merge master, fix conflicts
keptsecret Dec 15, 2025
7d16cb2
fixed problems from merging master
keptsecret Dec 15, 2025
965e028
fix decode scramble key, shifting discard bits in quantization
keptsecret Dec 15, 2025
cfd5500
fix z component storing too many bits in quantized sequence in vec2 d…
keptsecret Dec 15, 2025
53ff444
mix_helper requirements include bool vectors
keptsecret Dec 16, 2025
5055713
fix iridescent oriented eta bug
keptsecret Dec 16, 2025
3f3b5c9
partitionRandVar stores leftProb, fix minor bugs
keptsecret Dec 16, 2025
db454c0
plain const for vector types
keptsecret Dec 16, 2025
c353ab3
fixes to iridescent fresnel, moved getOrientedEtaRcp to dielectric fr…
keptsecret Dec 16, 2025
04f1c76
adjust mix_helper calling select requirements
keptsecret Dec 16, 2025
94a778f
restore regular triangle stuff, refactor usage
keptsecret Dec 16, 2025
9e4a16c
minor changes to rwmc usage
keptsecret Dec 16, 2025
62c79b4
remove storing texture inside local var of ResolveAccessorAdaptor
keptsecret Dec 16, 2025
5075c63
removed accessor, user should provide accessor that matches concept
keptsecret Dec 16, 2025
90007e6
fix formatting, name
keptsecret Dec 16, 2025
3d36c13
added more things to precompute
keptsecret Dec 16, 2025
62f2c99
changes to splatting params precompute for the last time
keptsecret Dec 16, 2025
f3f60c6
check that eta type of dielectric fresnels should be monochrome
keptsecret Dec 16, 2025
b4d957d
Change `Compile flag error` to `Compile flag warning`
devshgraphicsprogramming Dec 16, 2025
dfcae2d
Merge remote-tracking branch 'remotes/origin/master' into hlsl_path_t…
Dec 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions include/nbl/builtin/hlsl/cpp_compat/impl/intrinsics_impl.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -968,8 +968,19 @@ struct mix_helper<T, T NBL_PARTIAL_REQ_BOT(VECTOR_SPECIALIZATION_CONCEPT && !imp
}
};

template<typename T, typename U> NBL_PARTIAL_REQ_TOP((concepts::Vectorial<T> || concepts::Scalar<T>) && concepts::Boolean<U> && !impl::MixCallingBuiltins<T, U>)
struct mix_helper<T, U NBL_PARTIAL_REQ_BOT((concepts::Vectorial<T> || concepts::Scalar<T>) && concepts::Boolean<U> && !impl::MixCallingBuiltins<T, U>) >
namespace impl
{
template<typename T, typename U>
NBL_BOOL_CONCEPT MixCallingSelect =
#ifdef __HLSL_VERSION
spirv::SelectIsCallable<T, U>;
#else
concepts::Boolean<U> && (concepts::Scalar<U> || (concepts::Vector<T> && vector_traits<T>::Dimension==vector_traits<U>::Dimension)) && !MixCallingBuiltins<T, U>;
#endif
}

template<typename T, typename U> NBL_PARTIAL_REQ_TOP(impl::MixCallingSelect<T, U>)
struct mix_helper<T, U NBL_PARTIAL_REQ_BOT(impl::MixCallingSelect<T, U>) >
{
using return_t = T;
static return_t __call(NBL_CONST_REF_ARG(T) x, NBL_CONST_REF_ARG(T) y, NBL_CONST_REF_ARG(U) a)
Expand Down
9 changes: 5 additions & 4 deletions include/nbl/builtin/hlsl/rwmc/CascadeAccumulator.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,9 @@ struct CascadeAccumulator
// most of this code is stolen from https://cg.ivd.kit.edu/publications/2018/rwmc/tool/split.cpp
void addSample(uint32_t sampleCount, input_sample_type _sample)
{
const float32_t2 unpackedParams = hlsl::unpackHalf2x16(splattingParameters.packedLog2);
const cascade_layer_scalar_type log2Start = unpackedParams[0];
const cascade_layer_scalar_type log2Base = unpackedParams[1];
const cascade_layer_scalar_type luma = getLuma(_sample);
const cascade_layer_scalar_type log2Luma = log2<cascade_layer_scalar_type>(luma);
const cascade_layer_scalar_type cascade = log2Luma * 1.f / log2Base - log2Start / log2Base;
const cascade_layer_scalar_type cascade = log2Luma * splattingParameters.rcpLog2Base - splattingParameters.baseRootOfStart;
const cascade_layer_scalar_type clampedCascade = clamp(cascade, 0, CascadeCount - 1);
// c<=0 -> 0, c>=Count-1 -> Count-1
uint32_t lowerCascadeIndex = floor<cascade_layer_scalar_type>(cascade);
Expand All @@ -85,7 +82,11 @@ struct CascadeAccumulator

// handle super bright sample case
if (cascade > CascadeCount - 1)
{
const cascade_layer_scalar_type log2Base = cascade_layer_scalar_type(1.0) / splattingParameters.rcpLog2Base;
const cascade_layer_scalar_type log2Start = splattingParameters.baseRootOfStart * log2Base;
lowerCascadeWeight = exp2(log2Start + log2Base * (CascadeCount - 1) - log2Luma);
}

accumulation.addSampleIntoCascadeEntry(_sample, lowerCascadeIndex, lowerCascadeWeight, higherCascadeWeight, sampleCount);
}
Expand Down
17 changes: 13 additions & 4 deletions include/nbl/builtin/hlsl/rwmc/SplattingParameters.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define _NBL_BUILTIN_HLSL_RWMC_SPLATTING_PARAMETERS_HLSL_INCLUDED_

#include "nbl/builtin/hlsl/cpp_compat.hlsl"
#include "nbl/builtin/hlsl/tgmath.hlsl"

namespace nbl
{
Expand All @@ -12,10 +13,18 @@ namespace rwmc

struct SplattingParameters
{
// float16_t log2Start; 0
// float16_t log2Base; 1
// pack as Half2x16
int32_t packedLog2;
using scalar_t = float;

static SplattingParameters create(const scalar_t base, const scalar_t start)
{
SplattingParameters retval;
retval.rcpLog2Base = scalar_t(1.0) / hlsl::log2(base);
retval.baseRootOfStart = hlsl::log2(start) * retval.rcpLog2Base;
return retval;
}

scalar_t baseRootOfStart;
scalar_t rcpLog2Base;
};

}
Expand Down
2 changes: 0 additions & 2 deletions include/nbl/builtin/hlsl/rwmc/resolve.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ struct ResolveAccessorAdaptor
using output_type = vector<OutputScalar, 4>;
NBL_CONSTEXPR int32_t image_dimension = 2;

RWTexture2DArray<float32_t4> cascade;

float32_t calcLuma(NBL_REF_ARG(float32_t3) col)
{
return hlsl::dot<float32_t3>(colorspace::scRGB::ToXYZ()[1], col);
Expand Down
23 changes: 0 additions & 23 deletions include/nbl/builtin/hlsl/shapes/spherical_triangle.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -102,29 +102,6 @@ struct SphericalTriangle
vector3_type csc_sides;
};

namespace util
{
// Use this convetion e_i = v_{i+2}-v_{i+1}. vertex index is modulo by 3.
template <typename float_t>
vector<float_t, 3> compInternalAngle(const vector<float_t, 3> e0, vector<float_t, 3> e1, const vector<float_t, 3> e2)
{
// Calculate this triangle's weight for each of its three m_vertices
// start by calculating the lengths of its sides
const float_t a = hlsl::dot(e0, e0);
const float_t asqrt = hlsl::sqrt(a);
const float_t b = hlsl::dot(e1, e1);
const float_t bsqrt = hlsl::sqrt(b);
const float_t c = hlsl::dot(e2, e2);
const float_t csqrt = hlsl::sqrt(c);

const float_t angle0 = hlsl::acos((b + c - a) / (2.f * bsqrt * csqrt));
const float_t angle1 = hlsl::acos((-b + c + a) / (2.f * asqrt * csqrt));
const float_t angle2 = hlsl::numbers::pi<float_t> - (angle0 + angle1);
// use them to find the angle at each vertex
return vector<float_t, 3>(angle0, angle1, angle2);
}
}

}
}
}
Expand Down
46 changes: 46 additions & 0 deletions include/nbl/builtin/hlsl/shapes/triangle.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright (C) 2018-2025 - DevSH Graphics Programming Sp. z O.O.
// This file is part of the "Nabla Engine".
// For conditions of distribution and use, see copyright notice in nabla.h

#ifndef _NBL_BUILTIN_HLSL_SHAPES_TRIANGLE_INCLUDED_
#define _NBL_BUILTIN_HLSL_SHAPES_TRIANGLE_INCLUDED_

#include <nbl/builtin/hlsl/cpp_compat.hlsl>
#include <nbl/builtin/hlsl/tgmath.hlsl>
#include <nbl/builtin/hlsl/numbers.hlsl>

namespace nbl
{
namespace hlsl
{
namespace shapes
{

namespace util
{
// Use this convetion e_i = v_{i+2}-v_{i+1}. vertex index is modulo by 3.
template <typename float_t>
vector<float_t, 3> anglesFromTriangleEdge(const vector<float_t, 3> e0, vector<float_t, 3> e1, const vector<float_t, 3> e2)
{
// Calculate this triangle's weight for each of its three m_vertices
// start by calculating the lengths of its sides
const float_t a = hlsl::dot(e0, e0);
const float_t asqrt = hlsl::sqrt(a);
const float_t b = hlsl::dot(e1, e1);
const float_t bsqrt = hlsl::sqrt(b);
const float_t c = hlsl::dot(e2, e2);
const float_t csqrt = hlsl::sqrt(c);

const float_t angle0 = hlsl::acos((b + c - a) / (2.f * bsqrt * csqrt));
const float_t angle1 = hlsl::acos((-b + c + a) / (2.f * asqrt * csqrt));
const float_t angle2 = hlsl::numbers::pi<float_t> - (angle0 + angle1);
// use them to find the angle at each vertex
return vector<float_t, 3>(angle0, angle1, angle2);
}
}

}
}
}

#endif
4 changes: 2 additions & 2 deletions src/nbl/asset/utils/CSmoothNormalGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "CSmoothNormalGenerator.h"

#include "nbl/core/declarations.h"
#include "nbl/builtin/hlsl/shapes/spherical_triangle.hlsl"
#include "nbl/builtin/hlsl/shapes/triangle.hlsl"

#include <algorithm>

Expand Down Expand Up @@ -58,7 +58,7 @@ CSmoothNormalGenerator::VertexHashMap CSmoothNormalGenerator::setupData(const as
const auto faceNormal = normalize(cross(v1 - v0, v2 - v0));

//set data for m_vertices
const auto angleWages = hlsl::shapes::util::compInternalAngle(v2 - v1, v0 - v2, v1 - v2);
const auto angleWages = hlsl::shapes::util::anglesFromTriangleEdge(v2 - v1, v0 - v2, v1 - v2);

vertices.add({ i, 0, faceNormal * angleWages.x, v0});
vertices.add({ i + 1, 0, faceNormal * angleWages.y,v1});
Expand Down
1 change: 1 addition & 0 deletions src/nbl/builtin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/shapes/circle.hlsl")
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/shapes/ellipse.hlsl")
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/shapes/line.hlsl")
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/shapes/beziers.hlsl")
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/shapes/triangle.hlsl")
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/shapes/spherical_triangle.hlsl")
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/shapes/spherical_rectangle.hlsl")
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/shapes/aabb.hlsl")
Expand Down
Loading