Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
199b75a
Update CONTRIBUTING.md
devshgraphicsprogramming Sep 13, 2025
36d9943
Get IES cpps to compile
AnastaZIuk Oct 8, 2025
e312993
cap kind args
AnastaZIuk Oct 10, 2025
25c4bdc
fix a bug after my NSC rules update
AnastaZIuk Oct 10, 2025
3d18b58
update examples_tests submodule, we will first make CI pass with IES …
AnastaZIuk Oct 10, 2025
27de67f
update examples_tests submodule
AnastaZIuk Oct 10, 2025
0110f98
update examples_tests submodule
AnastaZIuk Oct 14, 2025
9ed5aee
ah IES was not added to asset manager, also correct some aspectMask s…
AnastaZIuk Oct 15, 2025
35931bd
update examples_tests submodule
AnastaZIuk Oct 15, 2025
a892678
update examples_tests submodule
AnastaZIuk Oct 16, 2025
5e236e6
update examples_tests submodule
AnastaZIuk Oct 19, 2025
7b27168
update examples_tests submodule
AnastaZIuk Oct 20, 2025
77e9e57
update examples_tests submodule
AnastaZIuk Oct 20, 2025
699e841
update ImGUI extension to allow hijacking precompiled SPIRV shaders (…
AnastaZIuk Oct 21, 2025
bd6cc4d
update examples_tests submodule
AnastaZIuk Oct 22, 2025
9381491
a few minor updates to NBL_CREATE_NSC_COMPILE_RULES to skip optional …
AnastaZIuk Oct 22, 2025
ae0b160
CP_UTF8 for dxc source buffer's encoding just like code page (experim…
AnastaZIuk Oct 24, 2025
d45e3a7
update examples_tests submodule
AnastaZIuk Oct 27, 2025
5ecf50e
fix IES Profile average emission and domain calculations
Oct 28, 2025
07feaff
Update CI references
Oct 28, 2025
e8ea119
`-Wno-local-type-template-args` for NBL_CREATE_NSC_COMPILE_RULES, upd…
AnastaZIuk Oct 28, 2025
1e9138e
make the IES octahedral maps corner sampled
Oct 28, 2025
be62e3a
improve how the resolution of an IES is calculated but also leave a T…
Oct 28, 2025
0c03e2f
Update CI references
Oct 28, 2025
80de6aa
update examples_tests submodule
AnastaZIuk Oct 29, 2025
e05478d
update examples_tests submodule
AnastaZIuk Oct 29, 2025
8d0c237
add createGrid to geometry creator
AnastaZIuk Oct 30, 2025
dbd2805
remove debug code I forgot about
AnastaZIuk Oct 30, 2025
054038f
add positions to geometry creator's grid for the polygon to be usable…
AnastaZIuk Oct 31, 2025
f64a8f3
update examples_tests submodule
AnastaZIuk Nov 3, 2025
c941991
update examples_tests submodule
AnastaZIuk Nov 3, 2025
95246c4
update examples_tests submodule
AnastaZIuk Nov 5, 2025
8eba4c9
pull ditt, resolve conflicts
AnastaZIuk Nov 8, 2025
4bb2864
add include/nbl/builtin/hlsl/math/octahedral.hlsl
AnastaZIuk Nov 8, 2025
12d608f
CONTRIBUTING.md post update
AnastaZIuk Nov 8, 2025
2eadc3b
wipe CIESProfile::octahdronUVToDir and use HLSL version
AnastaZIuk Nov 8, 2025
ff2558b
Merge branch 'master' of github.com:Devsh-Graphics-Programming/Nabla …
AnastaZIuk Nov 8, 2025
1d8aa31
wipe CIESProfile::sphericalDirToRadians and use polar.hlsl
AnastaZIuk Nov 8, 2025
a7287ca
Merge branch 'master' of github.com:Devsh-Graphics-Programming/Nabla …
AnastaZIuk Nov 9, 2025
7105b0c
add include/nbl/builtin/hlsl/ies/profile.hlsl and include/nbl/builtin…
AnastaZIuk Nov 14, 2025
811ced6
update IES .cpp files, downgrade IES internal scalar storage to float…
AnastaZIuk Nov 16, 2025
53766dc
pull master, resolve conflicts
AnastaZIuk Nov 24, 2025
80d4479
a few updates due to WAVE, ambiguity and DXC bugs, new ImGui/builtin/…
AnastaZIuk Nov 24, 2025
0ec69a7
Merge branch 'master' of github.com:Devsh-Graphics-Programming/Nabla …
AnastaZIuk Nov 25, 2025
1a25fc0
fix another ambiguity, finally my unified IES shader compiled
AnastaZIuk Nov 25, 2025
83da9c5
ah I broke nabla build, this one fixes the ambiguity and compiles for…
AnastaZIuk Nov 25, 2025
7c5b658
add source groups, include HLSL files in solution
AnastaZIuk Nov 25, 2025
67518fe
update examples_tests submodule
AnastaZIuk Nov 25, 2025
1ed5d82
add shadertoolsconfig.json, include in source group, leave some comme…
AnastaZIuk Nov 25, 2025
9814b88
update examples_tests submodule
AnastaZIuk Nov 26, 2025
cf12cee
pull master
AnastaZIuk Nov 26, 2025
e605969
update dxc submodule, pull microsoft:main and s-perron:i7945
AnastaZIuk Nov 26, 2025
d517cf1
Merge branch 'master' of github.com:Devsh-Graphics-Programming/Nabla …
AnastaZIuk Nov 26, 2025
53e4ab1
update dxc submodule, it crashes!
AnastaZIuk Nov 26, 2025
5b79bb4
update examples_tests submodule
AnastaZIuk Nov 30, 2025
0db984b
update examples_tests submodule
AnastaZIuk Nov 30, 2025
5ce6fa2
update examples_tests submodule
AnastaZIuk Nov 30, 2025
83a83a4
update ProfileProperties to tightly pack version, type and symmetry, …
AnastaZIuk Dec 3, 2025
b855e1c
NBL_HLSL_DEFINE_STRUCT for IESTextureInfo, update ies/profile.hlsl ca…
AnastaZIuk Dec 3, 2025
2c5974e
fix optimal resolution bug, update examples_tests submodule
AnastaZIuk Dec 4, 2025
777e443
update examples_tests submodule
AnastaZIuk Dec 4, 2025
5331ebe
pull master, resolve conflicts
AnastaZIuk Dec 5, 2025
cab896a
update examples_tests submodule
AnastaZIuk Dec 5, 2025
6329e3a
resolve conflicts, pull master
AnastaZIuk Dec 12, 2025
80ed36a
pull master, resolve conflicts
AnastaZIuk Dec 27, 2025
e7a0ef4
add IES texture eval overload, remove some old code, update examples_…
AnastaZIuk Dec 28, 2025
3e5f8d0
awful nsc tooling bug I didn't notice while merging https://github.co…
AnastaZIuk Dec 28, 2025
f95f163
update examples_tests submodule
AnastaZIuk Dec 28, 2025
575136e
builtin sources & headers per configuration
AnastaZIuk Dec 28, 2025
2f5de5d
wipe installation rules of builtin resource headers, they are not inc…
AnastaZIuk Dec 29, 2025
c71762e
BUILD_INTERFACE for builtin auto-gen include search directories
AnastaZIuk Dec 29, 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
2 changes: 1 addition & 1 deletion ci
Submodule ci updated 37 files
+1 −1 22.RaytracedAO/references/private
+ 22.RaytracedAO/references/public/71_render_0_2/71_render_0_2.exr
+ 22.RaytracedAO/references/public/71_render_0_2/71_render_0_2_denoised.exr
+ 22.RaytracedAO/references/public/71_render_0_2/71_render_0_2_normal.exr
+ 22.RaytracedAO/references/public/72_render_0_2/72_render_0_2.exr
+ 22.RaytracedAO/references/public/72_render_0_2/72_render_0_2_denoised.exr
+ 22.RaytracedAO/references/public/bathroom2_scene/Render_bathroom2_scene.exr
+ 22.RaytracedAO/references/public/bathroom2_scene/Render_bathroom2_scene_albedo.exr
+ 22.RaytracedAO/references/public/bathroom2_scene/Render_bathroom2_scene_denoised.exr
+ 22.RaytracedAO/references/public/bathroom2_scene/Render_bathroom2_scene_normal.exr
+ 22.RaytracedAO/references/public/bathroom_scene/Render_bathroom_scene.exr
+ 22.RaytracedAO/references/public/bathroom_scene/Render_bathroom_scene_denoised.exr
+ 22.RaytracedAO/references/public/bathroom_scene/Render_bathroom_scene_normal.exr
+ 22.RaytracedAO/references/public/bedroom_scene/Render_bedroom_scene.exr
+ 22.RaytracedAO/references/public/bedroom_scene/Render_bedroom_scene_albedo.exr
+ 22.RaytracedAO/references/public/bedroom_scene/Render_bedroom_scene_denoised.exr
+ 22.RaytracedAO/references/public/bedroom_scene/Render_bedroom_scene_normal.exr
+ 22.RaytracedAO/references/public/kitchen_scene/Render_kitchen_scene.exr
+ 22.RaytracedAO/references/public/kitchen_scene/Render_kitchen_scene_albedo.exr
+ 22.RaytracedAO/references/public/kitchen_scene/Render_kitchen_scene_denoised.exr
+ 22.RaytracedAO/references/public/kitchen_scene/Render_kitchen_scene_normal.exr
+ 22.RaytracedAO/references/public/living-room-2_scene/Render_living-room-2_scene.exr
+ 22.RaytracedAO/references/public/living-room-2_scene/Render_living-room-2_scene_albedo.exr
+ 22.RaytracedAO/references/public/living-room-2_scene/Render_living-room-2_scene_denoised.exr
+ 22.RaytracedAO/references/public/living-room-2_scene/Render_living-room-2_scene_normal.exr
+ 22.RaytracedAO/references/public/living-room_scene/Render_living-room_scene.exr
+ 22.RaytracedAO/references/public/living-room_scene/Render_living-room_scene_albedo.exr
+ 22.RaytracedAO/references/public/living-room_scene/Render_living-room_scene_denoised.exr
+ 22.RaytracedAO/references/public/living-room_scene/Render_living-room_scene_normal.exr
+ 22.RaytracedAO/references/public/shapetest/Render_shapetest_denoised.exr
+ 22.RaytracedAO/references/public/shapetest/Render_shapetest_normal.exr
+ 22.RaytracedAO/references/public/staircase2_scene/Render_staircase2_scene.exr
+ 22.RaytracedAO/references/public/staircase2_scene/Render_staircase2_scene_albedo.exr
+ 22.RaytracedAO/references/public/staircase2_scene/Render_staircase2_scene_denoised.exr
+ 22.RaytracedAO/references/public/staircase_scene/Render_staircase_scene_albedo.exr
+ 22.RaytracedAO/references/public/staircase_scene/Render_staircase_scene_denoised.exr
+ 22.RaytracedAO/references/public/staircase_scene/Render_staircase_scene_normal.exr
81 changes: 37 additions & 44 deletions cmake/common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -350,13 +350,6 @@ function(nbl_install_media _FILE)
nbl_install_lib_spec("${_FILE}" "")
endfunction()

function(nbl_install_builtin_resources _TARGET_)
get_target_property(_BUILTIN_RESOURCES_INCLUDE_SEARCH_DIRECTORY_ ${_TARGET_} BUILTIN_RESOURCES_INCLUDE_SEARCH_DIRECTORY)
get_target_property(_BUILTIN_RESOURCES_HEADERS_ ${_TARGET_} BUILTIN_RESOURCES_HEADERS)

nbl_install_headers_spec("${_BUILTIN_RESOURCES_HEADERS_}" "${_BUILTIN_RESOURCES_INCLUDE_SEARCH_DIRECTORY_}")
endfunction()

function(NBL_TEST_MODULE_INSTALL_FILE _NBL_FILEPATH_)
file(RELATIVE_PATH _NBL_REL_INSTALL_DEST_ "${NBL_ROOT_PATH}" "${_NBL_FILEPATH_}")
cmake_path(GET _NBL_REL_INSTALL_DEST_ PARENT_PATH _NBL_REL_INSTALL_DEST_)
Expand Down Expand Up @@ -1184,12 +1177,13 @@ struct DeviceConfigCaps
-enable-16bit-types
-Zpr
-spirv
-Wno-local-type-template-args
-fspv-target-env=vulkan1.3
-Wshadow
-Wconversion
$<$<CONFIG:Debug>:-O0>
$<$<CONFIG:Release>:-O3>
$<$<CONFIG:RelWithDebInfo>:-O3>
$<$<CONFIG:RelWithDebInfo>:-O3>
)

