Skip to content

Conversation

@Przemog1
Copy link
Contributor

No description provided.

Comment on lines +9 to 13
#include <vectorSIMD.h>
#include <nbl/builtin/hlsl/cpp_compat/matrix.hlsl>

#include "ISceneNode.h"
#include "matrixutil.h"

Choose a reason for hiding this comment

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

no need to touch this file, its dead code

#include "line3d.h"
#include "matrix4SIMD.h"
#include "position2d.h"
#include "quaternion.h"

Choose a reason for hiding this comment

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

merge #960 into your branch and nuke the quaternion.h as well

Comment on lines -224 to +230
core::matrix3x4SIMD transform = core::matrix3x4SIMD();
hlsl::float32_t3x4 transform = hlsl::float32_t3x4();
Instance<blas_ref_t> base = {};
};
template<typename blas_ref_t>
struct MatrixMotionInstance final
{
core::matrix3x4SIMD transform[2] = {core::matrix3x4SIMD(),core::matrix3x4SIMD()};
hlsl::float32_t3x4 transform[2] = {hlsl::float32_t3x4(),hlsl::float32_t3x4()};

Choose a reason for hiding this comment

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

did you test the acceleration structure examples ? 67 and 71 ?

Comment on lines +1 to +51
#ifndef _NBL_BUILTIN_HLSL_CAMERA_VIEW_MATRIX_INCLUDED_
#define _NBL_BUILTIN_HLSL_CAMERA_VIEW_MATRIX_INCLUDED_

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

namespace nbl
{
namespace hlsl
{

// /Arek: glm:: for normalize till dot product is fixed (ambiguity with glm namespace + linker issues)
template<typename T>
inline matrix<T, 3, 4> buildCameraLookAtMatrixLH(
const vector<T, 3>& position,
const vector<T, 3>& target,
const vector<T, 3>& upVector)
{
const vector<T, 3> zaxis = hlsl::normalize(target - position);
const vector<T, 3> xaxis = hlsl::normalize(hlsl::cross(upVector, zaxis));
const vector<T, 3> yaxis = hlsl::cross(zaxis, xaxis);

matrix<T, 3, 4> r;
r[0] = vector<T, 4>(xaxis, -hlsl::dot(xaxis, position));
r[1] = vector<T, 4>(yaxis, -hlsl::dot(yaxis, position));
r[2] = vector<T, 4>(zaxis, -hlsl::dot(zaxis, position));

return r;
}

template<typename T>
inline matrix<T, 3, 4> buildCameraLookAtMatrixRH(
const vector<T, 3>& position,
const vector<T, 3>& target,
const vector<T, 3>& upVector)
{
const vector<T, 3> zaxis = hlsl::normalize(position - target);
const vector<T, 3> xaxis = hlsl::normalize(hlsl::cross(upVector, zaxis));
const vector<T, 3> yaxis = hlsl::cross(zaxis, xaxis);

matrix<T, 3, 4> r;
r[0] = vector<T, 4>(xaxis, -hlsl::dot(xaxis, position));
r[1] = vector<T, 4>(yaxis, -hlsl::dot(yaxis, position));
r[2] = vector<T, 4>(zaxis, -hlsl::dot(zaxis, position));

return r;
}

}
}

#endif No newline at end of file

Choose a reason for hiding this comment

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

Comment on lines +1 to +12
#ifndef _NBL_BUILTIN_HLSL_CPP_COMPAT_UNROLL_INCLUDED_
#define _NBL_BUILTIN_HLSL_CPP_COMPAT_UNROLL_INCLUDED_

#ifdef __HLSL_VERSION
#define NBL_UNROLL [unroll]
#define NBL_UNROLL_LIMITED(LIMIT) [unroll(LIMIT)]
#else
#define NBL_UNROLL // can't be bothered / TODO
#define NBL_UNROLL_LIMITED(LIMIT)
#endif

#endif

Choose a reason for hiding this comment

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

its already in

#define NBL_UNROLL [[unroll]]

Choose a reason for hiding this comment

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

can add the LIMITED there

Comment on lines +1 to +96
// Copyright (C) 2019 - DevSH Graphics Programming Sp. z O.O.
// This file is part of the "Nabla Engine" and was originally part of the "Irrlicht Engine"
// For conditions of distribution and use, see copyright notice in nabla.h
// See the original file in irrlicht source for authors

#ifndef _NBL_BUILTIN_HLSL_MATH_QUATERNION_INCLUDED_
#define _NBL_BUILTIN_HLSL_MATH_QUATERNION_INCLUDED_

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

namespace nbl
{
namespace hlsl
{

//! Quaternion class for representing rotations.
/** It provides cheap combinations and avoids gimbal locks.
Also useful for interpolations. */

template<typename float_t>
struct quaternion
{
// i*data[0] + j*data[1] + k*data[2] + data[3]
using vec_t = vector<float_t, 4>;
vector<float_t, 4> data;

//! creates identity quaternion
static inline quaternion create()
{
quaternion q;
q.data = vector<float_t, 4>(0.0f, 0.0f, 0.0f, 1.0f);

return q;
}

static inline quaternion create(float_t x, float_t y, float_t z, float_t w)
{
quaternion q;
q.data = vector<float_t, 4>(x, y, z, w);

return q;
}

static inline quaternion create(NBL_CONST_REF_ARG(quaternion) other)
{
return other;
}

static inline quaternion create(float_t pitch, float_t yaw, float_t roll)
{
const float rollDiv2 = roll * 0.5f;
const float sr = sinf(rollDiv2);
const float cr = cosf(rollDiv2);

const float pitchDiv2 = pitch * 0.5f;
const float sp = sinf(pitchDiv2);
const float cp = cosf(pitchDiv2);

const float yawDiv2 = yaw * 0.5f;
const float sy = sinf(yawDiv2);
const float cy = cosf(yawDiv2);

quaternion<float_t> output;
output.data[0] = cr * sp * cy + sr * cp * sy; // x
output.data[1] = cr * cp * sy - sr * sp * cy; // y
output.data[2] = sr * cp * cy - cr * sp * sy; // z
output.data[3] = cr * cp * cy + sr * sp * sy; // w

return output;
}

// TODO:
//explicit quaternion(NBL_CONST_REF_ARG(float32_t3x4) m) {}

inline quaternion operator*(float_t scalar)
{
quaternion output;
output.data = data * scalar;
return output;
}

inline quaternion operator*(NBL_CONST_REF_ARG(quaternion) other)
{
return quaternion::create(
data.w * other.data.w - data.x * other.x - data.y * other.data.y - data.z * other.data.z,
data.w * other.data.x + data.x * other.w + data.y * other.data.z - data.z * other.data.y,
data.w * other.data.y - data.x * other.z + data.y * other.data.w + data.z * other.data.x,
data.w * other.data.z + data.x * other.y - data.y * other.data.x + data.z * other.data.w
);
}
};

} // end namespace core
} // nbl

#endif

Choose a reason for hiding this comment

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

let #960 overwrite your changes

Comment on lines +1 to +24
// Copyright (C) 2019 - DevSH Graphics Programming Sp. z O.O.
// This file is part of the "Nabla Engine" and was originally part of the "Irrlicht Engine"
// For conditions of distribution and use, see copyright notice in nabla.h
// See the original file in irrlicht source for authors

#ifndef _NBL_BUILTIN_HLSL_MATH_QUATERNION_IMPL_INCLUDED_
#define _NBL_BUILTIN_HLSL_MATH_QUATERNION_IMPL_INCLUDED_

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

namespace nbl
{
namespace hlsl
{

namespace quaternion_impl
{

}

} // end namespace core
} // nbl

#endif

Choose a reason for hiding this comment

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

there's no need for this file then

matrix3x4SIMD inv;
_mat.getInverse(inv);
hlsl::float32_t4x4 inv = hlsl::getMatrix3x4As4x4<hlsl::float32_t>(_mat);
hlsl::inverse(inv);

Choose a reason for hiding this comment

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

inverse is not in-place, you need to do const hlsl::float32_t4x4 inv = inverse(linalg::promote(_mat))

vectorSIMDf normal(_in.getNormal());
// transform by inverse transpose
return plane3dSIMDf(inv.rows[0]*normal.xxxx()+inv.rows[1]*normal.yyyy()+inv.rows[2]*normal.zzzz()+(normal.wwww()&BUILD_MASKF(0,0,0,1)));
hlsl::float32_t4 planeEq = inv[0] * hlsl::float32_t4(normal.x) + inv[1] * hlsl::float32_t4(normal.y) + inv[2] * hlsl::float32_t4(normal.z) + (hlsl::float32_t4(0, 0, 0, normal.w));

Choose a reason for hiding this comment

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

use swizzles instead of counting on promotions from constructors

Comment on lines 58 to +60
#define vec4 core::vectorSIMDf
#define mat4 core::matrix4SIMD
#define mat4x3 core::matrix3x4SIMD
#define mat4 hlsl::float32_t4x4
#define mat4x3 hlsl::float32_t3x4

Choose a reason for hiding this comment

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

don't touch this to reduce conflicts with #946

Comment on lines 301 to 314
template<> struct SPropertyElementData::get_typename<SPropertyElementData::Type::BLACKBODY>
{ using type = void; };
template<> struct SPropertyElementData::get_typename<SPropertyElementData::Type::MATRIX>
{ using type = core::matrix4SIMD; };
{ using type = hlsl::float32_t4x4; };
template<> struct SPropertyElementData::get_typename<SPropertyElementData::Type::TRANSLATE>
{ using type = core::matrix4SIMD; };
{ using type = hlsl::float32_t4x4; };
template<> struct SPropertyElementData::get_typename<SPropertyElementData::Type::ROTATE>
{ using type = core::matrix4SIMD; };
{ using type = hlsl::float32_t4x4; };
template<> struct SPropertyElementData::get_typename<SPropertyElementData::Type::SCALE>
{ using type = core::matrix4SIMD; };
{ using type = hlsl::float32_t4x4; };
template<> struct SPropertyElementData::get_typename<SPropertyElementData::Type::LOOKAT>
{ using type = core::matrix4SIMD; };
{ using type = hlsl::float32_t4x4; };
template<> struct SPropertyElementData::get_typename<SPropertyElementData::Type::INVALID>
{ using type = void; };

Choose a reason for hiding this comment

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

undo all changes to nbl/ext/MitsubaLoader because it will badly conflict with my #937

Comment on lines +22 to +29
NBL_UNROLL_LIMITED(4)
for (uint32_t i = 0; i < matrix_traits<MatT>::RowCount; ++i)
NBL_UNROLL_LIMITED(4)
for (uint32_t j = 0; j < matrix_traits<MatT>::ColumnCount; ++j)
output[i][j] = 0;

NBL_UNROLL_LIMITED(4)
for (uint32_t diag = 0; diag < matrix_traits<MatT>::RowCount; ++diag)

Choose a reason for hiding this comment

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

use regular unroll in such situations, it works better

Choose a reason for hiding this comment

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

write it similarly in construction to

matrix<T, NOut, MOut> promote_affine(const matrix<T, NIn, MIn> inMatrix)

set entire rows

Comment on lines +1 to +15
#ifndef _NBL_BUILTIN_HLSL_MATRIX_UTILS_TRANSFORMATION_MATRIX_UTILS_INCLUDED_
#define _NBL_BUILTIN_HLSL_MATRIX_UTILS_TRANSFORMATION_MATRIX_UTILS_INCLUDED_
#include <nbl/builtin/hlsl/math/quaternion/quaternion.hlsl>
// TODO: remove this header when deleting vectorSIMDf.hlsl
#ifndef __HLSL_VERSION
#include <nbl/core/math/glslFunctions.h>
#include "vectorSIMD.h"
#endif
#include <nbl/builtin/hlsl/matrix_utils/matrix_traits.hlsl>
#include "nbl/builtin/hlsl/cpp_compat/unroll.hlsl"

namespace nbl
{
namespace hlsl
{

Choose a reason for hiding this comment

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

add everything here to nbl::hlsl::math::linalg namespace and folder

{

template<typename MatT>
MatT diagonal(float diagonal = 1)

Choose a reason for hiding this comment

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

diagonal should be of matrix type's scalar type

also fix up matrix_traits to not have a default spec (also bug 7007 is fixed and you can remove the macro)

Comment on lines +70 to +78
template<int N, int M>
inline matrix<float64_t, N, M> getAs64BitPrecisionMatrix(NBL_CONST_REF_ARG(matrix<float32_t, N, M>) mat)
{
matrix<float64_t, N, M> output;
for (int i = 0; i < N; ++i)
output[i] = mat[i];

return output;
}

Choose a reason for hiding this comment

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

this should be a _static_cast_helper spec - cast equal rank matrices to each other with different types

Comment on lines +43 to +52
template<typename T>
inline matrix<T, 4, 4> getMatrix3x4As4x4(NBL_CONST_REF_ARG(matrix<T, 3, 4>) mat)
{
matrix<T, 4, 4> output;
for (int i = 0; i < 3; ++i)
output[i] = mat[i];
output[3] = float32_t4(0.0f, 0.0f, 0.0f, 1.0f);

return output;
}
Copy link
Member

@devshgraphicsprogramming devshgraphicsprogramming Dec 3, 2025

Choose a reason for hiding this comment

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

Comment on lines +54 to +68
template<typename T>
inline matrix<T, 3, 4> extractSub3x4From4x4Matrix(NBL_CONST_REF_ARG(matrix<T, 4, 4>) mat)
{
matrix<T, 3, 4> output;
for (int i = 0; i < 3; ++i)
output[i] = mat[i];

return output;
}

template<typename T, int N>
inline matrix<T, 3, 3> getSub3x3(NBL_CONST_REF_ARG(matrix<T, N, 4>) mat)
{
return matrix<T, 3, 3>(mat);
}

Choose a reason for hiding this comment

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

make a specialization of truncate for matrices

Comment on lines +80 to +108
namespace transformation_matrix_utils_impl
{
// This function calculates determinant using the scalar triple product.
template<typename T>
inline T determinant_helper(NBL_CONST_REF_ARG(matrix<T, 3, 3>) mat, NBL_REF_ARG(vector<T, 3>) r1crossr2)
{
r1crossr2 = hlsl::cross(mat[1], mat[2]);
return hlsl::dot(mat[0], r1crossr2);
}
}

//! returs adjugate of the cofactor (sub 3x3) matrix
template<typename T, int N, int M>
inline matrix<T, 3, 3> getSub3x3TransposeCofactors(NBL_CONST_REF_ARG(matrix<T, N, M>) mat)
{
static_assert(N >= 3 && M >= 3);

matrix<T, 3, 3> output;
vector<T, 3> row0 = vector<T, 3>(mat[0]);
vector<T, 3> row1 = vector<T, 3>(mat[1]);
vector<T, 3> row2 = vector<T, 3>(mat[2]);
output[0] = hlsl::cross(row1, row2);
output[1] = hlsl::cross(row2, row0);
output[2] = hlsl::cross(row0, row1);

output[0] = hlsl::cross(row0, row1);

return output;
}

Choose a reason for hiding this comment

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

It already exists

// useful for fast computation of a Normal Matrix
template<typename T, int N>
struct cofactors_base;
template<typename T>
struct cofactors_base<T,3>
{
using matrix_t = matrix<T,3,3>;
using vector_t = vector<T,3>;
static inline cofactors_base<T,3> create(NBL_CONST_REF_ARG(matrix_t) val)
{
cofactors_base<T,3> retval;
retval.transposed = matrix_t(
hlsl::cross<vector_t>(val[1],val[2]),
hlsl::cross<vector_t>(val[2],val[0]),
hlsl::cross<vector_t>(val[0],val[1])
);
return retval;
}
//
inline matrix_t get() NBL_CONST_MEMBER_FUNC
{
return hlsl::transpose<matrix_t>(transposed);
}
//
inline vector_t normalTransform(const vector_t n) NBL_CONST_MEMBER_FUNC
{
const vector_t tmp = hlsl::mul<matrix_t,vector_t>(transposed,n);
return hlsl::normalize<vector_t>(tmp);
}
matrix_t transposed;
};
// variant that cares about flipped/mirrored transforms
template<typename T, int N>
struct cofactors
{
using pseudo_base_t = cofactors_base<T,N>;
using matrix_t = typename pseudo_base_t::matrix_t;
using vector_t = typename pseudo_base_t::vector_t;
using mask_t = unsigned_integer_of_size_t<sizeof(T)>;
static inline cofactors<T,3> create(NBL_CONST_REF_ARG(matrix_t) val)
{
cofactors<T,3> retval;
retval.composed = pseudo_base_t::create(val);
const T det = hlsl::dot<vector_t>(val[0],retval.composed.transposed[0]);
const mask_t SignBit = 1;
SignBit = SignBit<<(sizeof(mask_t)*8-1);
retval.signFlipMask = bit_cast<mask_t>(det) & SignBit;
return retval;
}
//
inline vector_t normalTransform(const vector_t n) NBL_CONST_MEMBER_FUNC
{
const vector_t tmp = hlsl::mul<matrix_t,vector_t>(composed.transposed,n);
const T rcpLen = hlsl::rsqrt<T>(hlsl::dot<vector_t>(tmp,tmp));
return tmp*bit_cast<T>(bit_cast<mask_t>(rcpLen)^determinantSignMask);
}
cofactors_base<T,N> composed;
mask_t determinantSignMask;
};

Comment on lines +153 to +181
//! Replaces curent rocation and scale by rotation represented by quaternion `quat`, leaves 4th row and 4th colum unchanged
template<typename T, int N>
inline void setRotation(NBL_REF_ARG(matrix<T, N, 4>) outMat, NBL_CONST_REF_ARG(nbl::hlsl::quaternion<T>) quat)
{
// TODO
//static_assert(N == 3 || N == 4);

outMat[0] = vector<T, 4>(
1 - 2 * (quat.data.y * quat.data.y + quat.data.z * quat.data.z),
2 * (quat.data.x * quat.data.y - quat.data.z * quat.data.w),
2 * (quat.data.x * quat.data.z + quat.data.y * quat.data.w),

outMat[0][3]
);

outMat[1] = vector<T, 4>(
2 * (quat.data.x * quat.data.y + quat.data.z * quat.data.w),
1 - 2 * (quat.data.x * quat.data.x + quat.data.z * quat.data.z),
2 * (quat.data.y * quat.data.z - quat.data.x * quat.data.w),
outMat[1][3]
);

outMat[2] = vector<T, 4>(
2 * (quat.data.x * quat.data.z - quat.data.y * quat.data.w),
2 * (quat.data.y * quat.data.z + quat.data.x * quat.data.w),
1 - 2 * (quat.data.x * quat.data.x + quat.data.y * quat.data.y),
outMat[2][3]
);
}

Choose a reason for hiding this comment

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

gets replaces by #960

Choose a reason for hiding this comment

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

if you need a function that overwrites a square submatrix, add it to https://github.com/Devsh-Graphics-Programming/Nabla/blob/master/include/nbl/builtin/hlsl/math/linalg/transform.hlsl

and call its submatrixReplace

Comment on lines +183 to +192
template<typename T, int N>
inline void setTranslation(NBL_REF_ARG(matrix<T, N, 4>) outMat, NBL_CONST_REF_ARG(vector<T, 3>) translation)
{
// TODO
// static_assert(N == 3 || N == 4);

outMat[0].w = translation.x;
outMat[1].w = translation.y;
outMat[2].w = translation.z;
}

Choose a reason for hiding this comment

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

Choose a reason for hiding this comment

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

also generalize it to any matrix<T,N,N+1> matrix and vector<T,N>, what you have now will only work for 3x4

Comment on lines +129 to +140
// TODO: use portable_float when merged
//! multiplies matrices a and b, 3x4 matrices are treated as 4x4 matrices with 4th row set to (0, 0, 0 ,1)
template<typename T>
inline matrix<T, 3, 4> concatenateBFollowedByA(NBL_CONST_REF_ARG(matrix<T, 3, 4>) a, NBL_CONST_REF_ARG(matrix<T, 3, 4>) b)
{
// TODO
// static_assert(N == 3 || N == 4);

const matrix<T, 4, 4> a4x4 = getMatrix3x4As4x4<hlsl::float32_t>(a);
const matrix<T, 4, 4> b4x4 = getMatrix3x4As4x4<hlsl::float32_t>(b);
return matrix<T, 3, 4>(mul(a4x4, b4x4));
}

Choose a reason for hiding this comment

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

already exists as

matrix<T,N,M> promoted_mul(NBL_CONST_REF_ARG(matrix<T,N,P>) lhs, NBL_CONST_REF_ARG(matrix<T,Q,M>) rhs)

Comment on lines +110 to +127
template<typename T, int N>
inline bool getSub3x3InverseTranspose(NBL_CONST_REF_ARG(matrix<T, N, 4>) matIn, NBL_CONST_REF_ARG(matrix<T, 3, 3>) matOut)
{
matrix<T, 3, 3> matIn3x3 = getSub3x3(matIn);
vector<T, 3> r1crossr2;
T d = transformation_matrix_utils_impl::determinant_helper(matIn3x3, r1crossr2);
if (abs(d) <= FLT_MIN)
return false;
auto rcp = T(1.0f)/d;

// matrix of cofactors * 1/det
matOut = getSub3x3TransposeCofactors(matIn3x3);
matOut[0] *= rcp;
matOut[1] *= rcp;
matOut[2] *= rcp;

return true;
}

Choose a reason for hiding this comment

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

this probalby exists somewhere already

Comment on lines +142 to +151
template<typename T, int N>
inline void setScale(NBL_REF_ARG(matrix<T, N, 4>) outMat, NBL_CONST_REF_ARG(vector<T, 3>) scale)
{
// TODO
// static_assert(N == 3 || N == 4);

outMat[0][0] = scale[0];
outMat[1][1] = scale[1];
outMat[2][2] = scale[2];
}

Choose a reason for hiding this comment

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

this is not correct, the scale in a matrix is defined by the length of its column vectors (think about what happens when you right-multiply a pre-scale)

M S v // S is diagonal

so any scale "reset" needs to grab each column, and do

column *= newScale*inversesqrt(dot(column,column));

Comment on lines +1 to +21
#ifndef _NBL_BUILTIN_HLSL_VECTOR_UTILS_VECTOR_UTILS_INCLUDED_
#define _NBL_BUILTIN_HLSL_VECTOR_UTILS_VECTOR_UTILS_INCLUDED_

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

namespace nbl
{
namespace hlsl
{

// TODO: why cant I NBL_CONST_REF_ARG(vector<T, N>)
template<typename T, uint32_t N>
inline T lengthsquared(vector<T, N> vec)
{
return dot(vec, vec);
}

}
}

#endif No newline at end of file

Choose a reason for hiding this comment

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

It already exists and is just

scalar_type_t<T> lpNormPreroot(NBL_CONST_REF_ARG(T) v)

Comment on lines +1 to +10
#ifndef _NBL_BUILTIN_HLSL_PROJECTION_PROJECTION_INCLUDED_
#define _NBL_BUILTIN_HLSL_PROJECTION_PROJECTION_INCLUDED_

#include <nbl/builtin/hlsl/cpp_compat.hlsl>
#include <nbl/builtin/hlsl/concepts.hlsl>

namespace nbl
{
namespace hlsl
{
Copy link
Member

@devshgraphicsprogramming devshgraphicsprogramming Dec 4, 2025

Choose a reason for hiding this comment

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

move into math, just name the file nbl/builtin/hlsl/math/thin_lens_projection.hlsl

{
namespace hlsl
{
// TODO: use glm instead for c++

Choose a reason for hiding this comment

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

actually no, keep it identical between C++ and HLSL, less chance for bugs

{
// TODO: use glm instead for c++
template<typename FloatingPoint NBL_FUNC_REQUIRES(concepts::FloatingPoint<FloatingPoint>)
inline matrix<FloatingPoint, 4, 4> buildProjectionMatrixPerspectiveFovRH(FloatingPoint fieldOfViewRadians, FloatingPoint aspectRatio, FloatingPoint zNear, FloatingPoint zFar)

Choose a reason for hiding this comment

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

drop buildProjectionMatrixPerspective from the name, use a nbl::hlsl::math::thin_lens namespace instead and let the name be rhPerspectiveFovMatrix, likewise fo the other functions

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