Skip to content

Commit aa9539c

Browse files
committed
merge master, fix conflicts
2 parents dcdae1b + f5bba61 commit aa9539c

45 files changed

Lines changed: 1241 additions & 591 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cmake/common.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,13 +1206,14 @@ struct DeviceConfigCaps
12061206
-enable-16bit-types
12071207
-Zpr
12081208
-spirv
1209+
-Wno-local-type-template-args
12091210
-fspv-target-env=vulkan1.3
12101211
-Wshadow
12111212
-Wconversion
12121213
-Wno-local-type-template-args
12131214
$<$<CONFIG:Debug>:-O0>
12141215
$<$<CONFIG:Release>:-O3>
1215-
$<$<CONFIG:RelWithDebInfo>:-O3>
1216+
$<$<CONFIG:RelWithDebInfo>:-O3>
12161217
)
12171218

12181219
if(NSC_DEBUG_EDIF_FILE_BIT)
@@ -1599,7 +1600,6 @@ namespace @IMPL_NAMESPACE@ {
15991600
NBL_SPIRV_BINARY_DIR "${IMPL_BINARY_DIR}"
16001601
NBL_SPIRV_ACCESS_KEY "${FINAL_KEY_REL_PATH}"
16011602
)
1602-
16031603
set_property(TARGET ${IMPL_TARGET} APPEND PROPERTY NBL_SPIRV_OUTPUTS "${TARGET_OUTPUT}")
16041604
return()
16051605
endif()

examples_tests

Submodule examples_tests updated 58 files

include/nbl/asset/asset.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,6 @@
6868
#include "nbl/asset/metadata/CMTLMetadata.h"
6969
#include "nbl/asset/metadata/CPLYMetadata.h"
7070
#include "nbl/asset/metadata/CSTLMetadata.h"
71-
//#include "nbl/asset/metadata/CIESProfileMetadata.h"
71+
#include "nbl/asset/metadata/CIESProfileMetadata.h"
7272

7373
#endif

include/nbl/asset/utils/CGeometryCreator.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,15 @@ class NBL_API2 CGeometryCreator final : public core::IReferenceCounted
115115
\param subdivision Specifies subdivision level of the icosphere.
116116
\param smooth Specifies whether vertecies should be built for smooth or flat shading.
117117
*/
118-
119118
core::smart_refctd_ptr<ICPUPolygonGeometry> createIcoSphere(float radius=1.f, uint32_t subdivision=1, bool smooth=false) const;
120119

120+
//! Create a grid geometry
121+
/**
122+
No vertex buffer, only index in triangle strip topology without reset, "snake" with degenerates
123+
\param "resolution" Specifies resolution of grid
124+
*/
125+
core::smart_refctd_ptr<ICPUPolygonGeometry> createGrid(const hlsl::uint16_t2 resolution = { 128u, 128u }) const;
126+
121127
private:
122128
SCreationParams m_params;
123129
};

include/nbl/asset/utils/CQuantQuaternionCache.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88

99
#include "nbl/asset/utils/CDirQuantCacheBase.h"
10+
#include "nbl/builtin/hlsl/math/quaternions.hlsl"
1011

1112

1213
namespace nbl
@@ -68,4 +69,4 @@ class CQuantQuaternionCache : public CDirQuantCacheBase<impl::Projection,impl::Q
6869

6970
}
7071
}
71-
#endif
72+
#endif

include/nbl/builtin/glsl/ies/functions.glsl

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,33 @@
66

77
#include <nbl/builtin/glsl/math/constants.glsl>
88

