summaryrefslogtreecommitdiffstats
path: root/src/extras/defaults/qtexturedmetalroughmaterial.cpp
diff options
context:
space:
mode:
authorKevin Ottens <kevin.ottens@kdab.com>2017-05-31 16:46:41 +0200
committerSean Harmer <sean.harmer@kdab.com>2017-07-05 16:13:38 +0000
commit63c30b44f475359afc0e27b31b040ba84996e1ad (patch)
tree7eb611779eb7b4a645d6ed14771f65b7e2a3c125 /src/extras/defaults/qtexturedmetalroughmaterial.cpp
parent4bb9b413f0c409fa7d5b59988dcb0da0f3a1456a (diff)
Port Metal/Rough materials to shader graphs
This allows to validate the approach with a couple of functioning materials using the new shader generation system. Also allows to have a few prototypes in the default set of nodes. Clearly the system is still cumbersome to use as can be seen from the multiplication of prototypes, we shall improve that next by allowing more expressivity in the graph JSON to allow more control (clearly telling on the uniforms, return type for the functions, etc.). Change-Id: I3edfef65af288faa339661f20d5e640cf00e9234 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/extras/defaults/qtexturedmetalroughmaterial.cpp')
-rw-r--r--src/extras/defaults/qtexturedmetalroughmaterial.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/extras/defaults/qtexturedmetalroughmaterial.cpp b/src/extras/defaults/qtexturedmetalroughmaterial.cpp
index e09517866..9de8ec522 100644
--- a/src/extras/defaults/qtexturedmetalroughmaterial.cpp
+++ b/src/extras/defaults/qtexturedmetalroughmaterial.cpp
@@ -45,6 +45,7 @@
#include <Qt3DRender/qtexture.h>
#include <Qt3DRender/qtechnique.h>
#include <Qt3DRender/qshaderprogram.h>
+#include <Qt3DRender/qshaderprogrambuilder.h>
#include <Qt3DRender/qparameter.h>
#include <Qt3DRender/qrenderpass.h>
#include <Qt3DRender/qgraphicsapifilter.h>
@@ -78,6 +79,7 @@ QTexturedMetalRoughMaterialPrivate::QTexturedMetalRoughMaterialPrivate()
, m_metalRoughGL3Technique(new QTechnique())
, m_metalRoughGL3RenderPass(new QRenderPass())
, m_metalRoughGL3Shader(new QShaderProgram())
+ , m_metalRoughGL3ShaderBuilder(new QShaderProgramBuilder())
, m_filterKey(new QFilterKey)
{
m_baseColorTexture->setMagnificationFilter(QAbstractTexture::Linear);
@@ -125,6 +127,8 @@ QTexturedMetalRoughMaterialPrivate::QTexturedMetalRoughMaterialPrivate()
void QTexturedMetalRoughMaterialPrivate::init()
{
+ Q_Q(QTexturedMetalRoughMaterial);
+
connect(m_baseColorParameter, &Qt3DRender::QParameter::valueChanged,
this, &QTexturedMetalRoughMaterialPrivate::handleBaseColorChanged);
connect(m_metalnessParameter, &Qt3DRender::QParameter::valueChanged,
@@ -137,14 +141,16 @@ void QTexturedMetalRoughMaterialPrivate::init()
this, &QTexturedMetalRoughMaterialPrivate::handleNormalChanged);
m_metalRoughGL3Shader->setVertexShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/gl3/metalrough.vert"))));
- m_metalRoughGL3Shader->setFragmentShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/gl3/metalrough.frag"))));
+
+ m_metalRoughGL3ShaderBuilder->setParent(q);
+ m_metalRoughGL3ShaderBuilder->setShaderProgram(m_metalRoughGL3Shader);
+ m_metalRoughGL3ShaderBuilder->setFragmentShaderGraph(QUrl(QStringLiteral("qrc:/shaders/graphs/metalrough.frag.json")));
m_metalRoughGL3Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGL);
m_metalRoughGL3Technique->graphicsApiFilter()->setMajorVersion(3);
m_metalRoughGL3Technique->graphicsApiFilter()->setMinorVersion(1);
m_metalRoughGL3Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::CoreProfile);
- Q_Q(QTexturedMetalRoughMaterial);
m_filterKey->setParent(q);
m_filterKey->setName(QStringLiteral("renderingStyle"));
m_filterKey->setValue(QStringLiteral("forward"));