if(NSC_DEBUG_EDIF_FILE_BIT)
Expand Down Expand Up @@ -1484,42 +1478,41 @@ namespace @IMPL_NAMESPACE@ {
file(WRITE "${CONFIG_FILE}" "${CONFIG_CONTENT}")

# generate keys and commands for compiling shaders
foreach(BUILD_CONFIGURATION ${CMAKE_CONFIGURATION_TYPES})
set(FINAL_KEY_REL_PATH "${BUILD_CONFIGURATION}/${FINAL_KEY}")
set(TARGET_OUTPUT "${IMPL_BINARY_DIR}/${FINAL_KEY_REL_PATH}")

set(NBL_NSC_COMPILE_COMMAND
"$<TARGET_FILE:nsc>"
-Fc "${TARGET_OUTPUT}"
${COMPILE_OPTIONS} ${REQUIRED_OPTIONS} ${IMPL_COMMON_OPTIONS}
"${CONFIG_FILE}"
)

add_custom_command(OUTPUT "${TARGET_OUTPUT}"
COMMAND ${NBL_NSC_COMPILE_COMMAND}
DEPENDS ${DEPENDS_ON}
COMMENT "Creating \"${TARGET_OUTPUT}\""
VERBATIM
COMMAND_EXPAND_LISTS
)

set(HEADER_ONLY_LIKE "${CONFIG_FILE}" "${TARGET_INPUT}" "${TARGET_OUTPUT}")
target_sources(${IMPL_TARGET} PRIVATE ${HEADER_ONLY_LIKE})

set_source_files_properties(${HEADER_ONLY_LIKE} PROPERTIES
HEADER_FILE_ONLY ON
VS_TOOL_OVERRIDE None
)

set_source_files_properties("${TARGET_OUTPUT}" PROPERTIES
NBL_SPIRV_REGISTERED_INPUT "${TARGET_INPUT}"
NBL_SPIRV_PERMUTATION_CONFIG "${CONFIG_FILE}"
NBL_SPIRV_BINARY_DIR "${IMPL_BINARY_DIR}"
NBL_SPIRV_ACCESS_KEY "${FINAL_KEY_REL_PATH}"
)

set_property(TARGET ${IMPL_TARGET} APPEND PROPERTY NBL_SPIRV_OUTPUTS "${TARGET_OUTPUT}")
endforeach()
set(FINAL_KEY_REL_PATH "$<CONFIG>/${FINAL_KEY}")
set(TARGET_OUTPUT "${IMPL_BINARY_DIR}/${FINAL_KEY_REL_PATH}")

set(NBL_NSC_COMPILE_COMMAND
"$<TARGET_FILE:nsc>"
-Fc "${TARGET_OUTPUT}"
${COMPILE_OPTIONS} ${REQUIRED_OPTIONS} ${IMPL_COMMON_OPTIONS}
"${CONFIG_FILE}"
)

add_custom_command(OUTPUT "${TARGET_OUTPUT}"
COMMAND ${NBL_NSC_COMPILE_COMMAND}
DEPENDS ${DEPENDS_ON}
COMMENT "Creating \"${TARGET_OUTPUT}\""
VERBATIM
COMMAND_EXPAND_LISTS
)
set_source_files_properties("${TARGET_OUTPUT}" PROPERTIES GENERATED TRUE)

set(HEADER_ONLY_LIKE "${CONFIG_FILE}" "${TARGET_INPUT}" "${TARGET_OUTPUT}")
target_sources(${IMPL_TARGET} PRIVATE ${HEADER_ONLY_LIKE})

set_source_files_properties(${HEADER_ONLY_LIKE} PROPERTIES
HEADER_FILE_ONLY ON
VS_TOOL_OVERRIDE None
)

set_source_files_properties("${TARGET_OUTPUT}" PROPERTIES
NBL_SPIRV_REGISTERED_INPUT "${TARGET_INPUT}"
NBL_SPIRV_PERMUTATION_CONFIG "${CONFIG_FILE}"
NBL_SPIRV_BINARY_DIR "${IMPL_BINARY_DIR}"
NBL_SPIRV_ACCESS_KEY "${FINAL_KEY_REL_PATH}"
)

set_property(TARGET ${IMPL_TARGET} APPEND PROPERTY NBL_SPIRV_OUTPUTS "${TARGET_OUTPUT}")
return()
endif()

Expand Down
2 changes: 1 addition & 1 deletion examples_tests
2 changes: 1 addition & 1 deletion include/nbl/asset/asset.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,6 @@
#include "nbl/asset/metadata/CMTLMetadata.h"
#include "nbl/asset/metadata/CPLYMetadata.h"
#include "nbl/asset/metadata/CSTLMetadata.h"
//#include "nbl/asset/metadata/CIESProfileMetadata.h"
#include "nbl/asset/metadata/CIESProfileMetadata.h"

#endif
8 changes: 7 additions & 1 deletion include/nbl/asset/utils/CGeometryCreator.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,15 @@ class NBL_API2 CGeometryCreator final : public core::IReferenceCounted
\param subdivision Specifies subdivision level of the icosphere.
\param smooth Specifies whether vertecies should be built for smooth or flat shading.
*/

core::smart_refctd_ptr<ICPUPolygonGeometry> createIcoSphere(float radius=1.f, uint32_t subdivision=1, bool smooth=false) const;

//! Create a grid geometry
/**
No vertex buffer, only index in triangle strip topology without reset, "snake" with degenerates
\param "resolution" Specifies resolution of grid
*/
core::smart_refctd_ptr<ICPUPolygonGeometry> createGrid(const hlsl::uint16_t2 resolution = { 128u, 128u }) const;

private:
SCreationParams m_params;
};
Expand Down
36 changes: 22 additions & 14 deletions include/nbl/builtin/glsl/ies/functions.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,33 @@

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