9-
// TODO: implement proper mirroing
10-
// MIRROR_180_BITS = 0b001, Last Angle is 180, so map V slightly differently
11-
// MIRROR_90_BITS = 0b010, Last Angle is 90, so map both U and V slightly differently
12-
// ISOTROPIC_BITS = 0b011, texture to sample is Nx1, pretend v=middle always
13-
// FULL_THETA_BIT = 0b100, handle extended domain and rotate by 45 degrees for anisotropic
14-
15-
vec2 nbl_glsl_IES_convert_dir_to_uv(vec3 dir) {
16-
float sum = dot(vec3(1.0f), abs(dir));
9+
// TODO: when rewriting to HLSL this is not IES namespace or folder, this should be octahedral mapping sitting somewhere where the spherical/polar sits
10+
// NOTE: I changed it to return NDC [-1,1]^2 instead of UV coords [0,1]^2
11+
vec2 nbl_glsl_TODOnamespace_octahedral_mapping(vec3 dir)
12+
{
13+
float sum = dot(vec3(1.0f), abs(dir));
1714
vec3 s = dir / sum;
1815

19-
if(s.z < 0.0f) {
20-
s.xy = sign(s.xy) * (1.0f - abs(s.yx));
16+
if(s.z < 0.0f)
17+
{
18+
const uvec2 flipSignMask = floatBitsToUint(s.xy)&0x80000000u;
19+
s.xy = uintBitsToFloat(floatBitsToUint(1.0f - abs(s.yx))^flipSignMask);
2120
}
2221

23-
return s.xy * 0.5f + 0.5f;
22+
return s.xy;
2423
}
2524

26-
// vec2 nbl_glsl_IES_convert_dir_to_uv(vec3 dir) {
27-
// return vec2((atan(dir.x, dir.y) + nbl_glsl_PI) / (2.0*nbl_glsl_PI), acos(dir.z) / nbl_glsl_PI);
28-
// }
25+
// TODO: implement proper mirroing
26+
// MIRROR_180_BITS = 0b001, Last Angle is 180, so map V with MIRROR and corner sampling off
27+
// MIRROR_90_BITS = 0b010, Last Angle is 90, so map both U and V with MIRROR and corner sampling off
28+
// ISOTROPIC_BITS = 0b011, texture to sample is Nx1, pretend v=middle always , and make u REPEAT or CLAMP_TO_BORDER
29+
// FULL_THETA_BIT = 0b100, handle truncated domain and rotate by 45 degrees for anisotropic
30+
// (certain combos wont work like 90 degree 2 symmetry domain & half theta), it really needs to be an 8 case label thing explicitly enumerated
31+
vec2 nbl_glsl_IES_convert_dir_to_uv(vec3 dir, vec2 halfMinusHalfPixel)
32+
{
33+
// halfMinusHalfPixel = 0.5-0.5/texSize
34+
// believe it or not, cornerSampled(NDC*0.5+0.5) = NDC*0.5*(1-1/texSize)+0.5
35+
return nbl_glsl_TODOnamespace_octahedral_mapping(dir)*halfMinusHalfPixel+0.5;
36+
}
2937

3038
#endif

include/nbl/builtin/glsl/material_compiler/common.glsl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ bool nbl_glsl_MC_op_isDelta(in uint op)
215215
#ifdef TEX_PREFETCH_STREAM
216216
#include <nbl/builtin/glsl/bump_mapping/utils.glsl>
217217
#endif
218+
// TODO: once rewritten to HLSL, shall use new API
218219
#include <nbl/builtin/glsl/ies/functions.glsl>
219220

220221
// OptiX likes this one better
@@ -601,7 +602,8 @@ vec3 nbl_glsl_MC_oriented_material_t_getEmissive(in nbl_glsl_MC_oriented_materia
601602
if ((floatBitsToInt(emitter.orientation[0])&1u) != 1u) {
602603
right *= -1;
603604
}
604-
return emissive * nbl_glsl_vTextureGrad(emitter.emissionProfile, nbl_glsl_IES_convert_dir_to_uv(mat3(right, up, view)*dir), mat2(0.0)).r;
605+
vec2 halfMinusHalfPixel = vec2(0.5)-vec2(0.5)/vec2(nbl_glsl_unpackSize(emitter.emissionProfile));
606+
return emissive * nbl_glsl_vTextureGrad(emitter.emissionProfile, nbl_glsl_IES_convert_dir_to_uv(mat3(right, up, view)*dir,halfMinusHalfPixel), mat2(0.0)).r;
605607
}
606608
#endif
607609
return emissive;
@@ -1498,4 +1500,4 @@ nbl_glsl_MC_quot_pdf_aov_t nbl_glsl_MC_runGenerateAndRemainderStream(
14981500
}
14991501
#endif //GEN_CHOICE_STREAM
15001502

1501-
#endif
1503+
#endif

include/nbl/builtin/hlsl/array_accessors.hlsl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ struct array_set
2424
arr[index] = val;
2525
}
2626
};
27+
2728
}
2829
}
2930

30-
#endif
31+
#endif

include/nbl/builtin/hlsl/cpp_compat/basic.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ struct add_pointer
8484

8585
#endif
8686

