Skip to content

Commit

Permalink
qgspointcloud3dsymbol: Add support for gl_ClipDistance
Browse files Browse the repository at this point in the history
This is achieved with two changes:
1. define the plane equation as uniform with the
`Qgs3DUtils::addBoundingBoxParametersToEffect` call
2. include `clipplane.inc` file in the vertex shader file and call
setClipDistance()

With these changes, the planes defined in the framegraph are used.
  • Loading branch information
ptitjano committed Jul 3, 2024
1 parent 021d68c commit 4be7612
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/3d/shaders/pointcloud.vert
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ out vec3 pointColor;
out vec3 worldPosition; //used when points are triangulated
out vec3 vertNorm; //used when points are triangulated

#pragma include clipplane.inc

void main(void)
{
gl_Position = modelViewProjection * vec4(vertexPosition, 1);
Expand All @@ -49,4 +51,6 @@ void main(void)
classParameter = int(vertexParameter);
break;
}

setClipDistance(worldPosition);
}
2 changes: 2 additions & 0 deletions src/3d/symbols/qgspointcloud3dsymbol_p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "qgspointcloudindex.h"
#include "qgspointcloudblockrequest.h"
#include "qgsfeedback.h"
#include "qgs3dutils.h"

#include <Qt3DRender/QGeometryRenderer>
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
Expand Down Expand Up @@ -316,6 +317,7 @@ void QgsPointCloud3DSymbolHandler::makeEntity( Qt3DCore::QEntity *parent, const
technique->addParameter( new Qt3DRender::QParameter( "triangulate", !out.triangles.isEmpty() ) );

Qt3DRender::QEffect *eff = new Qt3DRender::QEffect;
Qgs3DUtils::addBoundingBoxParametersToEffect( eff, context.map() );
eff->addTechnique( technique );
mat->setEffect( eff );

Expand Down

0 comments on commit 4be7612

Please sign in to comment.