Encapsulates a Shader Program. More...
Header: | #include <QShaderProgram> |
qmake: | QT += 3drender |
Since: | Qt 5.5 |
Instantiated By: | ShaderProgram |
Inherits: | Qt3DCore::QNode |
This class was introduced in Qt 5.5.
enum | Format { GLSL, SPIRV } |
enum | ShaderType { Vertex, Fragment, TessellationControl, TessellationEvaluation, Geometry, Compute } |
enum | Status { NotReady, Ready, Error } |
|
|
QByteArray | computeShaderCode() const |
Qt3DRender::QShaderProgram::Format | format() const |
QByteArray | fragmentShaderCode() const |
QByteArray | geometryShaderCode() const |
QString | log() const |
void | setFormat(Qt3DRender::QShaderProgram::Format format) |
void | setShaderCode(Qt3DRender::QShaderProgram::ShaderType type, const QByteArray &shaderCode) |
QByteArray | shaderCode(Qt3DRender::QShaderProgram::ShaderType type) const |
Qt3DRender::QShaderProgram::Status | status() const |
QByteArray | tessellationControlShaderCode() const |
QByteArray | tessellationEvaluationShaderCode() const |
QByteArray | vertexShaderCode() const |
void | setComputeShaderCode(const QByteArray &computeShaderCode) |
void | setFragmentShaderCode(const QByteArray &fragmentShaderCode) |
void | setGeometryShaderCode(const QByteArray &geometryShaderCode) |
void | setTessellationControlShaderCode(const QByteArray &tessellationControlShaderCode) |
void | setTessellationEvaluationShaderCode(const QByteArray &tessellationEvaluationShaderCode) |
void | setVertexShaderCode(const QByteArray &vertexShaderCode) |
void | computeShaderCodeChanged(const QByteArray &computeShaderCode) |
void | formatChanged(Qt3DRender::QShaderProgram::Format format) |
void | fragmentShaderCodeChanged(const QByteArray &fragmentShaderCode) |
void | geometryShaderCodeChanged(const QByteArray &geometryShaderCode) |
void | logChanged(const QString &log) |
void | statusChanged(Qt3DRender::QShaderProgram::Status status) |
void | tessellationControlShaderCodeChanged(const QByteArray &tessellationControlShaderCode) |
void | tessellationEvaluationShaderCodeChanged(const QByteArray &tessellationEvaluationShaderCode) |
void | vertexShaderCodeChanged(const QByteArray &vertexShaderCode) |
QByteArray | loadSource(const QUrl &sourceUrl) |
virtual void | sceneChangeEvent(const Qt3DCore::QSceneChangePtr &change) override |
A shader program consists of several different shaders, such as vertex and fragment shaders.
Qt3D will automatically populate a set of default uniforms if they are encountered during the shader instrospection phase.
Default Uniform | Associated Qt3D Parameter name | GLSL declaration | |||
---|---|---|---|---|---|
ModelMatrix | modelMatrix | uniform mat4 modelMatrix; | |||
ViewMatrix | viewMatrix | uniform mat4 viewMatrix; | |||
ProjectionMatrix | projectionMatrix | uniform mat4 projectionMatrix; | |||
ModelViewMatrix | modelView | uniform mat4 modelView; | |||
ViewProjectionMatrix | viewProjectionMatrix | uniform mat4 viewProjectionMatrix; | |||
ModelViewProjectionMatrix | modelViewProjection mvp | uniform mat4 modelViewProjection; uniform mat4 mvp; | |||
InverseModelMatrix | inverseModelMatrix | uniform mat4 inverseModelMatrix; | |||
InverseViewMatrix | inverseViewMatrix | uniform mat4 inverseViewMatrix; | |||
InverseProjectionMatrix | inverseProjectionMatrix | uniform mat4 inverseProjectionMatrix; | |||
InverseModelViewMatrix | inverseModelView | uniform mat4 inverseModelView; | |||
InverseViewProjectionMatrix | inverseViewProjectionMatrix | uniform mat4 inverseViewProjectionMatrix; | |||
InverseModelViewProjectionMatrix | inverseModelViewProjection | uniform mat4 inverseModelViewProjection; | |||
ModelNormalMatrix | modelNormalMatrix | uniform mat3 modelNormalMatrix; | |||
ModelViewNormalMatrix | modelViewNormal | uniform mat3 modelViewNormal; | |||
ViewportMatrix | viewportMatrix | uniform mat4 viewportMatrix; | |||
InverseViewportMatrix | inverseViewportMatrix | uniform mat4 inverseViewportMatrix; | |||
AspectRatio (surface width / surface height) | aspectRatio | uniform float aspectRatio; | |||
Exposure | exposure | uniform float exposure; | |||
Gamma | gamma | uniform float gamma; | |||
Time (in nano seconds) | time | uniform float time; | |||
EyePosition | eyePosition | uniform vec3 eyePosition; | |||
SkinningPalette | skinningPalette[0] | const int maxJoints = 100; uniform mat4 skinningPalette[maxJoints]; |
This enum identifies the format of the shader code used.
Constant | Value | Description |
---|---|---|
Qt3DRender::QShaderProgram::GLSL |
0 |
OpenGL |
Qt3DRender::QShaderProgram::SPIRV |
1 |
Vulkan, OpenGL 5 |
This enum was introduced or modified in Qt 5.15.
This enum identifies the type of shader used.
Constant | Value | Description |
---|---|---|
Qt3DRender::QShaderProgram::Vertex |
0 |
Vertex shader |
Qt3DRender::QShaderProgram::Fragment |
1 |
Fragment shader |
Qt3DRender::QShaderProgram::TessellationControl |
2 |
Tesselation control shader |
Qt3DRender::QShaderProgram::TessellationEvaluation |
3 |
Tesselation evaluation shader |
Qt3DRender::QShaderProgram::Geometry |
4 |
Geometry shader |
Qt3DRender::QShaderProgram::Compute |
5 |
Compute shader |
This enum identifies the status of shader used.
Constant | Value | Description |
---|---|---|
Qt3DRender::QShaderProgram::NotReady |
0 |
The shader hasn't been compiled and linked yet |
Qt3DRender::QShaderProgram::Ready |
1 |
The shader was successfully compiled |
Qt3DRender::QShaderProgram::Error |
2 |
An error occurred while compiling the shader |
Holds the compute shader code used by this shader program.
Access functions:
QByteArray | computeShaderCode() const |
void | setComputeShaderCode(const QByteArray &computeShaderCode) |
Notifier signal:
void | computeShaderCodeChanged(const QByteArray &computeShaderCode) |
Holds the format of the code provided on the ShaderProgram. The default is ShaderProgram.GLSL
This property was introduced in Qt 5.15.
Access functions:
Qt3DRender::QShaderProgram::Format | format() const |
void | setFormat(Qt3DRender::QShaderProgram::Format format) |
Notifier signal:
void | formatChanged(Qt3DRender::QShaderProgram::Format format) |
Holds the fragment shader code used by this shader program.
Access functions:
QByteArray | fragmentShaderCode() const |
void | setFragmentShaderCode(const QByteArray &fragmentShaderCode) |
Notifier signal:
void | fragmentShaderCodeChanged(const QByteArray &fragmentShaderCode) |
Holds the geometry shader code used by this shader program.
Access functions:
QByteArray | geometryShaderCode() const |
void | setGeometryShaderCode(const QByteArray &geometryShaderCode) |
Notifier signal:
void | geometryShaderCodeChanged(const QByteArray &geometryShaderCode) |
Holds the log of the current shader program. This is useful to diagnose a compilation failure of the shader program.
Access functions:
QString | log() const |
Notifier signal:
void | logChanged(const QString &log) |
Holds the status of the current shader program.
Access functions:
Qt3DRender::QShaderProgram::Status | status() const |
Notifier signal:
void | statusChanged(Qt3DRender::QShaderProgram::Status status) |
Holds the tesselation control shader code used by this shader program.
Access functions:
QByteArray | tessellationControlShaderCode() const |
void | setTessellationControlShaderCode(const QByteArray &tessellationControlShaderCode) |
Notifier signal:
void | tessellationControlShaderCodeChanged(const QByteArray &tessellationControlShaderCode) |
Holds the tesselation evaluation shader code used by this shader program.
Access functions:
QByteArray | tessellationEvaluationShaderCode() const |
void | setTessellationEvaluationShaderCode(const QByteArray &tessellationEvaluationShaderCode) |
Notifier signal:
void | tessellationEvaluationShaderCodeChanged(const QByteArray &tessellationEvaluationShaderCode) |
Holds the vertex shader code used by this shader program.
Access functions:
QByteArray | vertexShaderCode() const |
void | setVertexShaderCode(const QByteArray &vertexShaderCode) |
Notifier signal:
void | vertexShaderCodeChanged(const QByteArray &vertexShaderCode) |
[static]
QByteArray QShaderProgram::loadSource(const QUrl &sourceUrl)
Returns the shader code loaded from sourceUrl.
Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.
[override virtual protected]
void QShaderProgram::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &change)
Reimplements: QNode::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &change).
Posts a scene change with parameter change.
Sets the shader code for type of shader to the shaderCode.
See also shaderCode().
Returns the shader code for type.
See also setShaderCode().
Returns the status of the current shader program.
Note: Getter function for property status.
© The Qt Company Ltd
Licensed under the GNU Free Documentation License, Version 1.3.
https://doc.qt.io/qt-5.15/qt3drender-qshaderprogram.html