Skip to content
Open
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
4782a9e
[render] add CrossSectionUniforms class
alemuntoni Mar 31, 2026
73726c7
[render] add CrossSectionUniforms shader header
alemuntoni Mar 31, 2026
45d28b3
[render] Add cross-section uniforms and controls to drawable mesh cla…
alemuntoni Mar 31, 2026
9409624
[render] per vertex and per fragment cross section
alemuntoni Mar 31, 2026
9207f49
[render] implement cross section for drawable mesh surface
alemuntoni Mar 31, 2026
16622eb
[render] Refactor cross section settings into CrossSectionSettings cl…
alemuntoni Apr 1, 2026
ca6a604
[render] Fix input on surface fragment shaders
alemuntoni Apr 2, 2026
907d79f
[render] Rename settingsUpdated signal to meshRenderSettingsUpdated t…
alemuntoni Apr 2, 2026
6462ce1
[render] CrossSectionSettingsFrame class
alemuntoni Apr 2, 2026
aba1c42
[render] Add cross-section controls and signal handlers to settings f…
alemuntoni Apr 2, 2026
b0ecf72
[render] add X slider to CrossSectionFrame
alemuntoni Apr 2, 2026
1d11f09
[render] CrossSectionFrame x slider working as expected
alemuntoni Apr 2, 2026
5720c7d
[render] CrossSectionSettingsFrame working
alemuntoni Apr 2, 2026
b886a33
Merge branch 'main' into cross_section
alemuntoni Apr 3, 2026
d7a0b96
Merge branch 'main' into cross_section
alemuntoni Apr 3, 2026
efdaa00
[render] Refactor cross-section discard logic into reusable shader ma…
alemuntoni Apr 10, 2026
e6e2f7b
[render] Add cross-section clipping to mesh surface pbr and surface I…
alemuntoni Apr 10, 2026
cbf32a3
[render] DrawableMesh: Refactor cross-section uniform updates into up…
alemuntoni Apr 10, 2026
c468fbd
[render] Add cross-section clipping support to points_instance shaders
alemuntoni Apr 10, 2026
94ea469
Merge branch 'main' into cross_section
alemuntoni Apr 13, 2026
72739a0
[render] Move CrossSectionSettings from drawable/mesh to render/setti…
alemuntoni Apr 13, 2026
81802a2
[render] Add CrossSection clipping to lines
alemuntoni Apr 13, 2026
42cb29b
[render] Move CrossSectionSettingsFrame to tab widget and update UI s…
alemuntoni Apr 13, 2026
88eb967
[render] separate cross section inputs/outputs in all the shaders
alemuntoni Apr 13, 2026
1f13489
[render] varying.def indent fixes
alemuntoni Apr 13, 2026
7cb33ad
Merge branch 'main' into cross_section
alemuntoni Apr 15, 2026
74d8efe
[render] cross section on primitve points shader
alemuntoni Apr 15, 2026
8203e19
[render] cross section on primitive lines
alemuntoni Apr 15, 2026
4b4d736
[render] small fixes
alemuntoni Apr 15, 2026
6e5c88a
[render] enable cross section for all remaining surface shaders
alemuntoni Apr 15, 2026
5519c74
[space] add isStrictlyBelow and isStrictlyAbove member functions to P…
alemuntoni Apr 17, 2026
e969dfb
[render] Add bounds checks and signal blocking to cross-section UI se…
alemuntoni Apr 17, 2026
5d7b8b5
[render] Improve cross section settings handling and UI state synchro…
alemuntoni Apr 17, 2026
2a75ff4
[space] isStrictly[Below/Above] member functions renamed to all[Less/…
alemuntoni Apr 17, 2026
b6fb4d6
[render] Refactor CrossSectionSettings bbox logic and fix UI checkbox…
alemuntoni Apr 17, 2026
5f14a15
[render] Add per-fragment flag to uniforms and handle null bounding b…
alemuntoni Apr 17, 2026
3dae7d0
[render] Initialize mCrossSectionFrame to nullptr and update frame on…
alemuntoni Apr 17, 2026
4b59cfe
[render] cpu lines - Apply near-plane clipping to v_worldPos0 and v_w…
alemuntoni Apr 18, 2026
7e8e197
Merge branch 'main' into cross_section
alemuntoni Apr 29, 2026
6b83ef3
Merge branch 'main' into cross_section
alemuntoni May 4, 2026
f24f616
Merge branch 'main' into cross_section
alemuntoni May 14, 2026
570839a
Merge branch 'main' into cross_section
alemuntoni May 19, 2026
7066ed2
Merge branch 'main' into cross_section
alemuntoni Jun 6, 2026
943c1bc
[render] fix dx build error
alemuntoni Jun 7, 2026
f03ff10
[render] fix CrossSectionSettings lower and upper reset when bbox set
alemuntoni Jun 7, 2026
dd8dd52
Merge branch 'main' into cross_section
alemuntoni Jun 22, 2026
55453aa
Merge branch 'main' into cross_section
alemuntoni Jun 29, 2026
a8bd1d9
[render] fix msvc build error
alemuntoni Jun 29, 2026
eef66d4
Merge branch 'main' into cross_section
alemuntoni Jun 29, 2026
7ad34a9
Merge branch 'main' into cross_section
alemuntoni Jun 30, 2026
40aaf45
[render] fix not renamed settings updated signal
alemuntoni Jul 1, 2026
587f82c
Merge branch 'main' into cross_section
alemuntoni Jul 1, 2026
d36a567
Merge branch 'main' into cross_section
alemuntoni Jul 1, 2026
f53ae04
[render] Add section-enabled surface shading options and update shade…
alemuntoni Jul 1, 2026
eea2629
[render] fix dx error: initialize unused varying variables with defau…
alemuntoni Jul 1, 2026
fbf66a4
Merge branch 'main' into cross_section
alemuntoni Jul 1, 2026
f9f7325
Merge branch 'main' into cross_section
alemuntoni Jul 2, 2026
d99b605
Merge branch 'main' into cross_section
alemuntoni Jul 2, 2026
b7ba307
[render] Rename SECTION dimension from ENABLED/DISABLED to ON/OFF in …
alemuntoni Jul 2, 2026
b73a1c6
Merge branch 'main' into cross_section
alemuntoni Jul 7, 2026
fe6445e
Merge branch 'main' into cross_section
alemuntoni Jul 9, 2026
ef19c89
Merge branch 'main' into cross_section
alemuntoni Jul 15, 2026
115faa8
[render] Synchronize cross section settings and bounding boxes in app…
alemuntoni Jul 15, 2026
9473b29
Merge branch 'main' into cross_section
alemuntoni Jul 15, 2026
2ad6421
[render] Add step size control for cross section precision with spin …
alemuntoni Jul 15, 2026
6c7e156
Merge branch 'main' into cross_section
alemuntoni Jul 16, 2026
a45b883
Merge branch 'main' into cross_section
alemuntoni Jul 17, 2026
e012b80
Merge branch 'main' into cross_section
alemuntoni Jul 17, 2026
f7debb6
[render] Add cross section support to point rendering and relevant sh…
alemuntoni Jul 17, 2026
87de1b0
Merge branch 'main' into cross_section
alemuntoni Jul 17, 2026
64985ec
Merge branch 'main' into cross_section
alemuntoni Jul 24, 2026
6e56429
Merge branch 'main' into cross_section
alemuntoni Jul 31, 2026
1e82844
[tests] add cross section tests
alemuntoni Jul 31, 2026
eaf80f2
Merge branch 'main' into cross_section
alemuntoni Aug 1, 2026
44c4da5
Merge branch 'main' into cross_section
alemuntoni Aug 2, 2026
8f628fd
[render] using StaticUniforms for CrossSectionSettings
alemuntoni Aug 2, 2026
37c8cdd
Merge branch 'main' into cross_section
alemuntoni Aug 4, 2026
28bbd62
[render] cross section working on new primitive lines
alemuntoni Aug 4, 2026
f29e548
[tests] wireframe cross section test
alemuntoni Aug 4, 2026
dca96b8
Merge branch 'main' into cross_section
alemuntoni Aug 9, 2026
c95ce12
[tests] fix build error
alemuntoni Aug 9, 2026
a5d1e7e
Merge branch 'main' into cross_section
alemuntoni Aug 22, 2026
f41f7ed
Merge branch 'main' into cross_section
alemuntoni Aug 22, 2026
2b1a1b8
Merge branch 'main' into cross_section
alemuntoni Sep 1, 2026
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
64 changes: 64 additions & 0 deletions vclib/core/include/vclib/space/core/point.h
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,70 @@ class Point : public Eigen::Matrix<Scalar, N, 1>
at(i) = args[i];
}

