Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
14636d3
update examples submodule
karimsayedre Dec 3, 2025
49a5d2b
Merge branch 'imguizmo-lights' into solid-angle-vis
karimsayedre Dec 4, 2025
6887419
updated examples submodule
karimsayedre Dec 6, 2025
f32ddd2
Update examples submodule
karimsayedre Dec 6, 2025
1832059
update examples submodule
karimsayedre Dec 8, 2025
b79bf8f
update examples submodule
karimsayedre Dec 8, 2025
49a017a
update examples submodule
karimsayedre Dec 8, 2025
e714c24
RandomSampler can give floats now, ranged and [0, 1), also update exa…
karimsayedre Dec 17, 2025
6741c75
update examples submodules
karimsayedre Dec 17, 2025
92545a5
update examples submodule
karimsayedre Dec 17, 2025
993032c
update examples submodule
karimsayedre Dec 20, 2025
3f9007a
Merge branch 'master' into solid-angle-vis
karimsayedre Dec 23, 2025
af7574a
include `tgmath.hlsl` in `functions.hlsl`, update examples_tests
karimsayedre Dec 31, 2025
27aad5c
Added `SRasterizationParams` to the full screen triangle pipeline cre…
karimsayedre Jan 6, 2026
e3adac0
update examples_tests
karimsayedre Jan 21, 2026
5096d9e
Merge branch 'master' into solid-angle-vis
karimsayedre Feb 17, 2026
68f5a49
fixes after merge, update examples submodule
karimsayedre Feb 17, 2026
4fef4b0
Merge branch 'sampler-concepts' into solid-angle-vis
karimsayedre Apr 11, 2026
af31b2b
Merge branch 'sampler-concepts' into solid-angle-vis
karimsayedre Apr 12, 2026
df64065
Merge branch 'sampler-concepts' into solid-angle-vis
karimsayedre Apr 13, 2026
1f3fed4
factorize out a bunch of stuff, make the Spherical Rectangle Solid An…
devshgraphicsprogramming Apr 16, 2026
1df4116
epic optimization!
devshgraphicsprogramming Apr 16, 2026
a3ed91a
`UsePdfAsWeight==false` implementation was 100% wrong
devshgraphicsprogramming Apr 17, 2026
99e9495
why its always to use accessing methods than members directly in othe…
devshgraphicsprogramming Apr 17, 2026
6da021b
The Spherical Rectangle Shape needs to be created with the observer (…
devshgraphicsprogramming Apr 17, 2026
4045921
Spherical Rectangle needs `generateInverse` implemented, otherwise PR…
devshgraphicsprogramming Apr 17, 2026
45a68a6
Update spherical_triangle.hlsl
devshgraphicsprogramming Apr 17, 2026
2291b7d
fixed compartor float vs bool warning, no more spherical triangle boi…
karimsayedre Apr 21, 2026
37cb817
Eytzinger CDF, alias table is packed, 2 versions, CDF sampler now has…
karimsayedre Apr 24, 2026
c12a724
forgotten to commit file
karimsayedre Apr 24, 2026
0571f7e
Merge branch 'master' into new-sampler-concepts
karimsayedre Apr 24, 2026
fc3cec4
replaced all sampler literal floats casting with `_static_cast<>()`
karimsayedre Apr 27, 2026
bf81211
Merge branch 'new-sampler-concepts' of github.com:Devsh-Graphics-Prog…
karimsayedre Apr 27, 2026
581e185
OBB view, width specific rotl and rotr
karimsayedre Apr 27, 2026
d7c95a4
Merge branch 'master' into solid-angle-vis
karimsayedre Apr 28, 2026
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
2 changes: 1 addition & 1 deletion examples_tests
Submodule examples_tests updated 87 files
+61 −56 31_HLSLPathTracer/app_resources/hlsl/next_event_estimator.hlsl
+0 −1 31_HLSLPathTracer/app_resources/hlsl/scene_rectangle_light.hlsl
+1 −1 31_HLSLPathTracer/main.cpp
+169 −34 37_HLSLSamplingTests/CMakeLists.txt
+77 −27 37_HLSLSamplingTests/app_resources/common/alias_table.hlsl
+0 −1 37_HLSLSamplingTests/app_resources/common/array_accessor.hlsl
+6 −0 37_HLSLSamplingTests/app_resources/common/bilinear.hlsl
+3 −0 37_HLSLSamplingTests/app_resources/common/box_muller_transform.hlsl
+11 −1 37_HLSLSamplingTests/app_resources/common/concentric_mapping.hlsl
+2 −0 37_HLSLSamplingTests/app_resources/common/cumulative_probability.hlsl
+8 −9 37_HLSLSamplingTests/app_resources/common/discrete_sampler_bench.hlsl
+264 −0 37_HLSLSamplingTests/app_resources/common/jacobian_test.hlsl
+3 −0 37_HLSLSamplingTests/app_resources/common/linear.hlsl
+19 −1 37_HLSLSamplingTests/app_resources/common/polar_mapping.hlsl
+7 −1 37_HLSLSamplingTests/app_resources/common/projected_hemisphere.hlsl
+3 −0 37_HLSLSamplingTests/app_resources/common/projected_sphere.hlsl
+21 −23 37_HLSLSamplingTests/app_resources/common/projected_spherical_rectangle.hlsl
+13 −8 37_HLSLSamplingTests/app_resources/common/projected_spherical_triangle.hlsl
+12 −4 37_HLSLSamplingTests/app_resources/common/spherical_rectangle.hlsl
+11 −4 37_HLSLSamplingTests/app_resources/common/spherical_triangle.hlsl
+7 −1 37_HLSLSamplingTests/app_resources/common/uniform_hemisphere.hlsl
+8 −1 37_HLSLSamplingTests/app_resources/common/uniform_sphere.hlsl
+0 −77 37_HLSLSamplingTests/app_resources/shaders/alias_table_test.comp.hlsl
+17 −13 37_HLSLSamplingTests/app_resources/shaders/bilinear_test.comp.hlsl
+17 −13 37_HLSLSamplingTests/app_resources/shaders/box_muller_transform_test.comp.hlsl
+13 −9 37_HLSLSamplingTests/app_resources/shaders/concentric_mapping_test.comp.hlsl
+11 −10 37_HLSLSamplingTests/app_resources/shaders/cumulative_probability_test.comp.hlsl
+17 −13 37_HLSLSamplingTests/app_resources/shaders/linear_test.comp.hlsl
+114 −0 37_HLSLSamplingTests/app_resources/shaders/packed_alias_test.comp.hlsl
+13 −9 37_HLSLSamplingTests/app_resources/shaders/polar_mapping_test.comp.hlsl
+13 −9 37_HLSLSamplingTests/app_resources/shaders/projected_hemisphere_test.comp.hlsl
+13 −9 37_HLSLSamplingTests/app_resources/shaders/projected_sphere_test.comp.hlsl
+42 −16 37_HLSLSamplingTests/app_resources/shaders/projected_spherical_rectangle_test.comp.hlsl
+30 −13 37_HLSLSamplingTests/app_resources/shaders/projected_spherical_triangle_test.comp.hlsl
+89 −17 37_HLSLSamplingTests/app_resources/shaders/spherical_rectangle_test.comp.hlsl
+29 −13 37_HLSLSamplingTests/app_resources/shaders/spherical_triangle.comp.hlsl
+63 −5 37_HLSLSamplingTests/app_resources/shaders/test_compile.comp.hlsl
+13 −9 37_HLSLSamplingTests/app_resources/shaders/uniform_hemisphere_test.comp.hlsl
+13 −9 37_HLSLSamplingTests/app_resources/shaders/uniform_sphere_test.comp.hlsl
+277 −254 37_HLSLSamplingTests/benchmarks/CDiscreteSamplerBenchmark.h
+52 −74 37_HLSLSamplingTests/benchmarks/CSamplerBenchmark.h
+148 −75 37_HLSLSamplingTests/main.cpp
+36 −15 37_HLSLSamplingTests/tests/CAliasTableGPUTester.h
+4 −3 37_HLSLSamplingTests/tests/CBilinearTester.h
+2 −1 37_HLSLSamplingTests/tests/CBoxMullerTransformTester.h
+3 −2 37_HLSLSamplingTests/tests/CConcentricMappingTester.h
+2 −1 37_HLSLSamplingTests/tests/CCumulativeProbabilityGPUTester.h
+371 −237 37_HLSLSamplingTests/tests/CDiscreteTableTester.h
+6 −5 37_HLSLSamplingTests/tests/CLinearTester.h
+3 −2 37_HLSLSamplingTests/tests/CPolarMappingTester.h
+5 −4 37_HLSLSamplingTests/tests/CProjectedHemisphereTester.h
+4 −3 37_HLSLSamplingTests/tests/CProjectedSphereTester.h
+36 −47 37_HLSLSamplingTests/tests/CProjectedSphericalRectangleTester.h
+18 −14 37_HLSLSamplingTests/tests/CProjectedSphericalTriangleTester.h
+20 −15 37_HLSLSamplingTests/tests/CSphericalRectangleTester.h
+9 −6 37_HLSLSamplingTests/tests/CSphericalTriangleTester.h
+3 −2 37_HLSLSamplingTests/tests/CUniformHemisphereTester.h
+3 −2 37_HLSLSamplingTests/tests/CUniformSphereTester.h
+328 −154 37_HLSLSamplingTests/tests/SamplerTestHelpers.h
+148 −72 37_HLSLSamplingTests/tests/property/CSamplerPropertyTester.h
+8 −10 40_PathTracer/app_resources/pathtrace/beauty.hlsl
+13 −4 40_PathTracer/app_resources/pathtrace/common.hlsl
+32 −91 64_EmulatedFloatTest/main.cpp
+136 −0 73_SolidAngleVisualizer/CMakeLists.txt
+0 −0 73_SolidAngleVisualizer/README.md
+424 −0 73_SolidAngleVisualizer/app_resources/hlsl/Drawing.hlsl
+240 −0 73_SolidAngleVisualizer/app_resources/hlsl/benchmark/benchmark.comp.hlsl
+10 −0 73_SolidAngleVisualizer/app_resources/hlsl/benchmark/common.hlsl
+155 −0 73_SolidAngleVisualizer/app_resources/hlsl/common.hlsl
+150 −0 73_SolidAngleVisualizer/app_resources/hlsl/debug_vis.hlsl
+410 −0 73_SolidAngleVisualizer/app_resources/hlsl/parallelogram_sampling.hlsl
+301 −0 73_SolidAngleVisualizer/app_resources/hlsl/pyramid_sampling.hlsl
+76 −0 73_SolidAngleVisualizer/app_resources/hlsl/pyramid_sampling/bilinear.hlsl
+80 −0 73_SolidAngleVisualizer/app_resources/hlsl/pyramid_sampling/biquadratic.hlsl
+108 −0 73_SolidAngleVisualizer/app_resources/hlsl/ray_vis.frag.hlsl
+399 −0 73_SolidAngleVisualizer/app_resources/hlsl/silhouette.hlsl
+217 −0 73_SolidAngleVisualizer/app_resources/hlsl/solid_angle_vis.frag.hlsl
+184 −0 73_SolidAngleVisualizer/app_resources/hlsl/triangle_sampling.hlsl
+31 −0 73_SolidAngleVisualizer/app_resources/hlsl/utils.hlsl
+28 −0 73_SolidAngleVisualizer/config.json.template
+19 −0 73_SolidAngleVisualizer/include/common.hpp
+213 −0 73_SolidAngleVisualizer/include/transform.hpp
+1,824 −0 73_SolidAngleVisualizer/main.cpp
+50 −0 73_SolidAngleVisualizer/pipeline.groovy
+0 −0 73_SolidAngleVisualizer/src/transform.cpp
+1 −0 CMakeLists.txt
+87 −59 common/include/nbl/examples/cameras/CCamera.hpp
4 changes: 3 additions & 1 deletion include/nbl/builtin/hlsl/algorithm.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@ struct bound_t

void comp_step(NBL_REF_ARG(Accessor) accessor, const uint32_t testPoint, const uint32_t rightBegin)
{
if (compare(accessor[testPoint],value))
typename Accessor::value_type val;
accessor.get(testPoint, val);
if (compare(val,value))
it = rightBegin;
}
void comp_step(NBL_REF_ARG(Accessor) accessor, const uint32_t testPoint)
Expand Down
30 changes: 29 additions & 1 deletion include/nbl/builtin/hlsl/bit.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@


#include <nbl/builtin/hlsl/macros.h>
#include <nbl/builtin/hlsl/cpp_compat/basic.h>


#ifndef __HLSL_VERSION
Expand Down Expand Up @@ -123,5 +124,32 @@ uint16_t countl_zero(T n)
}
}
#endif


