Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
d3f4169
Add files via upload
nahiim Nov 7, 2022
95cc93f
Update animtation.hlsl
nahiim Nov 7, 2022
507b1a6
Update keyframe.hlsl
nahiim Nov 7, 2022
bcb9f77
Update node.hlsl
nahiim Nov 7, 2022
b9b29d2
Add files via upload
nahiim Nov 7, 2022
6d7e989
Delete animtation.hlsl
nahiim Nov 7, 2022
6c24d2c
Update node.hlsl
nahiim Nov 7, 2022
ef4f253
Add files via upload
nahiim Nov 7, 2022
b89cad1
Delete node.hlsl
nahiim Nov 7, 2022
c964e09
Add files via upload
nahiim Nov 7, 2022
bb088e9
Update keyframe.hlsl
nahiim Nov 7, 2022
2e65bbc
brdf
nahiim Nov 9, 2022
cc39ce3
geom smith
nahiim Nov 9, 2022
9f18406
fixed minor math blunder
nahiim Nov 9, 2022
bfc2143
...
nahiim Nov 9, 2022
c80b0e9
Shapes and ieee754
nahiim Nov 10, 2022
321b252
numeric_limits
nahiim Nov 10, 2022
b5d3a4c
colorspace_EOTF
nahiim Nov 11, 2022
4ecbd7c
colorspace completed
nahiim Nov 11, 2022
8eec0c0
fixed typos
nahiim Nov 12, 2022
e644e74
Create HLSL_NABLA_COMPILE_TEST target for compile-testing Nabla's new…
AnastaZIuk Nov 12, 2022
8135e46
Find a way to clean environment for clear DXC compilation, make sure …
AnastaZIuk Nov 13, 2022
4712763
link dxcompiler library to Nabla
AnastaZIuk Nov 13, 2022
a215ee3
add dxc as dependency of HLSL_NABLA_COMPILE_TEST
AnastaZIuk Nov 13, 2022
9dd660f
math
nahiim Nov 14, 2022
255f8e8
maths
nahiim Nov 14, 2022
42b19d7
Merge remote-tracking branch 'origin/hlsl' into local_hlsl
nahiim Nov 14, 2022
95e9e2d
Merge remote-tracking branch 'origin/dxcIntegration' into local_hlsl
nahiim Nov 14, 2022
f01eeee
minor fixes
nahiim Nov 15, 2022
cbf8d71
automated HLSL compilation
nahiim Nov 15, 2022
1990c18
complex and constants
nahiim Nov 17, 2022
953b681
math completed
nahiim Nov 21, 2022
7011441
shapes completed
nahiim Nov 23, 2022
a09b8ef
create random/xoroshiro.hlsl
nahiim Nov 24, 2022
d5e3189
porting hlsl/utils
nahiim Nov 29, 2022
b3a17c9
add hlsl/utils/culling
nahiim Dec 2, 2022
47c82ce
add morton, normal_encode, normal_decode, culling
nahiim Dec 6, 2022
f037e69
utils
nahiim Dec 7, 2022
5f70cca
surface_transform finishing
nahiim Dec 8, 2022
67b22f0
add utils/transform
nahiim Dec 9, 2022
9cfc8fb
update transform.hlsl
nahiim Dec 10, 2022
0efa057
utils, loader, property_pool, blit
nahiim Dec 31, 2022
9720334
Seems like all BRDF functions are ported to HLSL and compiling ok
Crisspl Mar 11, 2023
bb6ec81
ported bsdf functions to HLSL
Crisspl Mar 17, 2023
52589d2
Reworked & renamed bxdf functions to _quotient_and_pdf convention
Crisspl Mar 21, 2023
e2daa63
HLSL BxDF concepts design: common bxdf classes
Crisspl Mar 22, 2023
6853d83
HLSL BxDF concepts design: some work done on NDFs
Crisspl Mar 28, 2023
a49760c
Typo and missing create() for blinnphong
Crisspl Mar 29, 2023
758a390
Fresnels
Crisspl Mar 29, 2023
5e2bf89
Diffuse BxDFs
Crisspl Mar 29, 2023
915ef27
Generic CookTorrance BRDF implementation
Crisspl Mar 29, 2023
c81e7ab
Merge pull request #475 from Crisspl/local_hlsl
devshgraphicsprogramming Sep 19, 2023
cf68dd5
Delete include/nbl/builtin/hlsl/math/binary_operator_functions.hlsl
devshgraphicsprogramming Sep 19, 2023
2b9f418
Update complex.hlsl
devshgraphicsprogramming Sep 19, 2023
0b5adfa
Resolved conflicts
Przemog1 Sep 20, 2023
1a87eb3
Merge branch 'type_traits' of https://github.com/Devsh-Graphics-Progr…
Przemog1 Sep 21, 2023
011af04
Merge branch 'master' of https://github.com/Devsh-Graphics-Programmin…
Przemog1 Sep 23, 2023
0f44f7c
Deleted xoutput (#554)
Przemog1 Sep 29, 2023
2fa14cf
Resolved conflicts
Przemog1 Oct 11, 2023
5190699
Deleted old files
Przemog1 Oct 11, 2023
b8a4bdd
Merge pull request #566 from Devsh-Graphics-Programming/give_credit_new
Przemog1 Oct 17, 2023
03f876e
Resolved conflicts
Przemog1 Oct 17, 2023
7eab08e
Resolved conflicts
Przemog1 Oct 17, 2023
4bb3160
Merge pull request #569 from Devsh-Graphics-Programming/give_credit_new
Przemog1 Oct 17, 2023
ae47657
remove BxDF stuff that's been rewritten since
Sep 13, 2025
57ecc75
remove more stuff redone on other branches
Sep 13, 2025
02630e6
Merge branch 'master' into give_credit
Sep 13, 2025
989f5d9
remove one more duplicate/rewritten file
Sep 13, 2025
3193d41
and remove some more duplicates
Sep 13, 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
1 change: 1 addition & 0 deletions 3rdparty/EGL
Submodule EGL added at 9eeb49
1 change: 1 addition & 0 deletions 3rdparty/SPIRV-Headers
Submodule SPIRV-Headers added at b8047f
1 change: 1 addition & 0 deletions 3rdparty/SPIRV-Tools
Submodule SPIRV-Tools added at 75e53b
1 change: 1 addition & 0 deletions 3rdparty/radeonrays
Submodule radeonrays added at e42145
132 changes: 132 additions & 0 deletions include/nbl/builtin/hlsl/math/complex.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@

// Copyright (C) 2018-2023 - 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_MATH_COMPLEX_INCLUDED_
#define _NBL_BUILTIN_HLSL_MATH_COMPLEX_INCLUDED_

#include <nbl/builtin/hlsl/math/constants.hlsl>


namespace nbl
{
namespace hlsl
{
namespace math
{


template<typename vector_t>
struct complex_t
{
// TODO: do it properly as an `exp` and `exp2` overload/shadow func
complex_t<vector_t> expImaginary(in float _theta)
{
complex_t<vector_t> result;
result.real = cos(_theta);
result.imaginary = sin(_theta);
return result;
}

complex_t<vector_t> operator+(const complex_t<vector_t> other)
{
complex_t<vector_t> result;
result.real = real + other.real;
result.imaginary = imaginary + other.imaginary;
return result;
}

complex_t<vector_t> operator-(const complex_t<vector_t> other)
{
complex_t<vector_t> result;
result.real = real - other.real;
result.imaginary = imaginary - other.imaginary;
return result;
}

complex_t<vector_t> operator*(const complex_t<vector_t> other)
{
complex_t<vector_t> result;
result.real = real * other.real - imaginary * other.imaginary;
result.imaginary = real * other.real + imaginary * other.imaginary;
return result;
}

complex_t<vector_t> conjugate()
{
complex_t<vector_t> result;
result.real = real;
result.imaginary = -imaginary;
return result;
}

vector_t real, imaginary;
};


// TODO: move to its own header
namespace fft
{

template<typename scalar_t>
complex_t<scalar_t> twiddle(in uint k, in float N)
{
complex_t<scalar_t> retval;
retval.x = cos(-2.f*PI*float(k)/N);
retval.y = sqrt(1.f-retval.x*retval.x); // twiddle is always half the range, so no conditional -1.f needed
return retval;
}

template<typename scalar_t>
complex_t<scalar_t> twiddle(in uint k, in uint logTwoN)
{
return twiddle<scalar_t>(k,float(1u<<logTwoN));
}

template<typename scalar_t>
complex_t<scalar_t> twiddle(in bool is_inverse, in uint k, in float N)
{
complex_t<scalar_t> twiddle = twiddle(k,N);
if (is_inverse)
return twiddle.conjugate;
return twiddle;
}

template<typename scalar_t>
complex_t<scalar_t> twiddle(in bool is_inverse, in uint k, in uint logTwoN)
{
return twiddle<scalar_t>(is_inverse,k,float(1u<<logTwoN));
}



// decimation in time
template<typename scalar_t, typename vector_t>
void DIT_radix2(in complex_t<scalar_t> twiddle, inout complex_t<vector_t> lo, inout complex_t<vector_t> hi)
{
complex_t<vector_t> wHi = hi * twiddle;
hi = lo-wHi;
lo += wHi;
}

// decimation in frequency
template<typename scalar_t, typename vector_t>
void DIF_radix2(in complex_t<scalar_t> twiddle, inout complex_t<vector_t> lo, inout complex_t<vector_t> hi)
{
complex_t<vector_t> diff = lo-hi;
lo += hi;
hi = diff * twiddle;
}


}

// TODO: radices 4,8 and 16

}
}
}



#endif
104 changes: 104 additions & 0 deletions include/nbl/builtin/hlsl/math/quaternions.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@

// Copyright (C) 2018-2022 - 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_GLSL_MATH_QUATERNIONS_INCLUDED_
#define _NBL_BUILTIN_GLSL_MATH_QUATERNIONS_INCLUDED_


namespace nbl
{
namespace hlsl
{
namespace math
{


struct quaternion_t
{
float4 data;


static quaternion_t constructFromTruncated(in float3 first3Components)
{
quaternion_t quat;
quat.data.xyz = first3Components;
quat.data.w = sqrt(1.0-dot(first3Components,first3Components));
return quat;
}

static quaternion_t lerp(in quaternion_t start, in quaternion_t end, in float fraction, in float totalPseudoAngle)
{
const uint negationMask = asuint(totalPseudoAngle) & 0x80000000u;
const float4 adjEnd = asfloat(asuint(end.data)^negationMask);

quaternion_t quat;
quat.data = lerp(start.data, adjEnd, fraction);
return quat;
}
static quaternion_t lerp(in quaternion_t start, in quaternion_t end, in float fraction)
{
return lerp(start,end,fraction,dot(start.data,end.data));
}

static float flerp_impl_adj_interpolant(in float angle, in float fraction, in float interpolantPrecalcTerm2, in float interpolantPrecalcTerm3)
{
const float A = 1.0904f + angle * (-3.2452f + angle * (3.55645f - angle * 1.43519f));
const float B = 0.848013f + angle * (-1.06021f + angle * 0.215638f);
const float k = A * interpolantPrecalcTerm2 + B;
return fraction+interpolantPrecalcTerm3*k;
}

static quaternion_t flerp(in quaternion_t start, in quaternion_t end, in float fraction)
{
const float pseudoAngle = dot(start.data,end.data);

const float interpolantPrecalcTerm = fraction-0.5f;
const float interpolantPrecalcTerm3 = fraction*interpolantPrecalcTerm*(fraction-1.f);
const float adjFrac = quaternion_t::flerp_impl_adj_interpolant(abs(pseudoAngle),fraction,interpolantPrecalcTerm*interpolantPrecalcTerm,interpolantPrecalcTerm3);
quaternion_t quat = quaternion_t::lerp(start,end,adjFrac,pseudoAngle);
quat.data = normalize(quat.data);
return quat;
}

static float3x3 constructMatrix(in quaternion_t quat)
{
float3x3 mat;
mat[0] = quat.data.yzx*quat.data.ywz+quat.data.zxy*quat.data.zyw*float3( 1.f, 1.f,-1.f);
mat[1] = quat.data.yzx*quat.data.xzw+quat.data.zxy*quat.data.wxz*float3(-1.f, 1.f, 1.f);
mat[2] = quat.data.yzx*quat.data.wyx+quat.data.zxy*quat.data.xwy*float3( 1.f,-1.f, 1.f);
mat[0][0] = 0.5f-mat[0][0];
mat[1][1] = 0.5f-mat[1][1];
mat[2][2] = 0.5f-mat[2][2];
mat *= 2.f;
return mat;
}
};

float3 slerp_delta_impl(in float3 start, in float3 preScaledWaypoint, in float cosAngleFromStart)
{
float3 planeNormal = cross(start,preScaledWaypoint);

cosAngleFromStart *= 0.5;
const float sinAngle = sqrt(0.5-cosAngleFromStart);
const float cosAngle = sqrt(0.5+cosAngleFromStart);

planeNormal *= sinAngle;
const float3 precompPart = cross(planeNormal,start)*2.0;

return precompPart*cosAngle+cross(planeNormal,precompPart);
}

float3 slerp_impl_impl(in float3 start, in float3 preScaledWaypoint, in float cosAngleFromStart)
{
return start + slerp_delta_impl(start,preScaledWaypoint,cosAngleFromStart);
}



}
}
}
Comment on lines +2 to +102
Copy link
Member Author

Choose a reason for hiding this comment

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

@kevyuu @keptsecret this file might be useful to you, but I can't guarantee correctness, so rewrite anyway but look at the ideas.


#endif
Loading
Loading