/**
* @brief Returns true if all the components of this point are strictly less
* than the corresponding components of another point p1.
*
* @param[in] p1: The Point object to compare with.
* @return true if this point is strictly below p1, false otherwise.
*/
bool allLessThan(const Point& p1) const
{
for (uint i = 0; i < N; i++) {
if (at(i) >= p1(i))
return false;
}
return true;
}

/**
* @brief Returns true if all the components of this point are less than or
* equal to the corresponding components of another point p1.
*
* @param[in] p1: The Point object to compare with.
* @return true if this point is below or equal to p1, false otherwise.
*/
bool allLessEqualThan(const Point& p1) const
{
for (uint i = 0; i < N; i++) {
if (at(i) > p1(i))
return false;
}
return true;
}

/**
* @brief Returns true if all the components of this point are strictly
* greater than the corresponding components of another point p1.
*
* @param[in] p1: The Point object to compare with.
* @return true if this point is strictly above p1, false otherwise.
*/
bool allGreaterThan(const Point& p1) const
{
for (uint i = 0; i < N; i++) {
if (at(i) <= p1(i))
return false;
}
return true;
}

/**
* @brief Returns true if all the components of this point are greater than
* or equal to the corresponding components of another point p1.
*
* @param[in] p1: The Point object to compare with.
* @return true if this point is above or equal to p1, false otherwise.
*/
bool allGreaterEqualThan(const Point& p1) const
{
for (uint i = 0; i < N; i++) {
if (at(i) < p1(i))
return false;
}
return true;
}