namespace nbl
{
namespace hlsl
{

// Variable-width sub-word bit rotation
template<typename T>
NBL_CONSTEXPR_FUNC T rotl(T value, uint32_t bits, uint32_t width)
{
const T mask = (width >= sizeof(T) * 8) ? ~T(0) : ((T(1) << width) - T(1));
value &= mask;
bits &= -(bits < width);
return ((value << bits) | (value >> (width - bits))) & mask;
}

template<typename T>
NBL_CONSTEXPR_FUNC T rotr(T value, uint32_t bits, uint32_t width)
{
const T mask = (width >= sizeof(T) * 8) ? ~T(0) : ((T(1) << width) - T(1));
value &= mask;
bits &= -(bits < width);
return ((value >> bits) | (value << (width - bits))) & mask;
}

}
}

#endif
24 changes: 18 additions & 6 deletions include/nbl/builtin/hlsl/functional.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,23 @@ struct reference_wrapper : enable_if_t<
return lhs OP rhs; \
}

#define ALIAS_STD_CMP(NAME,OP) template<typename T NBL_STRUCT_CONSTRAINABLE > struct NAME { \
using type_t = T; \
\
bool operator()(NBL_CONST_REF_ARG(T) lhs, NBL_CONST_REF_ARG(T) rhs) \
{ \
return lhs OP rhs; \
}