// TODO: implement proper mirroing
// MIRROR_180_BITS = 0b001, Last Angle is 180, so map V slightly differently
// MIRROR_90_BITS = 0b010, Last Angle is 90, so map both U and V slightly differently
// ISOTROPIC_BITS = 0b011, texture to sample is Nx1, pretend v=middle always
// FULL_THETA_BIT = 0b100, handle extended domain and rotate by 45 degrees for anisotropic

vec2 nbl_glsl_IES_convert_dir_to_uv(vec3 dir) {
float sum = dot(vec3(1.0f), abs(dir));
// TODO: when rewriting to HLSL this is not IES namespace or folder, this should be octahedral mapping sitting somewhere where the spherical/polar sits
// NOTE: I changed it to return NDC [-1,1]^2 instead of UV coords [0,1]^2
vec2 nbl_glsl_TODOnamespace_octahedral_mapping(vec3 dir)
Copy link
Member Author

Choose a reason for hiding this comment

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

TODO: forgot to wipe, not used anymore

Copy link
Member Author

Choose a reason for hiding this comment

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

EDIT: file to remove but leaving it due to reference in material compiler glsl

{
float sum = dot(vec3(1.0f), abs(dir));
vec3 s = dir / sum;

if(s.z < 0.0f) {
s.xy = sign(s.xy) * (1.0f - abs(s.yx));
if(s.z < 0.0f)
{
const uvec2 flipSignMask = floatBitsToUint(s.xy)&0x80000000u;
s.xy = uintBitsToFloat(floatBitsToUint(1.0f - abs(s.yx))^flipSignMask);
}

return s.xy * 0.5f + 0.5f;
return s.xy;
}

// vec2 nbl_glsl_IES_convert_dir_to_uv(vec3 dir) {
// return vec2((atan(dir.x, dir.y) + nbl_glsl_PI) / (2.0*nbl_glsl_PI), acos(dir.z) / nbl_glsl_PI);
// }
// TODO: implement proper mirroing
// MIRROR_180_BITS = 0b001, Last Angle is 180, so map V with MIRROR and corner sampling off
// MIRROR_90_BITS = 0b010, Last Angle is 90, so map both U and V with MIRROR and corner sampling off
// ISOTROPIC_BITS = 0b011, texture to sample is Nx1, pretend v=middle always , and make u REPEAT or CLAMP_TO_BORDER
// FULL_THETA_BIT = 0b100, handle truncated domain and rotate by 45 degrees for anisotropic
// (certain combos wont work like 90 degree 2 symmetry domain & half theta), it really needs to be an 8 case label thing explicitly enumerated
vec2 nbl_glsl_IES_convert_dir_to_uv(vec3 dir, vec2 halfMinusHalfPixel)
Copy link
Member Author

Choose a reason for hiding this comment

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

TODO: forgot to wipe, not used anymore

Copy link
Member Author

Choose a reason for hiding this comment

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

EDIT: file to remove but leaving it due to reference in material compiler glsl

{
// halfMinusHalfPixel = 0.5-0.5/texSize
// believe it or not, cornerSampled(NDC*0.5+0.5) = NDC*0.5*(1-1/texSize)+0.5
return nbl_glsl_TODOnamespace_octahedral_mapping(dir)*halfMinusHalfPixel+0.5;
}

#endif
6 changes: 4 additions & 2 deletions include/nbl/builtin/glsl/material_compiler/common.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ bool nbl_glsl_MC_op_isDelta(in uint op)
#ifdef TEX_PREFETCH_STREAM
#include <nbl/builtin/glsl/bump_mapping/utils.glsl>
#endif
// TODO: once rewritten to HLSL, shall use new API
#include <nbl/builtin/glsl/ies/functions.glsl>

// OptiX likes this one better
Expand Down Expand Up @@ -601,7 +602,8 @@ vec3 nbl_glsl_MC_oriented_material_t_getEmissive(in nbl_glsl_MC_oriented_materia
if ((floatBitsToInt(emitter.orientation[0])&1u) != 1u) {
right *= -1;
}
return emissive * nbl_glsl_vTextureGrad(emitter.emissionProfile, nbl_glsl_IES_convert_dir_to_uv(mat3(right, up, view)*dir), mat2(0.0)).r;
vec2 halfMinusHalfPixel = vec2(0.5)-vec2(0.5)/vec2(nbl_glsl_unpackSize(emitter.emissionProfile));
return emissive * nbl_glsl_vTextureGrad(emitter.emissionProfile, nbl_glsl_IES_convert_dir_to_uv(mat3(right, up, view)*dir,halfMinusHalfPixel), mat2(0.0)).r;
}
#endif
return emissive;
Expand Down Expand Up @@ -1498,4 +1500,4 @@ nbl_glsl_MC_quot_pdf_aov_t nbl_glsl_MC_runGenerateAndRemainderStream(
}
#endif //GEN_CHOICE_STREAM

#endif
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ SVertexAttributes main()
SVertexAttributes retval;
retval.uv = tc[gl_VertexIndex()];
return retval;
}
}