/**
* @brief Returns the outer product between this point p and p1, which is
* p * p1^T
Expand Down
29 changes: 29 additions & 0 deletions vclib/render/include/vclib/bgfx/drawable/drawable_mesh_bgfx.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <vclib/bgfx/context.h>
#include <vclib/bgfx/drawable/drawable_environment.h>
#include <vclib/bgfx/drawable/mesh/mesh_render_buffers.h>
#include <vclib/bgfx/drawable/uniforms/cross_section_uniforms.h>
#include <vclib/bgfx/drawable/uniforms/mesh_render_settings_uniforms.h>

#include <bgfx/bgfx.h>
Expand Down Expand Up @@ -137,6 +138,9 @@ class DrawableMeshBGFX : public AbstractDrawableMesh, public MeshType
mMRB.update(*this, buffersToUpdate);
mMRS.setRenderCapabilityFrom(*this);
setRenderSettings(mMRS);

mCSS.setBoundingBox(*this);
mMRB.updateCrossSectionSettings(mCSS);
}

void setRenderSettings(const MeshRenderSettings& rs) override
Expand All @@ -146,6 +150,12 @@ class DrawableMeshBGFX : public AbstractDrawableMesh, public MeshType
mMRB.updateWireframeSettings(rs);
}

void setCrossSectionSettings(const CrossSectionSettings& css) override
{
AbstractDrawableMesh::setCrossSectionSettings(css);
mMRB.updateCrossSectionSettings(css);
}

uint vertexCount() const override { return MeshType::vertexCount(); }

uint faceCount() const override
Expand Down Expand Up @@ -216,6 +226,8 @@ class DrawableMeshBGFX : public AbstractDrawableMesh, public MeshType
DrawableMeshUniforms::setColor(*this);
MeshRenderSettingsUniforms::set(mMRS);

updateCrossSectionUniforms();

if (mMRS.isSurface(MRI::Surface::VISIBLE)) {
const PBRViewerSettings& pbrSettings = settings.pbrSettings;
const DrawableEnvironment* env = settings.environment;
Expand Down Expand Up @@ -337,6 +349,8 @@ class DrawableMeshBGFX : public AbstractDrawableMesh, public MeshType
model = MeshType::transformMatrix().template cast<float>();
}

updateCrossSectionUniforms();

if (mMRS.isSurface(MRI::Surface::VISIBLE)) {
mMRB.bindVertexBuffers(mMRS);
mMRB.bindIndexBuffers(mMRS);
Expand Down Expand Up @@ -407,6 +421,21 @@ class DrawableMeshBGFX : public AbstractDrawableMesh, public MeshType
{
MeshRenderSettingsUniforms::bind();
DrawableMeshUniforms::bind();
CrossSectionUniforms::bind();
}

void updateCrossSectionUniforms() const
{
if (AbstractDrawableMesh::mCSS.isEnabled()) {
using enum CrossSectionSettings::CrossSectionType;
CrossSectionUniforms::set(
AbstractDrawableMesh::mCSS.lower(),
AbstractDrawableMesh::mCSS.upper(),
AbstractDrawableMesh::mCSS.type() == PER_FRAGMENT);
}
else {
CrossSectionUniforms::set();
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,12 @@ class MeshRenderBuffers : public MeshRenderData<MeshRenderBuffers<Mesh>>
}
}

void updateCrossSectionSettings(const CrossSectionSettings& css)
{
mEdgeLines.crossSectionSettings() = css;
mWireframeLines.crossSectionSettings() = css;
}

private:
void setVertexPositionsBuffer(const MeshType& mesh) // override
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/*****************************************************************************
* VCLib *
* Visual Computing Library *
* *
* Copyright(C) 2021-2026 *
* Visual Computing Lab *
* ISTI - Italian National Research Council *
* *
* All rights reserved. *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the Mozilla Public License Version 2.0 as published *
* by the Mozilla Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* Mozilla Public License Version 2.0 *
* (https://www.mozilla.org/en-US/MPL/2.0/) for more details. *
****************************************************************************/