#else // CPP

#define ALIAS_STD(NAME,OP) template<typename T> struct NAME : std::NAME<T> { \
using type_t = T;

#define ALIAS_STD_CMP(NAME,OP) template<typename T> struct NAME : std::NAME<T> { \
using type_t = T;

#endif

ALIAS_STD(bit_and,&)
Expand Down Expand Up @@ -136,14 +147,15 @@ ALIAS_STD(divides,/)
};


ALIAS_STD(equal_to, ==) };
ALIAS_STD(not_equal_to, !=) };
ALIAS_STD(greater, >) };
ALIAS_STD(less, <) };
ALIAS_STD(greater_equal, >=) };
ALIAS_STD(less_equal, <=) };
ALIAS_STD_CMP(equal_to, ==) };
ALIAS_STD_CMP(not_equal_to, !=) };
ALIAS_STD_CMP(greater, >) };
ALIAS_STD_CMP(less, <) };
ALIAS_STD_CMP(greater_equal, >=) };
ALIAS_STD_CMP(less_equal, <=) };

#undef ALIAS_STD
#undef ALIAS_STD_CMP

// The above comparison operators return bool on STD, but in HLSL they're supposed to yield bool vectors, so here's a specialization so that they return `vector<bool, N>` for vectorial types

Expand Down
2 changes: 1 addition & 1 deletion include/nbl/builtin/hlsl/ies/sampler.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ struct CandelaSampler
const angle_t vAngle = degrees(polar.theta);
const angle_t hAngle = degrees(__wrapPhi(polar.phi, symmetry));

