40 Qt3DRender::QEffect *materialEffect = effect();
41 if ( !materialEffect )
46 if ( clipPlanesEquations.isEmpty() )
52 for ( Qt3DRender::QTechnique *technique : materialEffect->techniques() )
54 for ( Qt3DRender::QRenderPass *renderPass : technique->renderPasses() )
56 Qt3DRender::QShaderProgram *shaderProgram = renderPass->shaderProgram();
57 const QByteArray geomCode = shaderProgram->geometryShaderCode();
58 if ( !geomCode.isEmpty() )
61 shaderProgram->setGeometryShaderCode( newGeomCode );
64 const QByteArray vertexCode = shaderProgram->vertexShaderCode();
65 if ( !vertexCode.isEmpty() )
68 shaderProgram->setVertexShaderCode( newVertexCode );
74 const int nrClipPlanes = clipPlanesEquations.size();
75 QVariantList clipPlanesEquationsVariant = QVariantList();
76 for (
int i = 0; i < nrClipPlanes; ++i )
78 clipPlanesEquationsVariant << clipPlanesEquations[i];
80 Qt3DRender::QParameter *clipPlane =
new Qt3DRender::QParameter( QgsMaterial::CLIP_PLANE_ARRAY_PARAMETER_NAME, clipPlanesEquationsVariant );
81 Qt3DRender::QParameter *clipPlaneNumber =
new Qt3DRender::QParameter( QgsMaterial::CLIP_PLANE_MAX_PLANE_PARAMETER_NAME, nrClipPlanes );
83 materialEffect->addParameter( clipPlane );
84 materialEffect->addParameter( clipPlaneNumber );
86 mClippingEnabled =
true;
91 Qt3DRender::QEffect *materialEffect = effect();
92 if ( !materialEffect || !mClippingEnabled )
96 for ( Qt3DRender::QTechnique *technique : materialEffect->techniques() )
98 for ( Qt3DRender::QRenderPass *renderPass : technique->renderPasses() )
100 Qt3DRender::QShaderProgram *shaderProgram = renderPass->shaderProgram();
101 const QByteArray geomCode = shaderProgram->geometryShaderCode();
102 if ( !geomCode.isEmpty() )
105 shaderProgram->setGeometryShaderCode( newGeomCode );
108 const QByteArray vertexCode = shaderProgram->vertexShaderCode();
109 if ( !vertexCode.isEmpty() )
112 shaderProgram->setVertexShaderCode( newVertexCode );
118 for ( Qt3DRender::QParameter *parameter : materialEffect->parameters() )
120 const QString parameterName = parameter->name();
121 if ( parameterName == QgsMaterial::CLIP_PLANE_ARRAY_PARAMETER_NAME || parameterName == QgsMaterial::CLIP_PLANE_MAX_PLANE_PARAMETER_NAME )
123 materialEffect->removeParameter( parameter );
128 mClippingEnabled =
false;