117 changes: 117 additions & 0 deletions include/nbl/builtin/hlsl/ies/profile.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
// 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_IES_PROFILE_INCLUDED_
#define _NBL_BUILTIN_HLSL_IES_PROFILE_INCLUDED_

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

namespace nbl
{
namespace hlsl
{
namespace ies
{

struct ProfileProperties
{
//! max 16K resolution
NBL_CONSTEXPR_STATIC_INLINE uint32_t CDC_MAX_TEXTURE_WIDTH = 15360u;
NBL_CONSTEXPR_STATIC_INLINE uint32_t CDC_MAX_TEXTURE_HEIGHT = 8640u;

// TODO: This constraint is hack because the mitsuba loader and its material compiler use Virtual Texturing, and there's some bug with IES not sampling sub 128x128 mip levels
// don't want to spend time to fix this since we'll be using descriptor indexing for the next iteration
NBL_CONSTEXPR_STATIC_INLINE uint32_t CDC_MIN_TEXTURE_WIDTH = 128u;
NBL_CONSTEXPR_STATIC_INLINE uint32_t CDC_MIN_TEXTURE_HEIGHT = 128u;

NBL_CONSTEXPR_STATIC_INLINE uint32_t CDC_DEFAULT_TEXTURE_WIDTH = 1024u;
NBL_CONSTEXPR_STATIC_INLINE uint32_t CDC_DEFAULT_TEXTURE_HEIGHT = 1024u;

NBL_CONSTEXPR_STATIC_INLINE float32_t MAX_VANGLE = 180.f;
NBL_CONSTEXPR_STATIC_INLINE float32_t MAX_HANGLE = 360.f;

// TODO: could change to uint8_t once we get implemented
// https://github.com/microsoft/hlsl-specs/pull/538
using packed_flags_t = uint16_t;

NBL_CONSTEXPR_STATIC_INLINE packed_flags_t VERSION_BITS = 2u;
NBL_CONSTEXPR_STATIC_INLINE packed_flags_t TYPE_BITS = 2u;
NBL_CONSTEXPR_STATIC_INLINE packed_flags_t SYMM_BITS = 3u;
NBL_CONSTEXPR_STATIC_INLINE packed_flags_t VERSION_MASK = (packed_flags_t(1u) << VERSION_BITS) - packed_flags_t(1u);
NBL_CONSTEXPR_STATIC_INLINE packed_flags_t TYPE_MASK = (packed_flags_t(1u) << TYPE_BITS) - packed_flags_t(1u);
NBL_CONSTEXPR_STATIC_INLINE packed_flags_t SYMM_MASK = (packed_flags_t(1u) << SYMM_BITS) - packed_flags_t(1u);

enum Version : packed_flags_t
{
V_1995,
V_2002,
V_SIZE
};

enum PhotometricType : packed_flags_t
{
TYPE_NONE,
TYPE_C,
TYPE_B,
TYPE_A
};

enum LuminairePlanesSymmetry : packed_flags_t
{
ISOTROPIC, //! Only one horizontal angle present and a luminaire is assumed to be laterally axial symmetric
QUAD_SYMETRIC, //! The luminaire is assumed to be symmetric in each quadrant
HALF_SYMETRIC, //! The luminaire is assumed to be symmetric about the 0 to 180 degree plane
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
NO_LATERAL_SYMMET //! The luminaire is assumed to exhibit no lateral symmet
};

Version getVersion() NBL_CONST_MEMBER_FUNC
{
return (Version)( packed & VERSION_MASK );
}

PhotometricType getType() NBL_CONST_MEMBER_FUNC
{
const packed_flags_t shift = VERSION_BITS;
return (PhotometricType)((packed >> shift) & TYPE_MASK);
}

LuminairePlanesSymmetry getSymmetry() NBL_CONST_MEMBER_FUNC
{
const packed_flags_t shift = VERSION_BITS + TYPE_BITS;
return (LuminairePlanesSymmetry)((packed >> shift) & SYMM_MASK);
}

void setVersion(Version v)
{
packed_flags_t vBits = (packed_flags_t)(v) & VERSION_MASK;
packed = (packed & ~VERSION_MASK) | vBits;
}

void setType(PhotometricType t)
{
const packed_flags_t shift = VERSION_BITS;
packed_flags_t tBits = ((packed_flags_t)(t) & TYPE_MASK) << shift;
packed = (packed & ~(TYPE_MASK << shift)) | tBits;
}

void setSymmetry(LuminairePlanesSymmetry s)
{
const packed_flags_t shift = VERSION_BITS + TYPE_BITS;
packed_flags_t sBits = ((packed_flags_t)(s) & SYMM_MASK) << shift;
packed = (packed & ~(SYMM_MASK << shift)) | sBits;
}

float32_t maxCandelaValue; //! Max candela sample value
float32_t totalEmissionIntegral; //! Total emitted intensity (integral over full angular domain)
float32_t fullDomainAvgEmission; //! Mean intensity over full angular domain (including I == 0)
float32_t avgEmmision; //! Mean intensity over emitting solid angle (I > 0)
packed_flags_t packed; //! Packed version, type and symmetry flags
};

}
}
}

#endif // _NBL_BUILTIN_HLSL_IES_PROFILE_INCLUDED_
Loading
Loading