From d6341c40897c07264f96fca749d8c86c8bd1bccd Mon Sep 17 00:00:00 2001 From: lshoek Date: Mon, 2 Mar 2026 09:52:02 +0100 Subject: [PATCH 01/15] add findvertexbufferbindingindex to renderablemesh --- .../naprender/src/renderablemesh.cpp | 30 +++++++++++++++---- system_modules/naprender/src/renderablemesh.h | 11 ++++++- 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/system_modules/naprender/src/renderablemesh.cpp b/system_modules/naprender/src/renderablemesh.cpp index de57c66f88..5cc4b18a2a 100644 --- a/system_modules/naprender/src/renderablemesh.cpp +++ b/system_modules/naprender/src/renderablemesh.cpp @@ -81,13 +81,11 @@ namespace nap int RenderableMesh::getVertexBufferBindingIndex(const std::string& meshVertexAttributeID) const { - GPUMesh& gpu_mesh = mMesh->getMeshInstance().getGPUMesh(); - const Material& material = mMaterialInstance->getMaterial(); - int binding = 0; - for (auto& kvp : material.getShader().getAttributes()) + const auto& material = mMaterialInstance->getMaterial(); + for (const auto& kvp : material.getShader().getAttributes()) { - const Material::VertexAttributeBinding* material_binding = material.findVertexAttributeBinding(kvp.first); + const auto* material_binding = material.findVertexAttributeBinding(kvp.first); assert(material_binding != nullptr); // Override the position mesh attribute @@ -100,5 +98,27 @@ namespace nap return -1; } + + bool RenderableMesh::findVertexBufferBindingIndex(const std::string& meshVertexAttributeID, int& outIndex) const + { + int binding = 0; + const auto& material = mMaterialInstance->getMaterial(); + for (const auto& kvp : material.getShader().getAttributes()) + { + const auto* material_binding = material.findVertexAttributeBinding(kvp.first); + if (material_binding == nullptr) + return false; + + // Override the position mesh attribute + if (material_binding->mMeshAttributeID == meshVertexAttributeID) + { + outIndex = binding; + return true; + } + ++binding; + } + return false; + } + } diff --git a/system_modules/naprender/src/renderablemesh.h b/system_modules/naprender/src/renderablemesh.h index 299942fe71..1c2eeeca47 100644 --- a/system_modules/naprender/src/renderablemesh.h +++ b/system_modules/naprender/src/renderablemesh.h @@ -84,12 +84,21 @@ namespace nap const std::vector& getVertexBufferOffsets() const { return mVertexBufferOffsets; } /** - * Returns the vertex buffer binding index of the given mesh attribute, asserts and returs -1 if not found. + * Returns the vertex buffer binding index of the given mesh attribute, asserts and returns -1 if not found. * @param meshVertexAttributeID the vertex attribute buffer name * @return the vertex buffer binding index of the given mesh attribute */ int getVertexBufferBindingIndex(const std::string& meshVertexAttributeID) const; + /** + * Writes to outIndex the vertex buffer binding index of the given mesh attribute, returns true if found, + * returns false if not found. + * @param meshVertexAttributeID the vertex attribute buffer name + * @param outIndex the vertex buffer binding index of the given mesh attribute + * @return if the buffer binding index was found + */ + bool findVertexBufferBindingIndex(const std::string& meshVertexAttributeID, int& outIndex) const; + protected: /** * Constructor From 23ca86cf470bc6973b1f61bc9c750640aa5ead96 Mon Sep 17 00:00:00 2001 From: lshoek Date: Mon, 2 Mar 2026 09:52:50 +0100 Subject: [PATCH 02/15] add getorcreatematerial to renderbloomcomponent --- system_modules/naprender/src/renderbloomcomponent.cpp | 5 ++--- system_modules/naprender/src/renderbloomcomponent.h | 11 +++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/system_modules/naprender/src/renderbloomcomponent.cpp b/system_modules/naprender/src/renderbloomcomponent.cpp index 6fd8ee727c..d285c5d68c 100644 --- a/system_modules/naprender/src/renderbloomcomponent.cpp +++ b/system_modules/naprender/src/renderbloomcomponent.cpp @@ -9,15 +9,12 @@ #include "gpubuffer.h" #include "renderglobals.h" #include "uniforminstance.h" -#include "renderglobals.h" #include "blurshader.h" #include "textureutils.h" // External Includes #include #include -#include -#include #include // nap::RenderBloomComponent run time class definition @@ -31,6 +28,8 @@ RTTI_END_CLASS // nap::RenderBloomComponentInstance run time class definition RTTI_BEGIN_CLASS_NO_DEFAULT_CONSTRUCTOR(nap::RenderBloomComponentInstance) RTTI_CONSTRUCTOR(nap::EntityInstance&, nap::Component&) + RTTI_FUNCTION(nap::material::instance::getOrCreateMaterial, &nap::RenderBloomComponentInstance::getOrCreateMaterial) + RTTI_FUNCTION("draw", &nap::RenderBloomComponentInstance::draw) RTTI_END_CLASS ////////////////////////////////////////////////////////////////////////// diff --git a/system_modules/naprender/src/renderbloomcomponent.h b/system_modules/naprender/src/renderbloomcomponent.h index 032ff7c047..09858c770b 100644 --- a/system_modules/naprender/src/renderbloomcomponent.h +++ b/system_modules/naprender/src/renderbloomcomponent.h @@ -83,6 +83,17 @@ namespace nap */ Texture2D& getOutputTexture() { return *mOutputTexture; } + /** + * Returns the program used to render the mesh. + * + * TODO: This should be private, but our current RTTI implementation 'mangles' class name-spaces, + * causing the RTTR_REGISTRATION_FRIEND macro to fail -> needs to be fixed. + * It is therefore not recommended to use this function at runtime, use 'getMaterialInstance' instead! + * + * @return material handle + */ + MaterialInstance* getOrCreateMaterial() { return &mMaterialInstance; } + protected: /** * Draws the effect full screen to the currently active render target, From e56c3ff851bbb8223075fe709d37afa2177fdec2 Mon Sep 17 00:00:00 2001 From: lshoek Date: Mon, 2 Mar 2026 10:13:03 +0100 Subject: [PATCH 03/15] refactor boxmesh --- system_modules/naprender/src/boxmesh.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/system_modules/naprender/src/boxmesh.cpp b/system_modules/naprender/src/boxmesh.cpp index 5fab327773..2805bab4c8 100644 --- a/system_modules/naprender/src/boxmesh.cpp +++ b/system_modules/naprender/src/boxmesh.cpp @@ -164,13 +164,13 @@ namespace nap } // Create attributes - nap::Vec3VertexAttribute& position_attribute = mMeshInstance->getOrCreateAttribute(vertexid::position); - nap::Vec3VertexAttribute& normal_attribute = mMeshInstance->getOrCreateAttribute(vertexid::normal); - nap::Vec3VertexAttribute& uv_attribute = mMeshInstance->getOrCreateAttribute(vertexid::getUVName(0)); - nap::Vec4VertexAttribute& color_attribute = mMeshInstance->getOrCreateAttribute(vertexid::getColorName(0)); + auto& position_attribute = mMeshInstance->getOrCreateAttribute(vertexid::position); + auto& normal_attribute = mMeshInstance->getOrCreateAttribute(vertexid::normal); + auto& uv_attribute = mMeshInstance->getOrCreateAttribute(vertexid::getUVName(0)); + auto& color_attribute = mMeshInstance->getOrCreateAttribute(vertexid::getColorName(0)); // Set numer of vertices this mesh contains - mesh.setNumVertices((int)boxVertCount); + mesh.setNumVertices(static_cast(boxVertCount)); mesh.setDrawMode(EDrawMode::Triangles); mesh.setCullMode(mCullMode); mesh.setUsage(mUsage); @@ -178,7 +178,7 @@ namespace nap // Create vertex data based on scale factor std::vector vertex_data(boxVertCount); - for (nap::uint i = 0; i < boxVertCount; i++) + for (uint i = 0; i < boxVertCount; i++) vertex_data[i] = (unitBox[i] * mSize) + mPosition; // Set data From 1f5ba4a361820537fc4281c3bf8947345ff2d7bc Mon Sep 17 00:00:00 2001 From: lshoek Date: Mon, 2 Mar 2026 10:29:29 +0100 Subject: [PATCH 04/15] refactor getshadervariablevaluetype --- system_modules/naprender/src/shader.cpp | 54 ++++++++++++------------- 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/system_modules/naprender/src/shader.cpp b/system_modules/naprender/src/shader.cpp index b6f690c4fd..505fe780d8 100644 --- a/system_modules/naprender/src/shader.cpp +++ b/system_modules/naprender/src/shader.cpp @@ -503,37 +503,35 @@ static nap::EShaderVariableValueType getShaderVariableValueType(spirv_cross::SPI case spirv_cross::SPIRType::Int: if (type.vecsize == 1 && type.columns == 1) return nap::EShaderVariableValueType::Int; - else if (type.vecsize == 4 && type.columns == 1) + if (type.vecsize == 4 && type.columns == 1) return nap::EShaderVariableValueType::IVec4; - else - return nap::EShaderVariableValueType::Unknown; + break; case spirv_cross::SPIRType::UInt: if (type.vecsize == 1 && type.columns == 1) return nap::EShaderVariableValueType::UInt; - else if (type.vecsize == 4 && type.columns == 1) + if (type.vecsize == 4 && type.columns == 1) return nap::EShaderVariableValueType::UVec4; - else - return nap::EShaderVariableValueType::Unknown; + break; case spirv_cross::SPIRType::Float: if (type.vecsize == 1 && type.columns == 1) return nap::EShaderVariableValueType::Float; - else if (type.vecsize == 2 && type.columns == 1) + if (type.vecsize == 2 && type.columns == 1) return nap::EShaderVariableValueType::Vec2; - else if (type.vecsize == 3 && type.columns == 1) + if (type.vecsize == 3 && type.columns == 1) return nap::EShaderVariableValueType::Vec3; - else if (type.vecsize == 4 && type.columns == 1) + if (type.vecsize == 4 && type.columns == 1) return nap::EShaderVariableValueType::Vec4; - else if (type.vecsize == 2 && type.columns == 2) + if (type.vecsize == 2 && type.columns == 2) return nap::EShaderVariableValueType::Mat2; - else if (type.vecsize == 3 && type.columns == 3) + if (type.vecsize == 3 && type.columns == 3) return nap::EShaderVariableValueType::Mat3; - else if (type.vecsize == 4 && type.columns == 4) + if (type.vecsize == 4 && type.columns == 4) return nap::EShaderVariableValueType::Mat4; - else - return nap::EShaderVariableValueType::Unknown; + break; default: - return nap::EShaderVariableValueType::Unknown; + break; } + return nap::EShaderVariableValueType::Unknown; } @@ -544,33 +542,33 @@ static VkFormat getFormatFromType(spirv_cross::SPIRType type) case spirv_cross::SPIRType::Int: if (type.vecsize == 1 && type.columns == 1) return VK_FORMAT_R32_SINT; - else if (type.vecsize == 4 && type.columns == 1) + if (type.vecsize == 4 && type.columns == 1) return VK_FORMAT_R32G32B32A32_SINT; - else - return VK_FORMAT_UNDEFINED; + break; case spirv_cross::SPIRType::UInt: if (type.vecsize == 1 && type.columns == 1) return VK_FORMAT_R32_UINT; - else if (type.vecsize == 4 && type.columns == 1) + if (type.vecsize == 4 && type.columns == 1) return VK_FORMAT_R32G32B32A32_UINT; - else - return VK_FORMAT_UNDEFINED; + break; case spirv_cross::SPIRType::Float: if (type.vecsize == 1 && type.columns == 1) return VK_FORMAT_R32_SFLOAT; - else if (type.vecsize == 2 && type.columns == 1) + if (type.vecsize == 2 && type.columns == 1) return VK_FORMAT_R32G32_SFLOAT; - else if (type.vecsize == 3 && type.columns == 1) + if (type.vecsize == 3 && type.columns == 1) return VK_FORMAT_R32G32B32_SFLOAT; - else if (type.vecsize == 4 && type.columns == 1) + if (type.vecsize == 4 && type.columns == 1) return VK_FORMAT_R32G32B32A32_SFLOAT; - else - return VK_FORMAT_UNDEFINED; + break; case spirv_cross::SPIRType::Double: - return VK_FORMAT_R64_SFLOAT; + if (type.vecsize == 1 && type.columns == 1) + return VK_FORMAT_R64_SFLOAT; + break; default: - return VK_FORMAT_UNDEFINED; + break; } + return VK_FORMAT_UNDEFINED; } From 7869027614753e3f08b709f29c224dbc017f78c6 Mon Sep 17 00:00:00 2001 From: lshoek Date: Mon, 2 Mar 2026 10:32:12 +0100 Subject: [PATCH 05/15] refactor uniforminstance --- .../naprender/src/uniforminstance.cpp | 96 +++++++++---------- 1 file changed, 44 insertions(+), 52 deletions(-) diff --git a/system_modules/naprender/src/uniforminstance.cpp b/system_modules/naprender/src/uniforminstance.cpp index 9fea862e91..6c1a701ad0 100644 --- a/system_modules/naprender/src/uniforminstance.cpp +++ b/system_modules/naprender/src/uniforminstance.cpp @@ -147,18 +147,18 @@ namespace nap if (declaration_type == RTTI_OF(ShaderVariableStructArrayDeclaration)) { - const ShaderVariableStructArrayDeclaration* struct_array_declaration = rtti_cast(&declaration); - std::unique_ptr struct_array_instance = std::make_unique(*struct_array_declaration); + const auto* struct_array_declaration = rtti_cast(&declaration); + auto struct_array_instance = std::make_unique(*struct_array_declaration); for (auto& struct_declaration : struct_array_declaration->mElements) { - std::unique_ptr struct_instance = std::make_unique(*struct_declaration, uniformCreatedCallback); + auto struct_instance = std::make_unique(*struct_declaration, uniformCreatedCallback); struct_array_instance->addElement(std::move(struct_instance)); } return std::move(struct_array_instance); } else if (declaration_type == RTTI_OF(ShaderVariableValueArrayDeclaration)) { - const ShaderVariableValueArrayDeclaration* value_array_declaration = rtti_cast(&declaration); + const auto* value_array_declaration = rtti_cast(&declaration); if (value_array_declaration->mElementType == EShaderVariableValueType::UInt) { @@ -166,49 +166,49 @@ namespace nap array_instance->getValues().resize(value_array_declaration->mNumElements); return std::move(array_instance); } - else if (value_array_declaration->mElementType == EShaderVariableValueType::Int) + if (value_array_declaration->mElementType == EShaderVariableValueType::Int) { auto array_instance = std::make_unique(*value_array_declaration); array_instance->getValues().resize(value_array_declaration->mNumElements); return std::move(array_instance); } - else if (value_array_declaration->mElementType == EShaderVariableValueType::Float) + if (value_array_declaration->mElementType == EShaderVariableValueType::Float) { auto array_instance = std::make_unique(*value_array_declaration); array_instance->getValues().resize(value_array_declaration->mNumElements); return std::move(array_instance); } - else if (value_array_declaration->mElementType == EShaderVariableValueType::Vec2) + if (value_array_declaration->mElementType == EShaderVariableValueType::Vec2) { auto array_instance = std::make_unique(*value_array_declaration); array_instance->getValues().resize(value_array_declaration->mNumElements); return std::move(array_instance); } - else if (value_array_declaration->mElementType == EShaderVariableValueType::Vec3) + if (value_array_declaration->mElementType == EShaderVariableValueType::Vec3) { auto array_instance = std::make_unique(*value_array_declaration); array_instance->getValues().resize(value_array_declaration->mNumElements); return std::move(array_instance); } - else if (value_array_declaration->mElementType == EShaderVariableValueType::Vec4) + if (value_array_declaration->mElementType == EShaderVariableValueType::Vec4) { auto array_instance = std::make_unique(*value_array_declaration); array_instance->getValues().resize(value_array_declaration->mNumElements); return std::move(array_instance); } - else if (value_array_declaration->mElementType == EShaderVariableValueType::IVec4) + if (value_array_declaration->mElementType == EShaderVariableValueType::IVec4) { auto array_instance = std::make_unique(*value_array_declaration); array_instance->getValues().resize(value_array_declaration->mNumElements); return std::move(array_instance); } - else if (value_array_declaration->mElementType == EShaderVariableValueType::UVec4) + if (value_array_declaration->mElementType == EShaderVariableValueType::UVec4) { auto array_instance = std::make_unique(*value_array_declaration); array_instance->getValues().resize(value_array_declaration->mNumElements); return std::move(array_instance); } - else if (value_array_declaration->mElementType == EShaderVariableValueType::Mat4) + if (value_array_declaration->mElementType == EShaderVariableValueType::Mat4) { auto array_instance = std::make_unique(*value_array_declaration); array_instance->getValues().resize(value_array_declaration->mNumElements); @@ -217,49 +217,39 @@ namespace nap } else if (declaration_type == RTTI_OF(ShaderVariableStructDeclaration)) { - const ShaderVariableStructDeclaration* struct_declaration = rtti_cast(&declaration); + const auto* struct_declaration = rtti_cast(&declaration); return std::make_unique(*struct_declaration, uniformCreatedCallback); } else if (declaration_type == RTTI_OF(ShaderVariableValueDeclaration)) { - const ShaderVariableValueDeclaration* value_declaration = rtti_cast(&declaration); + const auto* value_declaration = rtti_cast(&declaration); if (value_declaration->mType == EShaderVariableValueType::UInt) - { return std::make_unique(*value_declaration); - } - else if (value_declaration->mType == EShaderVariableValueType::Int) - { + + if (value_declaration->mType == EShaderVariableValueType::Int) return std::make_unique(*value_declaration); - } - else if (value_declaration->mType == EShaderVariableValueType::Float) - { + + if (value_declaration->mType == EShaderVariableValueType::Float) return std::make_unique(*value_declaration); - } - else if (value_declaration->mType == EShaderVariableValueType::Vec2) - { + + if (value_declaration->mType == EShaderVariableValueType::Vec2) return std::make_unique(*value_declaration); - } - else if (value_declaration->mType == EShaderVariableValueType::Vec3) - { + + if (value_declaration->mType == EShaderVariableValueType::Vec3) return std::make_unique(*value_declaration); - } - else if (value_declaration->mType == EShaderVariableValueType::Vec4) - { + + if (value_declaration->mType == EShaderVariableValueType::Vec4) return std::make_unique(*value_declaration); - } - else if (value_declaration->mType == EShaderVariableValueType::IVec4) - { + + if (value_declaration->mType == EShaderVariableValueType::IVec4) return std::make_unique(*value_declaration); - } - else if (value_declaration->mType == EShaderVariableValueType::UVec4) - { + + if (value_declaration->mType == EShaderVariableValueType::UVec4) return std::make_unique(*value_declaration); - } - else if (value_declaration->mType == EShaderVariableValueType::Mat4) - { + + if (value_declaration->mType == EShaderVariableValueType::Mat4) return std::make_unique(*value_declaration); - } } else { @@ -297,10 +287,10 @@ namespace nap if (declaration_type == RTTI_OF(ShaderVariableStructArrayDeclaration)) { - ShaderVariableStructArrayDeclaration* struct_array_declaration = rtti_cast(uniform_declaration.get()); + auto* struct_array_declaration = rtti_cast(uniform_declaration.get()); - std::unique_ptr struct_array_instance = std::make_unique(*struct_array_declaration); - const UniformStructArray* struct_array_resource = rtti_cast(resource); + auto struct_array_instance = std::make_unique(*struct_array_declaration); + const auto* struct_array_resource = rtti_cast(resource); if (!errorState.check(resource == nullptr || struct_array_resource->mStructs.size() == struct_array_declaration->mElements.size(), "Mismatch between number of array elements in shader and json.")) return false; @@ -310,9 +300,11 @@ namespace nap UniformStruct* struct_resource = nullptr; if (struct_array_resource != nullptr && resource_index < struct_array_resource->mStructs.size()) struct_resource = struct_array_resource->mStructs[resource_index++].get(); - std::unique_ptr instance_element = std::make_unique(*declaration_element, uniformCreatedCallback); + + auto instance_element = std::make_unique(*declaration_element, uniformCreatedCallback); if (!instance_element->addUniformRecursive(*declaration_element, struct_resource, uniformCreatedCallback, createDefaults, errorState)) return false; + struct_array_instance->addElement(std::move(instance_element)); } @@ -320,11 +312,11 @@ namespace nap } else if (declaration_type == RTTI_OF(ShaderVariableValueArrayDeclaration)) { - const UniformValueArray* value_array_resource = rtti_cast(resource); + const auto* value_array_resource = rtti_cast(resource); if (!errorState.check(resource == nullptr || value_array_resource != nullptr, "Type mismatch between shader type and json type")) return false; - ShaderVariableValueArrayDeclaration* value_declaration = rtti_cast(uniform_declaration.get()); + auto* value_declaration = rtti_cast(uniform_declaration.get()); std::unique_ptr instance_value_array; if (value_declaration->mElementType == EShaderVariableValueType::UInt) @@ -383,18 +375,18 @@ namespace nap } else if (declaration_type == RTTI_OF(ShaderVariableStructDeclaration)) { - const UniformStruct* struct_resource = rtti_cast(resource); + const auto* struct_resource = rtti_cast(resource); + auto* struct_declaration = rtti_cast(uniform_declaration.get()); - ShaderVariableStructDeclaration* struct_declaration = rtti_cast(uniform_declaration.get()); - std::unique_ptr struct_instance = std::make_unique(*struct_declaration, uniformCreatedCallback); + auto struct_instance = std::make_unique(*struct_declaration, uniformCreatedCallback); if (!struct_instance->addUniformRecursive(*struct_declaration, struct_resource, uniformCreatedCallback, createDefaults, errorState)) return false; mUniforms.emplace_back(std::move(struct_instance)); } - else if(declaration_type == RTTI_OF(ShaderVariableValueDeclaration)) + else if (declaration_type == RTTI_OF(ShaderVariableValueDeclaration)) { - ShaderVariableValueDeclaration* value_declaration = rtti_cast(uniform_declaration.get()); + auto* value_declaration = rtti_cast(uniform_declaration.get()); std::unique_ptr value_instance; if (value_declaration->mType == EShaderVariableValueType::UInt) @@ -454,7 +446,7 @@ namespace nap } - nap::UniformStructInstance* UniformStructArrayInstance::findElement(int index) + UniformStructInstance* UniformStructArrayInstance::findElement(int index) { return index >= mElements.size() ? nullptr : mElements[index].get(); } From 2940e2a918364d4966c0cea42e289ada89193e09 Mon Sep 17 00:00:00 2001 From: lshoek Date: Mon, 2 Mar 2026 11:02:19 +0100 Subject: [PATCH 06/15] refactor boxframemesh --- .../naprenderadvanced/src/boxframemesh.cpp | 109 +++++++++--------- .../naprenderadvanced/src/boxframemesh.h | 2 +- 2 files changed, 54 insertions(+), 57 deletions(-) diff --git a/system_modules/naprenderadvanced/src/boxframemesh.cpp b/system_modules/naprenderadvanced/src/boxframemesh.cpp index b97bc96d93..3a298927eb 100644 --- a/system_modules/naprenderadvanced/src/boxframemesh.cpp +++ b/system_modules/naprenderadvanced/src/boxframemesh.cpp @@ -27,6 +27,36 @@ namespace nap // Static ////////////////////////////////////////////////////////////////////////// + constexpr static uint sQuadVertCount = 4; //< Number of vertices per quad + constexpr static uint sQuadCount = 2; //< Total number of quad + constexpr static uint sLineVertCount = 2; //< Total number of vertices per line + constexpr static uint sLineCount = 4; //< Total number of lines + + // Index offsets to shape a single quad face + static const std::vector sQuadIndexOffsets = { 0, 1, 1, 2, 2, 3, 3, 0 }; + + static void setupIndices(std::vector& outIndices) + { + // Generate the indices + outIndices.reserve(sQuadCount * sQuadVertCount * 2 + sLineCount * sLineVertCount); + + // Repeat twice generating two quads + for (uint i = 0; i < sQuadCount; i++) + { + const uint quad_offset = i * sQuadVertCount; + for (uint off : sQuadIndexOffsets) + outIndices.emplace_back(quad_offset + off); + } + + // Connect the mirroring edges of the quads + for (uint i = 0; i < sLineCount; i++) + { + outIndices.emplace_back(i); + outIndices.emplace_back(i + sQuadVertCount); + } + } + + static std::vector getBoxFrameMeshVertices(const math::Box& box) { return @@ -42,14 +72,8 @@ namespace nap { box.getMax().x, box.getMax().y, box.getMax().z }, }; } - - const static std::vector sUnitLineBox = getBoxFrameMeshVertices({1, 1, 1 }); - const static std::vector sNormalizedLineBox = getBoxFrameMeshVertices({2, 2, 2 }); - - constexpr static uint sQuadVertCount = 4; //< Number of vertices per quad - constexpr static uint sQuadCount = 2; //< Total number of quad - constexpr static uint sLineVertCount = 2; //< Total number of vertices per line - constexpr static uint sLineCount = 4; //< Total number of lines + const static std::vector sUnitLineBox = getBoxFrameMeshVertices({ 1, 1, 1 }); + const static std::vector sNormalizedLineBox = getBoxFrameMeshVertices({ 2, 2, 2 }); ////////////////////////////////////////////////////////////////////////// @@ -62,6 +86,15 @@ namespace nap bool BoxFrameMesh::init(utility::ErrorState& errorState) + { + if (!mIsSetupManually) + setup(); + + return mMeshInstance->init(errorState); + } + + + bool BoxFrameMesh::setup(const math::Box& box, utility::ErrorState& errorState) { // Create mesh instance assert(mRenderService != nullptr); @@ -74,36 +107,8 @@ namespace nap mMeshInstance->setDrawMode(EDrawMode::Lines); mMeshInstance->setCullMode(ECullMode::None); - if (!mIsSetupManually) - setup(); - - return mMeshInstance->init(errorState); - } - - - bool BoxFrameMesh::setup(const math::Box& box, utility::ErrorState& errorState) - { - // Generate the indices std::vector indices; - indices.reserve(sQuadCount * sQuadVertCount * 2 + sLineCount * sLineVertCount); - - // Index offsets to shape a single quad face - static const std::vector quad_index_offsets = { 0, 1, 1, 2, 2, 3, 3, 0 }; - - // Repeat twice generating two quads - for (uint i = 0; i < sQuadCount; i++) - { - const uint quad_offset = i * sQuadVertCount; - for (uint off : quad_index_offsets) - indices.emplace_back(quad_offset + off); - } - - // Connect the mirroring edges of the quads - for (uint i = 0; i < sLineCount; i++) - { - indices.emplace_back(i); - indices.emplace_back(i + sQuadVertCount); - } + setupIndices(indices); // Create attributes auto& position_attribute = mMeshInstance->getOrCreateAttribute(vertexid::position); @@ -120,27 +125,19 @@ namespace nap void BoxFrameMesh::setup() { - // Generate the indices - std::vector indices; - indices.reserve(sQuadCount * sQuadVertCount * 2 + sLineCount * sLineVertCount); - - // Index offsets to shape a single quad face - static const std::vector quad_index_offsets = { 0, 1, 1, 2, 2, 3, 3, 0 }; + // Create mesh instance + assert(mRenderService != nullptr); + mMeshInstance = std::make_unique(*mRenderService); - // Repeat twice generating two quads - for (uint i = 0; i < sQuadCount; i++) - { - const uint quad_offset = i * sQuadVertCount; - for (uint off : quad_index_offsets) - indices.emplace_back(quad_offset + off); - } + // Persistent configuration + mMeshInstance->setNumVertices(sNormalizedLineBox.size()); + mMeshInstance->setUsage(mUsage); + mMeshInstance->setPolygonMode(EPolygonMode::Line); + mMeshInstance->setDrawMode(EDrawMode::Lines); + mMeshInstance->setCullMode(ECullMode::None); - // Connect the mirroring edges of the quads - for (uint i = 0; i < sLineCount; i++) - { - indices.emplace_back(i); - indices.emplace_back(i + sQuadVertCount); - } + std::vector indices; + setupIndices(indices); // Create attributes auto& position_attribute = mMeshInstance->getOrCreateAttribute(vertexid::position); diff --git a/system_modules/naprenderadvanced/src/boxframemesh.h b/system_modules/naprenderadvanced/src/boxframemesh.h index eb4b977e55..8559285c5d 100644 --- a/system_modules/naprenderadvanced/src/boxframemesh.h +++ b/system_modules/naprenderadvanced/src/boxframemesh.h @@ -52,7 +52,7 @@ namespace nap /** * @return the unit line box from (-0.5, -0.5, -0.5) to (0.5, 0.5, 0.5) */ - const std::vector& getUnitLineBox(); + static const std::vector& getUnitLineBox(); /** * @return the normalized line box from (-1, -1, -1) to (1, 1, 1) From 15bfa6d7c9ec8beaf0015bf15d2b77063d2a65a5 Mon Sep 17 00:00:00 2001 From: lshoek Date: Mon, 2 Mar 2026 11:04:48 +0100 Subject: [PATCH 07/15] add getorcreatematerial to renderskyboxcomponent --- .../naprenderadvanced/src/renderskyboxcomponent.cpp | 1 + system_modules/naprenderadvanced/src/renderskyboxcomponent.h | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/system_modules/naprenderadvanced/src/renderskyboxcomponent.cpp b/system_modules/naprenderadvanced/src/renderskyboxcomponent.cpp index 7b50f7c772..5bfaf3aeaf 100644 --- a/system_modules/naprenderadvanced/src/renderskyboxcomponent.cpp +++ b/system_modules/naprenderadvanced/src/renderskyboxcomponent.cpp @@ -26,6 +26,7 @@ RTTI_END_CLASS RTTI_BEGIN_CLASS_NO_DEFAULT_CONSTRUCTOR(nap::RenderSkyBoxComponentInstance) RTTI_CONSTRUCTOR(nap::EntityInstance&, nap::Component&) + RTTI_FUNCTION(nap::material::instance::getOrCreateMaterial, &nap::RenderSkyBoxComponentInstance::getOrCreateMaterial) RTTI_END_CLASS namespace nap diff --git a/system_modules/naprenderadvanced/src/renderskyboxcomponent.h b/system_modules/naprenderadvanced/src/renderskyboxcomponent.h index 55ae97913b..a92f12e90e 100644 --- a/system_modules/naprenderadvanced/src/renderskyboxcomponent.h +++ b/system_modules/naprenderadvanced/src/renderskyboxcomponent.h @@ -100,6 +100,11 @@ namespace nap */ float getOpacity() const { return mAlphaUniform->getValue(); } + /** + * @return material handle + */ + MaterialInstance* getOrCreateMaterial() { return &mMaterialInstance; } + protected: /** * Draws the skybox to the given render target From b9396ce5c1cf97e2cc12f925d4355920e985a630 Mon Sep 17 00:00:00 2001 From: lshoek Date: Mon, 2 Mar 2026 11:08:46 +0100 Subject: [PATCH 08/15] make getNormalizedLineBox static --- system_modules/naprenderadvanced/src/boxframemesh.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system_modules/naprenderadvanced/src/boxframemesh.h b/system_modules/naprenderadvanced/src/boxframemesh.h index 8559285c5d..6804c19c19 100644 --- a/system_modules/naprenderadvanced/src/boxframemesh.h +++ b/system_modules/naprenderadvanced/src/boxframemesh.h @@ -57,7 +57,7 @@ namespace nap /** * @return the normalized line box from (-1, -1, -1) to (1, 1, 1) */ - const std::vector& getNormalizedLineBox(); + static const std::vector& getNormalizedLineBox(); EMemoryUsage mUsage = EMemoryUsage::Static; ///< Property: 'Usage' If the mesh is uploaded once or frequently updated From 843d804fdf3d67afcabdcf19bfa045cba3664957 Mon Sep 17 00:00:00 2001 From: lshoek Date: Wed, 4 Mar 2026 12:29:51 +0100 Subject: [PATCH 09/15] fix boxframemesh dynamicwrite multiple setup --- .../naprenderadvanced/src/boxframemesh.cpp | 47 ++++++++++--------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/system_modules/naprenderadvanced/src/boxframemesh.cpp b/system_modules/naprenderadvanced/src/boxframemesh.cpp index 3a298927eb..1ca2d3b44c 100644 --- a/system_modules/naprenderadvanced/src/boxframemesh.cpp +++ b/system_modules/naprenderadvanced/src/boxframemesh.cpp @@ -96,27 +96,30 @@ namespace nap bool BoxFrameMesh::setup(const math::Box& box, utility::ErrorState& errorState) { - // Create mesh instance assert(mRenderService != nullptr); - mMeshInstance = std::make_unique(*mRenderService); - - // Persistent configuration - mMeshInstance->setNumVertices(sNormalizedLineBox.size()); - mMeshInstance->setUsage(mUsage); - mMeshInstance->setPolygonMode(EPolygonMode::Line); - mMeshInstance->setDrawMode(EDrawMode::Lines); - mMeshInstance->setCullMode(ECullMode::None); - - std::vector indices; - setupIndices(indices); + if (mMeshInstance == nullptr) + { + // Create mesh instance + mMeshInstance = std::make_unique(*mRenderService); + + // Persistent configuration + mMeshInstance->setNumVertices(sNormalizedLineBox.size()); + mMeshInstance->setUsage(mUsage); + mMeshInstance->setPolygonMode(EPolygonMode::Line); + mMeshInstance->setDrawMode(EDrawMode::Lines); + mMeshInstance->setCullMode(ECullMode::None); + + std::vector indices; + setupIndices(indices); + + // Create the shape + auto& shape = mMeshInstance->createShape(); + shape.setIndices(indices.data(), indices.size()); + } // Create attributes - auto& position_attribute = mMeshInstance->getOrCreateAttribute(vertexid::position); - position_attribute.setData(getBoxFrameMeshVertices(box)); - - // Create the shape - auto& shape = mMeshInstance->createShape(); - shape.setIndices(indices.data(), indices.size()); + auto& attr = mMeshInstance->getOrCreateAttribute(vertexid::position); + attr.setData(getBoxFrameMeshVertices(box)); mIsSetupManually = true; return true; @@ -136,13 +139,13 @@ namespace nap mMeshInstance->setDrawMode(EDrawMode::Lines); mMeshInstance->setCullMode(ECullMode::None); + // Create attributes + auto& attr = mMeshInstance->getOrCreateAttribute(vertexid::position); + attr.setData(sUnitLineBox); + std::vector indices; setupIndices(indices); - // Create attributes - auto& position_attribute = mMeshInstance->getOrCreateAttribute(vertexid::position); - position_attribute.setData(sUnitLineBox); - // Create the shape auto& shape = mMeshInstance->createShape(); shape.setIndices(indices.data(), indices.size()); From 1d42ff6309a83c50a2fbe12c430dd5cd5ff1c558 Mon Sep 17 00:00:00 2001 From: lshoek Date: Wed, 4 Mar 2026 11:54:07 +0100 Subject: [PATCH 10/15] port imgui sliderfloat calls in some demos --- demos/audioanalysis/src/audioanalysisapp.cpp | 8 ++++---- demos/lightsandshadow/src/lightsandshadowapp.cpp | 6 +++--- demos/oscmidi/src/oscmidi.cpp | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/demos/audioanalysis/src/audioanalysisapp.cpp b/demos/audioanalysis/src/audioanalysisapp.cpp index c900fd71b1..3e79a61336 100644 --- a/demos/audioanalysis/src/audioanalysisapp.cpp +++ b/demos/audioanalysis/src/audioanalysisapp.cpp @@ -96,10 +96,10 @@ namespace nap // Draw some gui elements ImGui::SetNextWindowSize(ImVec2(512, 512), ImGuiCond_FirstUseEver); ImGui::Begin("Audio analysis"); - ImGui::PlotHistogram("", mPlotvalues.data(), mPlotvalues.size(), mTickIdx, nullptr, 0.0f, 0.2f, ImVec2(ImGui::GetColumnWidth(), 128)); // Plot the output values - ImGui::SliderFloat("Filter Frequency", &mAnalysisFrequency, 0.0f, 10000.0f, "%.3f", 2.0f); - ImGui::SliderFloat("Filter Bandwidth", &mAnalysisBand, 1.f, 10000.0f, "%.3f", 2.0f); - ImGui::SliderFloat("Audio Gain", &mAnalysisGain, 0.5f, 5.f, "%.3f", 1.f); + ImGui::PlotHistogram("Histogram", mPlotvalues.data(), mPlotvalues.size(), mTickIdx, nullptr, 0.0f, 0.2f, ImVec2(ImGui::GetColumnWidth(), 128)); // Plot the output values + ImGui::SliderFloat("Filter Frequency", &mAnalysisFrequency, 0.0f, 10000.0f, "%.3f", ImGuiSliderFlags_Logarithmic); + ImGui::SliderFloat("Filter Bandwidth", &mAnalysisBand, 1.f, 10000.0f, "%.3f", ImGuiSliderFlags_Logarithmic); + ImGui::SliderFloat("Audio Gain", &mAnalysisGain, 0.5f, 5.f, "%.3f"); if (ImGui::RadioButton("Audio file input", mInputSource == EAudioFile)) mInputSource = EAudioFile; if (ImGui::RadioButton("Audio device input", mInputSource == EAudioDevice)) diff --git a/demos/lightsandshadow/src/lightsandshadowapp.cpp b/demos/lightsandshadow/src/lightsandshadowapp.cpp index b639d2fad3..15c6e06cfa 100644 --- a/demos/lightsandshadow/src/lightsandshadowapp.cpp +++ b/demos/lightsandshadow/src/lightsandshadowapp.cpp @@ -87,15 +87,15 @@ namespace nap light.setColor(color); auto inten = light.getIntensity(); - if (ImGui::SliderFloat("Intensity", &inten, 0.0f, 5.0f, "%.3f", 2.0f)) + if (ImGui::SliderFloat("Intensity", &inten, 0.0f, 5.0f, "%.3f", ImGuiSliderFlags_Logarithmic)) light.setIntensity(inten); auto shadow = light.getShadowStrength(); - if (ImGui::SliderFloat("Shadow Strength", &shadow, 0.0f, 1.0f, "%.3f", 1.0f)) + if (ImGui::SliderFloat("Shadow Strength", &shadow, 0.0f, 1.0f, "%.3f")) light.setShadowStrength(shadow); auto spread = light.getShadowSpread(); - if (ImGui::SliderFloat("Shadow Spread", &spread, 0.0f, 10.0f, "%.3f", 1.0f)) + if (ImGui::SliderFloat("Shadow Spread", &spread, 0.0f, 10.0f, "%.3f")) light.setShadowSpread(spread); } diff --git a/demos/oscmidi/src/oscmidi.cpp b/demos/oscmidi/src/oscmidi.cpp index e05c9e8ceb..4a0e1d268e 100644 --- a/demos/oscmidi/src/oscmidi.cpp +++ b/demos/oscmidi/src/oscmidi.cpp @@ -215,7 +215,7 @@ namespace nap std::string display_string = utility::stringFormat("Send OSC message to: %s, port: %d, with the specified address and value", mOscSender->mIPAddress.c_str(), mOscSender->mPort); ImGui::Text(display_string.c_str()); ImGui::InputText("Address", &mOscOutputTag[0], mOscOutputTag.capacity()); - ImGui::SliderFloat("Value", &mOscOutputValue, 0.f, 1.f, "%.3f", 1); + ImGui::SliderFloat("Value", &mOscOutputValue, 0.f, 1.f, "%.3f"); if (ImGui::Button("Send")) { std::string address = "/" + std::string(mOscOutputTag.data()); From 5ed5a45b53bf4e08c302a93eda4e5982d761243b Mon Sep 17 00:00:00 2001 From: lshoek Date: Wed, 4 Mar 2026 12:02:08 +0100 Subject: [PATCH 11/15] resize and generalize buffer dummies --- demos/audiovisualfft/data/objects.json | 40 +++++++++++++------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/demos/audiovisualfft/data/objects.json b/demos/audiovisualfft/data/objects.json index fde6d863b7..d4f10223ee 100644 --- a/demos/audiovisualfft/data/objects.json +++ b/demos/audiovisualfft/data/objects.json @@ -63,9 +63,6 @@ "StereoPanning": 0.5, "AutoPlay": false, "StartPosition": 17000.0, - "Duration": 0.0, - "FadeInTime": 0.0, - "FadeOutTime": 0.0, "Pitch": 1.0 }, { @@ -194,25 +191,25 @@ "Type": "nap::BufferBindingVec4", "mID": "InPositions_2c26c4bb", "Name": "InPositions", - "Buffer": "PositionBufferDummy" + "Buffer": "Vec4BufferDummy" }, { "Type": "nap::BufferBindingVec4", "mID": "OutPositions_94e6febd", "Name": "OutPositions", - "Buffer": "PositionBufferDummy" + "Buffer": "Vec4BufferDummy" }, { "Type": "nap::BufferBindingVec4", "mID": "InNormals_2817da11", "Name": "InNormals", - "Buffer": "PositionBufferDummy" + "Buffer": "Vec4BufferDummy" }, { "Type": "nap::BufferBindingVec4", "mID": "OutNormals_bb180dba", "Name": "OutNormals", - "Buffer": "PositionBufferDummy" + "Buffer": "Vec4BufferDummy" } ], "Constants": [ @@ -253,7 +250,7 @@ "Type": "nap::BufferBindingVec4", "mID": "Positions_07091c33", "Name": "Positions", - "Buffer": "PositionBufferDummy" + "Buffer": "Vec4BufferDummy" }, { "Type": "nap::BufferBindingUInt", @@ -265,25 +262,25 @@ "Type": "nap::BufferBindingVec4", "mID": "OutNormals_57d4a5a7", "Name": "OutNormals", - "Buffer": "PositionBufferDummy" + "Buffer": "Vec4BufferDummy" }, { "Type": "nap::BufferBindingUInt", "mID": "Triangles_ee9855e9", "Name": "Triangles", - "Buffer": "TriangleBufferDummy" + "Buffer": "UIntBufferDummy" }, { "Type": "nap::BufferBindingInt", "mID": "Adjacency_638d952e", "Name": "Adjacency", - "Buffer": "AdjacencyBufferDummy" + "Buffer": "IntBufferDummy" }, { "Type": "nap::BufferBindingVec4", "mID": "InNormals_88aa8533", "Name": "InNormals", - "Buffer": "PositionBufferDummy" + "Buffer": "Vec4BufferDummy" } ], "Constants": [ @@ -673,6 +670,7 @@ 255 ] }, + "Clear": true, "SampleShading": false, "PreserveAspect": true } @@ -1394,9 +1392,9 @@ }, { "Type": "nap::VertexBufferVec4", - "mID": "PositionBufferDummy", + "mID": "Vec4BufferDummy", "Usage": "Static", - "Count": 262144, + "Count": 1, "Clear": false, "FillPolicy": "" }, @@ -1420,23 +1418,23 @@ "Type": "nap::IndexBuffer", "mID": "IndexBufferDummy", "Usage": "Static", - "Count": 1565190, + "Count": 1, "Clear": false, "FillPolicy": "" }, { "Type": "nap::VertexBufferUInt", - "mID": "TriangleBufferDummy", + "mID": "UIntBufferDummy", "Usage": "Static", - "Count": 1565190, + "Count": 1, "Clear": false, "FillPolicy": "" }, { "Type": "nap::GPUBufferInt", - "mID": "AdjacencyBufferDummy", + "mID": "IntBufferDummy", "Usage": "Static", - "Count": 1572864, + "Count": 1, "Clear": false, "FillPolicy": "" }, @@ -1556,7 +1554,9 @@ { "Type": "nap::audio::AudioFileResource", "mID": "AudioFile", - "AudioFilePath": "hang.mp3" + "AudioFilePath": "hang.mp3", + "Resample": false, + "ResampleMode": "Sinc Fastest" } ] } \ No newline at end of file From 4b20b4b1e1364a9a4c51ebcabc7f4054be509852 Mon Sep 17 00:00:00 2001 From: lshoek Date: Wed, 4 Mar 2026 12:07:44 +0100 Subject: [PATCH 12/15] remove unused constant --- demos/audiovisualfft/data/shaders/normals.comp | 1 - 1 file changed, 1 deletion(-) diff --git a/demos/audiovisualfft/data/shaders/normals.comp b/demos/audiovisualfft/data/shaders/normals.comp index 20cab20b0c..d6369ef737 100644 --- a/demos/audiovisualfft/data/shaders/normals.comp +++ b/demos/audiovisualfft/data/shaders/normals.comp @@ -14,7 +14,6 @@ layout(constant_id = 0) const uint MAX_GROUP_SIZE_X = 32; // Derive attribute buffer sizes from plane dimensions const uint ROW_COUNT = 1024; const uint COLUMN_COUNT = 256; -const uint CELL_COUNT = (ROW_COUNT-1)*(COLUMN_COUNT-1); const uint MAX_ADJACENT_TRI_COUNT = 6; const uint VERTS_PER_TRI_COUNT = 3; From c9c637eb06bfde71e50e9c38addaf3fb33dd036e Mon Sep 17 00:00:00 2001 From: lshoek Date: Wed, 4 Mar 2026 11:54:51 +0100 Subject: [PATCH 13/15] remove unnecessary buffer size constants in audiovisualfft --- demos/audiovisualfft/data/shaders/normals.comp | 17 +++++------------ .../audiovisualfft/data/shaders/positions.comp | 5 ++--- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/demos/audiovisualfft/data/shaders/normals.comp b/demos/audiovisualfft/data/shaders/normals.comp index d6369ef737..04fc8e4173 100644 --- a/demos/audiovisualfft/data/shaders/normals.comp +++ b/demos/audiovisualfft/data/shaders/normals.comp @@ -16,39 +16,32 @@ const uint ROW_COUNT = 1024; const uint COLUMN_COUNT = 256; const uint MAX_ADJACENT_TRI_COUNT = 6; -const uint VERTS_PER_TRI_COUNT = 3; -const uint TRIS_PER_CELL_COUNT = 2; -const uint INDS_PER_TRI_COUNT = 3; - -const uint POSITION_COUNT = ROW_COUNT*COLUMN_COUNT; -const uint TRIANGLE_COUNT = CELL_COUNT*TRIS_PER_CELL_COUNT; -const uint TRIANGLE_INDEX_COUNT = TRIANGLE_COUNT*INDS_PER_TRI_COUNT; const float EPSILON = 0.0001; layout(std430) readonly buffer Positions { - vec4 positions[POSITION_COUNT]; + vec4 positions[]; }; layout(std430) readonly buffer Triangles { - uint triangles[TRIANGLE_INDEX_COUNT]; + uint triangles[]; }; layout(std430) readonly buffer Adjacency { - int adjacency[POSITION_COUNT*MAX_ADJACENT_TRI_COUNT]; + int adjacency[]; }; layout(std430) readonly buffer InNormals { - vec4 innormals[POSITION_COUNT]; + vec4 innormals[]; }; layout(std430) writeonly buffer OutNormals { - vec4 outnormals[POSITION_COUNT]; + vec4 outnormals[]; }; struct triangle diff --git a/demos/audiovisualfft/data/shaders/positions.comp b/demos/audiovisualfft/data/shaders/positions.comp index ae0a4fc792..cba90a1b81 100644 --- a/demos/audiovisualfft/data/shaders/positions.comp +++ b/demos/audiovisualfft/data/shaders/positions.comp @@ -20,16 +20,15 @@ layout(constant_id = 0) const uint MAX_GROUP_SIZE_X = 32; // Derive attribute buffer sizes from plane dimensions const uint ROW_COUNT = 1024; const uint COLUMN_COUNT = 256; -const uint POSITION_COUNT = ROW_COUNT*COLUMN_COUNT; layout(std430) readonly buffer InPositions { - vec4 inpositions[POSITION_COUNT]; + vec4 inpositions[]; }; layout(std430) writeonly buffer OutPositions { - vec4 outpositions[POSITION_COUNT]; + vec4 outpositions[]; }; uniform UBO From 0c744ef62ccc45f1308b355ebc9a0010b92be02b Mon Sep 17 00:00:00 2001 From: lshoek Date: Wed, 4 Mar 2026 09:39:28 +0100 Subject: [PATCH 14/15] favor auto in renderskybox --- .../naprenderadvanced/src/renderskyboxcomponent.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/system_modules/naprenderadvanced/src/renderskyboxcomponent.cpp b/system_modules/naprenderadvanced/src/renderskyboxcomponent.cpp index 5bfaf3aeaf..c8899dd52a 100644 --- a/system_modules/naprenderadvanced/src/renderskyboxcomponent.cpp +++ b/system_modules/naprenderadvanced/src/renderskyboxcomponent.cpp @@ -167,7 +167,7 @@ namespace nap mModelMatUniform->setValue(mTransformComponent->getGlobalTransform()); // Acquire new / unique descriptor set before rendering - const DescriptorSet& descriptor_set = mMaterialInstance.update(); + const auto& descriptor_set = mMaterialInstance.update(); // Fetch and bind pipeline utility::ErrorState error_state; @@ -178,15 +178,15 @@ namespace nap vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline.mLayout, 0, 1, &descriptor_set.mSet, 0, nullptr); // Bind vertex buffers - const std::vector& vertex_buffers = mRenderableMesh.getVertexBuffers(); - const std::vector& offsets = mRenderableMesh.getVertexBufferOffsets(); + const auto& vertex_buffers = mRenderableMesh.getVertexBuffers(); + const auto& offsets = mRenderableMesh.getVertexBufferOffsets(); vkCmdBindVertexBuffers(commandBuffer, 0, vertex_buffers.size(), vertex_buffers.data(), offsets.data()); // Draw meshes - MeshInstance& mesh_instance = mSkyBoxMesh.getMeshInstance(); - GPUMesh& mesh = mesh_instance.getGPUMesh(); + auto& mesh_instance = mSkyBoxMesh.getMeshInstance(); + auto& mesh = mesh_instance.getGPUMesh(); - const IndexBuffer& index_buffer = mesh.getIndexBuffer(0); + const auto& index_buffer = mesh.getIndexBuffer(0); vkCmdBindIndexBuffer(commandBuffer, index_buffer.getBuffer(), 0, VK_INDEX_TYPE_UINT32); vkCmdDrawIndexed(commandBuffer, index_buffer.getCount(), 1, 0, 0, 0); From 8cd9dbaecac7276951da40424608212fb91a05a1 Mon Sep 17 00:00:00 2001 From: lshoek Date: Wed, 4 Mar 2026 10:06:38 +0100 Subject: [PATCH 15/15] favor getcontentregionavail in flocking demo --- demos/computeflocking/src/computeflockingapp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demos/computeflocking/src/computeflockingapp.cpp b/demos/computeflocking/src/computeflockingapp.cpp index ad1ecce20f..eaf01bcc1c 100644 --- a/demos/computeflocking/src/computeflockingapp.cpp +++ b/demos/computeflocking/src/computeflockingapp.cpp @@ -123,7 +123,7 @@ namespace nap if (ImGui::CollapsingHeader("Bloom Texture", ImGuiTreeNodeFlags_DefaultOpen)) { const float aspect = coloradjust_comp->getOutputTexture().getHeight() / static_cast(coloradjust_comp->getOutputTexture().getWidth()); - const float width = ImGui::GetWindowContentRegionWidth(); + const float width = ImGui::GetContentRegionAvail().x; ImGui::Image(coloradjust_comp->getOutputTexture(), { width, width * aspect }); } ImGui::End();