#ifndef VCL_BGFX_DRAWABLE_UNIFORMS_CROSS_SECTION_UNIFORMS_H
#define VCL_BGFX_DRAWABLE_UNIFORMS_CROSS_SECTION_UNIFORMS_H

#include <vclib/bgfx/uniform.h>

#include <vclib/space/core.h>

namespace vcl {

class CrossSectionUniforms
{
inline static std::array<float, 4> sCrossSectionMinData = {
Point3f::min().x(), // x min
Point3f::min().y(), // y min
Point3f::min().z(), // z min
0.0 // per-fragment flag
// (0.0 = per-vertex, 1.0 = per-fragment)
};

inline static std::array<float, 4> sCrossSectionMaxData = {
Point3f::max().x(), // x max
Point3f::max().y(), // y max
Point3f::max().z(), // z max
0.0 // unused
};
Comment thread
alemuntoni marked this conversation as resolved.

inline static Uniform sCrossSectionMinDataUniform;
inline static Uniform sCrossSectionMaxDataUniform;

public:
CrossSectionUniforms() = delete;

static void set(
const Point3f& minPoint = Point3f::min(),
const Point3f& maxPoint = Point3f::max(),
bool perFragment = false)
{
sCrossSectionMinData[0] = minPoint.x();
sCrossSectionMinData[1] = minPoint.y();
sCrossSectionMinData[2] = minPoint.z();
sCrossSectionMinData[3] = float(perFragment);

sCrossSectionMaxData[0] = maxPoint.x();
sCrossSectionMaxData[1] = maxPoint.y();
sCrossSectionMaxData[2] = maxPoint.z();
}

static void bind()
{
// lazy initialization
// to avoid creating uniforms before bgfx is initialized
if (!sCrossSectionMinDataUniform.isValid())
sCrossSectionMinDataUniform =
Uniform("u_crossSectionMinData", bgfx::UniformType::Vec4);
if (!sCrossSectionMaxDataUniform.isValid())
sCrossSectionMaxDataUniform =
Uniform("u_crossSectionMaxData", bgfx::UniformType::Vec4);
sCrossSectionMinDataUniform.bind(sCrossSectionMinData.data());
sCrossSectionMaxDataUniform.bind(sCrossSectionMaxData.data());
}
};

} // namespace vcl

