39 Qt3DRender::QEffect *materialEffect = effect();
40 if ( !materialEffect )
45 if ( clipPlanesEquations.isEmpty() )
51 for ( Qt3DRender::QTechnique *technique : materialEffect->techniques() )
53 for ( Qt3DRender::QRenderPass *renderPass : technique->renderPasses() )
55 Qt3DRender::QShaderProgram *shaderProgram = renderPass->shaderProgram();
56 const QByteArray geomCode = shaderProgram->geometryShaderCode();
57 if ( !geomCode.isEmpty() )
60 shaderProgram->setGeometryShaderCode( newGeomCode );
63 const QByteArray vertexCode = shaderProgram->vertexShaderCode();
64 if ( !vertexCode.isEmpty() )
67 shaderProgram->setVertexShaderCode( newVertexCode );
73 const int nrClipPlanes = clipPlanesEquations.size();
74 QVariantList clipPlanesEquationsVariant = QVariantList();
75 for (
int i = 0; i < nrClipPlanes; ++i )
77 clipPlanesEquationsVariant << clipPlanesEquations[i];
79 Qt3DRender::QParameter *clipPlane =
new Qt3DRender::QParameter( QgsMaterial::CLIP_PLANE_ARRAY_PARAMETER_NAME, clipPlanesEquationsVariant );
80 Qt3DRender::QParameter *clipPlaneNumber =
new Qt3DRender::QParameter( QgsMaterial::CLIP_PLANE_MAX_PLANE_PARAMETER_NAME, nrClipPlanes );
82 materialEffect->addParameter( clipPlane );
83 materialEffect->addParameter( clipPlaneNumber );
85 mClippingEnabled =
true;
90 Qt3DRender::QEffect *materialEffect = effect();
91 if ( !materialEffect || !mClippingEnabled )
95 for ( Qt3DRender::QTechnique *technique : materialEffect->techniques() )
97 for ( Qt3DRender::QRenderPass *renderPass : technique->renderPasses() )
99 Qt3DRender::QShaderProgram *shaderProgram = renderPass->shaderProgram();
100 const QByteArray geomCode = shaderProgram->geometryShaderCode();
101 if ( !geomCode.isEmpty() )
104 shaderProgram->setGeometryShaderCode( newGeomCode );
107 const QByteArray vertexCode = shaderProgram->vertexShaderCode();
108 if ( !vertexCode.isEmpty() )
111 shaderProgram->setVertexShaderCode( newVertexCode );
117 for ( Qt3DRender::QParameter *parameter : materialEffect->parameters() )
119 const QString parameterName = parameter->name();
120 if ( parameterName == QgsMaterial::CLIP_PLANE_ARRAY_PARAMETER_NAME || parameterName == QgsMaterial::CLIP_PLANE_MAX_PLANE_PARAMETER_NAME )
122 materialEffect->removeParameter( parameter );
127 mClippingEnabled =
false;