MNE-CPP  0.1.9
A Framework for Electrophysiology
gpuinterpolationmaterial.cpp
Go to the documentation of this file.
1 //=============================================================================================================
36 //=============================================================================================================
37 // INCLUDES
38 //=============================================================================================================
39 
41 
42 //=============================================================================================================
43 // QT INCLUDES
44 //=============================================================================================================
45 
46 #include <Qt3DRender/QEffect>
47 #include <Qt3DRender/QParameter>
48 #include <Qt3DRender/QRenderPass>
49 #include <Qt3DRender/QFilterKey>
50 #include <Qt3DRender/QTechnique>
51 #include <Qt3DRender/QShaderProgram>
52 #include <Qt3DRender/QGraphicsApiFilter>
53 #include <QUrl>
54 
55 //=============================================================================================================
56 // EIGEN INCLUDES
57 //=============================================================================================================
58 
59 //=============================================================================================================
60 // USED NAMESPACES
61 //=============================================================================================================
62 
63 using namespace DISP3DLIB;
64 using namespace Qt3DRender;
65 
66 //=============================================================================================================
67 // DEFINE GLOBAL METHODS
68 //=============================================================================================================
69 
70 //=============================================================================================================
71 // DEFINE MEMBER METHODS
72 //=============================================================================================================
73 
74 GpuInterpolationMaterial::GpuInterpolationMaterial(bool bUseSortPolicy, Qt3DCore::QNode *parent)
75  : AbstractPhongAlphaMaterial(bUseSortPolicy, parent)
76  , m_pComputeShader(new QShaderProgram)
77  , m_pComputeRenderPass(new QRenderPass)
78  , m_pComputeFilterKey(new QFilterKey)
79  , m_pComputeTechnique(new QTechnique)
80  , m_pDrawShader(new QShaderProgram)
81  , m_pDrawRenderPass(new QRenderPass)
82  , m_pDrawTechnique(new QTechnique)
83  , m_pSignalDataParameter(new QParameter)
84  , m_pColsParameter(new QParameter)
85  , m_pRowsParameter(new QParameter)
86  , m_pInterpolationMatParameter(new QParameter)
87  , m_pOutputColorParameter(new QParameter)
88  , m_pThresholdXParameter(new QParameter(QStringLiteral("fThresholdX"), 1e-10f))
89  , m_pThresholdZParameter(new QParameter(QStringLiteral("fThresholdZ"), 6e-6f))
90  , m_pColormapParameter(new QParameter(QStringLiteral("ColormapType"), 3))
91 {
92  init();
93  setShaderCode();
94 }
95 
96 //=============================================================================================================
97 
99 {
100  //Compute part
101  //Set OpenGL version
102  m_pComputeTechnique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGL);
103  m_pComputeTechnique->graphicsApiFilter()->setMajorVersion(4);
104  m_pComputeTechnique->graphicsApiFilter()->setMinorVersion(3);
105  m_pComputeTechnique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::CoreProfile);
106 
107  //Set filter Keys
108  m_pComputeFilterKey->setName(QStringLiteral("renderingStyle"));
109  m_pComputeFilterKey->setValue(QStringLiteral("compute"));
110 
111  //Add to technique
114 
115  //Set default Interpolation matrix parameters
116  m_pColsParameter->setName(QStringLiteral("cols"));
117  m_pColsParameter->setValue(1);
118  m_pRowsParameter->setName(QStringLiteral("rows"));
119  m_pRowsParameter->setValue(1);
120  m_pInterpolationMatParameter->setName(QStringLiteral("InterpolationMat"));
121 
122  //Set default output
123  m_pOutputColorParameter->setName(QStringLiteral("OutputColor"));
124 
125  //Set default input
126  m_pSignalDataParameter->setName(QStringLiteral("InputVec"));
127 
128  //Add compute Parameter
129  m_pComputeRenderPass->addParameter(m_pColsParameter);
130  m_pComputeRenderPass->addParameter(m_pRowsParameter);
134 
135  //Add Threshold parameter
138 
139  //Add ColormapType
141 
142  //Draw part
143  //Add Phongalpha parameter
144  m_pDrawRenderPass->addParameter(m_pDiffuseParameter);
147  m_pDrawRenderPass->addParameter(m_pAlphaParameter);
148 
149  //Set OpenGL version
150  m_pDrawTechnique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGL);
151  m_pDrawTechnique->graphicsApiFilter()->setMajorVersion(4);
152  m_pDrawTechnique->graphicsApiFilter()->setMinorVersion(3);
153  m_pDrawTechnique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::CoreProfile);
154 
155  //Add to technique
156  m_pDrawTechnique->addFilterKey(m_pDrawFilterKey);
157  m_pDrawTechnique->addRenderPass(m_pDrawRenderPass);
158 
159  //Effect
160  //Link shader and uniforms
161  m_pEffect->addTechnique(m_pComputeTechnique);
162  m_pEffect->addTechnique(m_pDrawTechnique);
163 
164  //Add to material
165  this->setEffect(m_pEffect);
166 }
167 
168 //=============================================================================================================
169 
171 {
172  m_pComputeShader->setComputeShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/engine/model/materials/shaders/compute/interpolation.csh"))));
173  m_pComputeRenderPass->setShaderProgram(m_pComputeShader);
174 
175  m_pDrawShader->setVertexShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/engine/model/materials/shaders/compute/interpolation.vert"))));
176  m_pDrawShader->setFragmentShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/engine/model/materials/shaders/compute/interpolation.frag"))));
177  m_pDrawRenderPass->setShaderProgram(m_pDrawShader);
178 }
179 
180 //=============================================================================================================
181 
DISP3DLIB::AbstractPhongAlphaMaterial::m_pSpecularParameter
QPointer< Qt3DRender::QParameter > m_pSpecularParameter
Definition: abstractphongalphamaterial.h:161
DISP3DLIB::GpuInterpolationMaterial::m_pColsParameter
QPointer< Qt3DRender::QParameter > m_pColsParameter
Definition: gpuinterpolationmaterial.h:141
DISP3DLIB::GpuInterpolationMaterial::m_pDrawShader
QPointer< Qt3DRender::QShaderProgram > m_pDrawShader
Definition: gpuinterpolationmaterial.h:133
DISP3DLIB::GpuInterpolationMaterial::m_pSignalDataParameter
QPointer< Qt3DRender::QParameter > m_pSignalDataParameter
Definition: gpuinterpolationmaterial.h:138
DISP3DLIB::AbstractPhongAlphaMaterial::m_pAlphaParameter
QPointer< Qt3DRender::QParameter > m_pAlphaParameter
Definition: abstractphongalphamaterial.h:163
gpuinterpolationmaterial.h
GpuInterpolationMaterial class declaration.
DISP3DLIB::GpuInterpolationMaterial::m_pThresholdZParameter
QPointer< Qt3DRender::QParameter > m_pThresholdZParameter
Definition: gpuinterpolationmaterial.h:150
DISP3DLIB::GpuInterpolationMaterial::m_pComputeShader
QPointer< Qt3DRender::QShaderProgram > m_pComputeShader
Definition: gpuinterpolationmaterial.h:127
DISP3DLIB::AbstractPhongAlphaMaterial::m_pEffect
QPointer< Qt3DRender::QEffect > m_pEffect
Definition: abstractphongalphamaterial.h:158
DISP3DLIB::AbstractPhongAlphaMaterial::m_pDiffuseParameter
QPointer< Qt3DRender::QParameter > m_pDiffuseParameter
Definition: abstractphongalphamaterial.h:160
DISP3DLIB::GpuInterpolationMaterial::m_pDrawRenderPass
QPointer< Qt3DRender::QRenderPass > m_pDrawRenderPass
Definition: gpuinterpolationmaterial.h:134
DISP3DLIB::GpuInterpolationMaterial::m_pColormapParameter
QPointer< Qt3DRender::QParameter > m_pColormapParameter
Definition: gpuinterpolationmaterial.h:153
DISP3DLIB::GpuInterpolationMaterial::m_pComputeFilterKey
QPointer< Qt3DRender::QFilterKey > m_pComputeFilterKey
Definition: gpuinterpolationmaterial.h:129
DISP3DLIB::GpuInterpolationMaterial::m_pDrawTechnique
QPointer< Qt3DRender::QTechnique > m_pDrawTechnique
Definition: gpuinterpolationmaterial.h:135
DISP3DLIB::GpuInterpolationMaterial::m_pInterpolationMatParameter
QPointer< Qt3DRender::QParameter > m_pInterpolationMatParameter
Definition: gpuinterpolationmaterial.h:143
DISP3DLIB::AbstractPhongAlphaMaterial::m_pShininessParameter
QPointer< Qt3DRender::QParameter > m_pShininessParameter
Definition: abstractphongalphamaterial.h:162
DISP3DLIB::GpuInterpolationMaterial::m_pRowsParameter
QPointer< Qt3DRender::QParameter > m_pRowsParameter
Definition: gpuinterpolationmaterial.h:142
DISP3DLIB::GpuInterpolationMaterial::setShaderCode
void setShaderCode() override
Definition: gpuinterpolationmaterial.cpp:170
DISP3DLIB::AbstractPhongAlphaMaterial
This abstract class is used as a base class for all materials that are using the phong alpha lightini...
Definition: abstractphongalphamaterial.h:84
DISP3DLIB::AbstractPhongAlphaMaterial::m_pDrawFilterKey
QPointer< Qt3DRender::QFilterKey > m_pDrawFilterKey
Definition: abstractphongalphamaterial.h:165
DISP3DLIB::GpuInterpolationMaterial::GpuInterpolationMaterial
GpuInterpolationMaterial(bool bUseSortPolicy=false, Qt3DCore::QNode *parent=nullptr)
Definition: gpuinterpolationmaterial.cpp:74
DISP3DLIB::GpuInterpolationMaterial::m_pComputeRenderPass
QPointer< Qt3DRender::QRenderPass > m_pComputeRenderPass
Definition: gpuinterpolationmaterial.h:128
DISP3DLIB::GpuInterpolationMaterial::m_pComputeTechnique
QPointer< Qt3DRender::QTechnique > m_pComputeTechnique
Definition: gpuinterpolationmaterial.h:130
DISP3DLIB::GpuInterpolationMaterial::init
void init() override
Definition: gpuinterpolationmaterial.cpp:98
DISP3DLIB::GpuInterpolationMaterial::m_pOutputColorParameter
QPointer< Qt3DRender::QParameter > m_pOutputColorParameter
Definition: gpuinterpolationmaterial.h:146
DISP3DLIB::GpuInterpolationMaterial::m_pThresholdXParameter
QPointer< Qt3DRender::QParameter > m_pThresholdXParameter
Definition: gpuinterpolationmaterial.h:149