87+
88+
8789
namespace nbl
8890
{
8991
namespace hlsl
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
// Copyright (C) 2018-2025 - DevSH Graphics Programming Sp. z O.O.
2+
// This file is part of the "Nabla Engine".
3+
// For conditions of distribution and use, see copyright notice in nabla.h
4+
5+
#ifndef _NBL_BUILTIN_HLSL_IES_PROFILE_INCLUDED_
6+
#define _NBL_BUILTIN_HLSL_IES_PROFILE_INCLUDED_
7+
8+
#include "nbl/builtin/hlsl/cpp_compat.hlsl"
9+
#include "nbl/builtin/hlsl/cpp_compat/basic.h"
10+
11+
namespace nbl
12+
{
13+
namespace hlsl
14+
{
15+
namespace ies
16+
{
17+
18+
struct ProfileProperties
19+
{
20+
NBL_CONSTEXPR_STATIC_INLINE float32_t MaxVAngleDegrees = 180.f;
21+
NBL_CONSTEXPR_STATIC_INLINE float32_t MaxHAngleDegrees = 360.f;
22+
23+
// TODO: could change to uint8_t once we get implemented
24+
// https://github.com/microsoft/hlsl-specs/pull/538
25+
using packed_flags_t = uint32_t;
26+
27+
NBL_CONSTEXPR_STATIC_INLINE packed_flags_t VersionBits = 2u;
28+
NBL_CONSTEXPR_STATIC_INLINE packed_flags_t TypeBits = 2u;
29+
NBL_CONSTEXPR_STATIC_INLINE packed_flags_t SymmetryBits = 3u;
30+
NBL_CONSTEXPR_STATIC_INLINE packed_flags_t VersionMask = (packed_flags_t(1u) << VersionBits) - packed_flags_t(1u);
31+
NBL_CONSTEXPR_STATIC_INLINE packed_flags_t TypeMask = (packed_flags_t(1u) << TypeBits) - packed_flags_t(1u);
32+
NBL_CONSTEXPR_STATIC_INLINE packed_flags_t SymmetryMask = (packed_flags_t(1u) << SymmetryBits) - packed_flags_t(1u);
33+
NBL_CONSTEXPR_STATIC_INLINE packed_flags_t TypeShift = VersionBits;
34+
NBL_CONSTEXPR_STATIC_INLINE packed_flags_t SymmetryShift = VersionBits + TypeBits;
35+
36+
enum Version : packed_flags_t
37+
{
38+
V_1995,
39+
V_2002,
40+
V_SIZE
41+
};
42+
43+
enum PhotometricType : packed_flags_t
44+
{
45+
TYPE_NONE,
46+
TYPE_C,
47+
TYPE_B,
48+
TYPE_A
49+
};
50+
51+
enum LuminairePlanesSymmetry : packed_flags_t
52+
{
53+
ISOTROPIC, //! Only one horizontal angle present and a luminaire is assumed to be laterally axial symmetric
54+
QUAD_SYMETRIC, //! The luminaire is assumed to be symmetric in each quadrant
55+
HALF_SYMETRIC, //! The luminaire is assumed to be symmetric about the 0 to 180 degree plane
56+
OTHER_HALF_SYMMETRIC, //! HALF_SYMETRIC case for legacy V_1995 version where horizontal angles are in range [90, 270], in that case the parser patches horizontal angles to be HALF_SYMETRIC
57+
NO_LATERAL_SYMMET //! The luminaire is assumed to exhibit no lateral symmet
58+
};
59+
60+
Version getVersion() NBL_CONST_MEMBER_FUNC
61+
{
62+
return (Version)(packed & VersionMask);
63+
}
64+
65+
PhotometricType getType() NBL_CONST_MEMBER_FUNC
66+
{
67+
return (PhotometricType)((packed >> TypeShift) & TypeMask);
68+
}
69+
70+
LuminairePlanesSymmetry getSymmetry() NBL_CONST_MEMBER_FUNC
71+
{
72+
return (LuminairePlanesSymmetry)((packed >> SymmetryShift) & SymmetryMask);
73+
}
74+
75+
void setVersion(Version v)
76+
{
77+
packed_flags_t vBits = (packed_flags_t)(v) & VersionMask;
78+
packed = (packed & ~VersionMask) | vBits;
79+
}
80+
81+
void setType(PhotometricType t)
82+
{
83+
packed_flags_t tBits = ((packed_flags_t)(t) & TypeMask) << TypeShift;
84+
packed = (packed & ~(TypeMask << TypeShift)) | tBits;
85+
}
86+
87+
void setSymmetry(LuminairePlanesSymmetry s)
88+
{
89+
packed_flags_t sBits = ((packed_flags_t)(s) & SymmetryMask) << SymmetryShift;
90+
packed = (packed & ~(SymmetryMask << SymmetryShift)) | sBits;
91+
}
92+
93+
float32_t maxCandelaValue; //! Max candela sample value
94+
float32_t totalEmissionIntegral; //! Total emitted intensity (integral over full angular domain)
95+
float32_t fullDomainAvgEmission; //! Mean intensity over full angular domain (including I == 0)
96+
float32_t avgEmmision; //! Mean intensity over emitting solid angle (I > 0)
97+
packed_flags_t packed; //! Packed version, type and symmetry flags
98+
};
99+
100+
}
101+
102+
}
103+
}
104+
105+
#endif // _NBL_BUILTIN_HLSL_IES_PROFILE_INCLUDED_

0 commit comments

Comments
 (0)