#endif // VCL_BGFX_DRAWABLE_UNIFORMS_CROSS_SECTION_UNIFORMS_H
37 changes: 37 additions & 0 deletions vclib/render/include/vclib/bgfx/primitives/lines.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@
#ifndef VCL_BGFX_PRIMITIVES_LINES_H
#define VCL_BGFX_PRIMITIVES_LINES_H

#include <vclib/bgfx/drawable/uniforms/cross_section_uniforms.h>
#include <vclib/bgfx/primitives/lines/cpu_generated_lines.h>
#include <vclib/bgfx/primitives/lines/primitive_lines.h>
#include <vclib/bgfx/uniform.h>

#include <vclib/render/settings/cross_section_settings.h>

#include <vclib/base.h>
#include <vclib/space/core.h>

Expand Down Expand Up @@ -90,6 +93,8 @@ class Lines
ColorToUse mColorToUse = ColorToUse::GENERAL;
Color mGeneralColor = Color::ColorABGR::LightGray;

CrossSectionSettings mCrossSectionSettings;

ImplementationType mType = ImplementationType::COUNT;

std::variant<detail::PrimitiveLines, detail::CPUGeneratedLines>
Expand Down Expand Up @@ -385,6 +390,25 @@ class Lines
*/
Color& generalColor() { return mGeneralColor; }

/**
* @brief Returns the current cross section settings.
* @return The current cross section settings.
*/
const CrossSectionSettings& crossSectionSettings() const
{
return mCrossSectionSettings;
}

/**
* @brief Returns a reference to the current cross section settings. This
* allows to modify the settings directly.
* @return A reference to the current cross section settings.
*/
CrossSectionSettings& crossSectionSettings()
{
return mCrossSectionSettings;
}

/**
* @brief Returns the current implementation type that is used to render
* the lines.
Expand Down Expand Up @@ -533,6 +557,19 @@ class Lines
std::bit_cast<float>(mGeneralColor.abgr()),
mDepthOffset};
sSettingUH.bind(data);

// cross section settings
if (mCrossSectionSettings.isEnabled()) {
using enum CrossSectionSettings::CrossSectionType;
CrossSectionUniforms::set(
mCrossSectionSettings.lower(),
mCrossSectionSettings.upper(),
mCrossSectionSettings.type() == PER_FRAGMENT);
}
else {
CrossSectionUniforms::set();
}
CrossSectionUniforms::bind();
}
};

Expand Down
13 changes: 11 additions & 2 deletions vclib/render/include/vclib/qt/gui/mesh_render_settings_frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@
#ifndef VCL_QT_GUI_MESH_RENDER_SETTINGS_FRAME_H
#define VCL_QT_GUI_MESH_RENDER_SETTINGS_FRAME_H

#include "mesh_render_settings_frame/cross_section_settings_frame.h"
#include "mesh_render_settings_frame/generic_mesh_render_settings_frame.h"

#include <vclib/render/drawable/mesh/mesh_render_settings.h>
#include <vclib/render/settings/cross_section_settings.h>

#include <QFrame>

Expand All @@ -44,20 +46,27 @@ class MeshRenderSettingsFrame : public QFrame
Ui::MeshRenderSettingsFrame* mUI;
MeshRenderSettings mMRS;

std::vector<GenericMeshRenderSettingsFrame*> frames;
std::vector<GenericMeshRenderSettingsFrame*> mFrames;
CrossSectionSettingsFrame* mCrossSectionFrame = nullptr;

public:
explicit MeshRenderSettingsFrame(QWidget* parent = nullptr);
~MeshRenderSettingsFrame();

const MeshRenderSettings& meshRenderSettings() const;

const CrossSectionSettings& crossSectionSettings() const;

void setMeshRenderSettings(
const MeshRenderSettings& settings,
bool changeCurrentTab = false);

void setCrossSectionSettings(const CrossSectionSettings& settings);

signals:
void settingsUpdated();
void meshRenderSettingsUpdated();

void crossSectionSettingsUpdated();

private:
enum { POINTS_FRAME = 0, SURFACE_FRAME, WIREFRAME_FRAME, EDGES_FRAME };
Expand Down
Loading
Loading