#define NBL_IES_DEF_ANGLE_ACC(T, EXPR) struct T { using value_type = angle_t; accessor_t acc; value_type operator[](uint32_t idx) NBL_CONST_MEMBER_FUNC { return EXPR; } };
#define NBL_IES_DEF_ANGLE_ACC(T, EXPR) struct T { using value_type = angle_t; accessor_t acc; value_type operator[](uint32_t idx) NBL_CONST_MEMBER_FUNC { return EXPR; } void get(uint32_t idx, NBL_REF_ARG(value_type) val) NBL_CONST_MEMBER_FUNC { val = EXPR; } };

NBL_IES_DEF_ANGLE_ACC(VAcc, acc.vAngle(idx))
NBL_IES_DEF_ANGLE_ACC(HAcc, acc.hAngle(idx))
Expand Down
19 changes: 14 additions & 5 deletions include/nbl/builtin/hlsl/math/functions.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,22 @@ scalar_type_t<T> lpNorm(NBL_CONST_REF_ARG(T) v)


// valid only for `theta` in [-PI,PI]
template <typename T NBL_FUNC_REQUIRES(concepts::FloatingPointLikeScalar<T>)
// UseRealSinCos=true -> back-to-back sin + cos. Saturates the special-function pipeline, enables vendor sincos fusion, full precision near multiples of pi.
// UseRealSinCos=false -> cos + sqrt(1-c*c) with sign recovered from theta. Saves one special-function op when cos alone is cheaper than sin+cos, but suffers catastrophic cancellation as |c| -> 1.
template <typename T, bool UseRealSinCos = true NBL_FUNC_REQUIRES(concepts::FloatingPointLikeScalar<T>)
void sincos(T theta, NBL_REF_ARG(T) s, NBL_REF_ARG(T) c)
{
s = sin<T>(theta);
c = cos<T>(theta);
// s = sqrt<T>(T(NBL_FP64_LITERAL(1.0))-c*c);
// s = ieee754::flipSign(s, theta < T(NBL_FP64_LITERAL(0.0)));
if (UseRealSinCos)
{
s = sin<T>(theta);
c = cos<T>(theta);
}
else
{
c = cos<T>(theta);
s = sqrt<T>(T(NBL_FP64_LITERAL(1.0))-c*c);
s = ieee754::flipSign(s, theta < T(NBL_FP64_LITERAL(0.0)));
}
}

template <typename T NBL_FUNC_REQUIRES(vector_traits<T>::Dimension == 3)
Expand Down
Loading
Loading