mirror of https://github.com/qt/qt3d.git
Fix QMorphPhongMaterial
Replace the removed phong.frag with graph-based fragment shader. Task-number: QTBUG-69751 Change-Id: I196be25aff656d6934d6179e4f082430b109b2a1 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
This commit is contained in:
parent
c8e95f8409
commit
d05d2fd3d2
|
|
@ -44,6 +44,7 @@
|
||||||
#include <Qt3DRender/qparameter.h>
|
#include <Qt3DRender/qparameter.h>
|
||||||
#include <Qt3DRender/qrenderpass.h>
|
#include <Qt3DRender/qrenderpass.h>
|
||||||
#include <Qt3DRender/qgraphicsapifilter.h>
|
#include <Qt3DRender/qgraphicsapifilter.h>
|
||||||
|
#include <Qt3DRender/qshaderprogrambuilder.h>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QVector3D>
|
#include <QVector3D>
|
||||||
#include <QVector4D>
|
#include <QVector4D>
|
||||||
|
|
@ -57,9 +58,9 @@ namespace Qt3DExtras {
|
||||||
QMorphPhongMaterialPrivate::QMorphPhongMaterialPrivate()
|
QMorphPhongMaterialPrivate::QMorphPhongMaterialPrivate()
|
||||||
: QMaterialPrivate()
|
: QMaterialPrivate()
|
||||||
, m_phongEffect(new QEffect())
|
, m_phongEffect(new QEffect())
|
||||||
, m_ambientParameter(new QParameter(QStringLiteral("ka"), QColor::fromRgbF(0.05f, 0.05f, 0.05f, 1.0f)))
|
, m_ambientParameter(new QParameter(QStringLiteral("ka"), QColor::fromRgbF(0.05, 0.05, 0.05, 1.0)))
|
||||||
, m_diffuseParameter(new QParameter(QStringLiteral("kd"), QColor::fromRgbF(0.7f, 0.7f, 0.7f, 1.0f)))
|
, m_diffuseParameter(new QParameter(QStringLiteral("kd"), QColor::fromRgbF(0.7, 0.7, 0.7, 1.0)))
|
||||||
, m_specularParameter(new QParameter(QStringLiteral("ks"), QColor::fromRgbF(0.01f, 0.01f, 0.01f, 1.0f)))
|
, m_specularParameter(new QParameter(QStringLiteral("ks"), QColor::fromRgbF(0.01, 0.01, 0.01, 1.0)))
|
||||||
, m_shininessParameter(new QParameter(QStringLiteral("shininess"), 150.0f))
|
, m_shininessParameter(new QParameter(QStringLiteral("shininess"), 150.0f))
|
||||||
, m_interpolatorParameter(new QParameter(QStringLiteral("interpolator"), 0.0f))
|
, m_interpolatorParameter(new QParameter(QStringLiteral("interpolator"), 0.0f))
|
||||||
, m_phongGL3Technique(new QTechnique())
|
, m_phongGL3Technique(new QTechnique())
|
||||||
|
|
@ -70,12 +71,16 @@ QMorphPhongMaterialPrivate::QMorphPhongMaterialPrivate()
|
||||||
, m_phongES2RenderPass(new QRenderPass())
|
, m_phongES2RenderPass(new QRenderPass())
|
||||||
, m_phongGL3Shader(new QShaderProgram())
|
, m_phongGL3Shader(new QShaderProgram())
|
||||||
, m_phongGL2ES2Shader(new QShaderProgram())
|
, m_phongGL2ES2Shader(new QShaderProgram())
|
||||||
|
, m_phongGL3ShaderBuilder(new QShaderProgramBuilder())
|
||||||
|
, m_phongGL2ES2ShaderBuilder(new QShaderProgramBuilder())
|
||||||
, m_filterKey(new QFilterKey)
|
, m_filterKey(new QFilterKey)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void QMorphPhongMaterialPrivate::init()
|
void QMorphPhongMaterialPrivate::init()
|
||||||
{
|
{
|
||||||
|
Q_Q(QMorphPhongMaterial);
|
||||||
|
|
||||||
connect(m_ambientParameter, &Qt3DRender::QParameter::valueChanged,
|
connect(m_ambientParameter, &Qt3DRender::QParameter::valueChanged,
|
||||||
this, &QMorphPhongMaterialPrivate::handleAmbientChanged);
|
this, &QMorphPhongMaterialPrivate::handleAmbientChanged);
|
||||||
connect(m_diffuseParameter, &Qt3DRender::QParameter::valueChanged,
|
connect(m_diffuseParameter, &Qt3DRender::QParameter::valueChanged,
|
||||||
|
|
@ -88,9 +93,19 @@ void QMorphPhongMaterialPrivate::init()
|
||||||
this, &QMorphPhongMaterialPrivate::handleInterpolatorChanged);
|
this, &QMorphPhongMaterialPrivate::handleInterpolatorChanged);
|
||||||
|
|
||||||
m_phongGL3Shader->setVertexShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/gl3/morphphong.vert"))));
|
m_phongGL3Shader->setVertexShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/gl3/morphphong.vert"))));
|
||||||
m_phongGL3Shader->setFragmentShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/gl3/phong.frag"))));
|
m_phongGL3ShaderBuilder->setParent(q);
|
||||||
|
m_phongGL3ShaderBuilder->setShaderProgram(m_phongGL3Shader);
|
||||||
|
m_phongGL3ShaderBuilder->setFragmentShaderGraph(QUrl(QStringLiteral("qrc:/shaders/graphs/phong.frag.json")));
|
||||||
|
m_phongGL3ShaderBuilder->setEnabledLayers({QStringLiteral("diffuse"),
|
||||||
|
QStringLiteral("specular"),
|
||||||
|
QStringLiteral("normal")});
|
||||||
m_phongGL2ES2Shader->setVertexShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/es2/morphphong.vert"))));
|
m_phongGL2ES2Shader->setVertexShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/es2/morphphong.vert"))));
|
||||||
m_phongGL2ES2Shader->setFragmentShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/es2/phong.frag"))));
|
m_phongGL2ES2ShaderBuilder->setParent(q);
|
||||||
|
m_phongGL2ES2ShaderBuilder->setShaderProgram(m_phongGL2ES2Shader);
|
||||||
|
m_phongGL2ES2ShaderBuilder->setFragmentShaderGraph(QUrl(QStringLiteral("qrc:/shaders/graphs/phong.frag.json")));
|
||||||
|
m_phongGL2ES2ShaderBuilder->setEnabledLayers({QStringLiteral("diffuse"),
|
||||||
|
QStringLiteral("specular"),
|
||||||
|
QStringLiteral("normal")});
|
||||||
|
|
||||||
m_phongGL3Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGL);
|
m_phongGL3Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGL);
|
||||||
m_phongGL3Technique->graphicsApiFilter()->setMajorVersion(3);
|
m_phongGL3Technique->graphicsApiFilter()->setMajorVersion(3);
|
||||||
|
|
@ -115,7 +130,6 @@ void QMorphPhongMaterialPrivate::init()
|
||||||
m_phongGL2Technique->addRenderPass(m_phongGL2RenderPass);
|
m_phongGL2Technique->addRenderPass(m_phongGL2RenderPass);
|
||||||
m_phongES2Technique->addRenderPass(m_phongES2RenderPass);
|
m_phongES2Technique->addRenderPass(m_phongES2RenderPass);
|
||||||
|
|
||||||
Q_Q(QMorphPhongMaterial);
|
|
||||||
m_filterKey->setParent(q);
|
m_filterKey->setParent(q);
|
||||||
m_filterKey->setName(QStringLiteral("renderingStyle"));
|
m_filterKey->setName(QStringLiteral("renderingStyle"));
|
||||||
m_filterKey->setValue(QStringLiteral("forward"));
|
m_filterKey->setValue(QStringLiteral("forward"));
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,7 @@ class QTechnique;
|
||||||
class QParameter;
|
class QParameter;
|
||||||
class QShaderProgram;
|
class QShaderProgram;
|
||||||
class QRenderPass;
|
class QRenderPass;
|
||||||
|
class QShaderProgramBuilder;
|
||||||
|
|
||||||
} // namespace Qt3DRender
|
} // namespace Qt3DRender
|
||||||
|
|
||||||
|
|
@ -94,6 +95,8 @@ public:
|
||||||
Qt3DRender::QRenderPass *m_phongES2RenderPass;
|
Qt3DRender::QRenderPass *m_phongES2RenderPass;
|
||||||
Qt3DRender::QShaderProgram *m_phongGL3Shader;
|
Qt3DRender::QShaderProgram *m_phongGL3Shader;
|
||||||
Qt3DRender::QShaderProgram *m_phongGL2ES2Shader;
|
Qt3DRender::QShaderProgram *m_phongGL2ES2Shader;
|
||||||
|
Qt3DRender::QShaderProgramBuilder *m_phongGL3ShaderBuilder;
|
||||||
|
Qt3DRender::QShaderProgramBuilder *m_phongGL2ES2ShaderBuilder;
|
||||||
Qt3DRender::QFilterKey *m_filterKey;
|
Qt3DRender::QFilterKey *m_filterKey;
|
||||||
|
|
||||||
Q_DECLARE_PUBLIC(QMorphPhongMaterial)
|
Q_DECLARE_PUBLIC(QMorphPhongMaterial)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue