Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QSSGShaderUtils Namespace Reference

\qmltype Shader \inherits Object \inqmlmodule QtQuick3D More...

Classes

struct  ShaderType
 
struct  ShaderType< QMetaType::Bool >
 
struct  ShaderType< QMetaType::Double >
 
struct  ShaderType< QMetaType::Int >
 
struct  ShaderType< QMetaType::QColor >
 
struct  ShaderType< QMetaType::QMatrix4x4 >
 
struct  ShaderType< QMetaType::QPoint >
 
struct  ShaderType< QMetaType::QPointF >
 
struct  ShaderType< QMetaType::QQuaternion >
 
struct  ShaderType< QMetaType::QRect >
 
struct  ShaderType< QMetaType::QRectF >
 
struct  ShaderType< QMetaType::QSize >
 
struct  ShaderType< QMetaType::QSizeF >
 
struct  ShaderType< QMetaType::QVector2D >
 
struct  ShaderType< QMetaType::QVector3D >
 
struct  ShaderType< QMetaType::QVector4D >
 

Typedefs

using MetaTypeList = QList<QMetaType::Type>
 
using ResolveFunction = bool (*)(const QUrl &url, const QQmlContext *context, QByteArray &shaderData, QByteArray &shaderPathKey)
 

Functions

void setResolveFunction (ResolveFunction fn)
 
QByteArray resolveShader (const QUrl &fileUrl, const QQmlContext *context, QByteArray &shaderPathKey)
 
QByteArray uniformTypeName (QMetaType type)
 
QByteArray uniformTypeName (QSSGRenderShaderValue::Type type)
 
QSSGRenderShaderValue::Type uniformType (QMetaType type)
 
MetaTypeList supportedMetatypes ()
 

Variables

ResolveFunction resolveShaderOverride = nullptr
 
static constexpr QMetaType::Type qssg_metatype_list []
 

Detailed Description

\qmltype Shader \inherits Object \inqmlmodule QtQuick3D

Container component for defining shader code used by post-processing effects.

The Shader type is used for populating the \l{Pass::shaders}{shaders} list in the render \l{Pass}{pass} of an \l Effect.

A shader is code which is executed directly on the graphic hardware at a particular \l{Shader::stage}{stage} of the rendering pipeline.

See also
Effect

\qmlproperty url Shader::shader Specifies the name of the shader source file. For details on how to write shader code, see the \l Effect documentation.

\qmlproperty enumeration Shader::stage Specifies the stage of the rendering pipeline when the shader code will be executed. The default is Shader.Fragment

\value Shader.Vertex The shader is a vertex shader. This code is run once per vertex in the input geometry and can be used to modify it before the geometry is rasterized (scan converted). In the case of effects, the input geometry is always a quad (four vertexes representing the corners of the render target). \value Shader.Fragment The shader is a fragment shader. After vertex processing, the modified geometry is turned into fragments (rasterization). Then a fragment shader is executed for each fragment, assigning a color to it. Fragments are a related concept to pixels, but with additional information attached. Also, as a result of some anti-aliasing strategies, there may be more than one fragment for each pixel in the output.

\qmltype TextureInput \inherits Object \inqmlmodule QtQuick3D

Specifies a texture exposed to the shaders of a CustomMaterial or Effect.

This is a type which can be used for exposing a \l Texture to a shader, either in the \l{Pass}{render pass} of an \l Effect, or in a \l CustomMaterial. It exists primarily to assign a local name to the \l Texture that can be referenced from shaders.

When a TextureInput property is declared in an \l Effect or a \l CustomMaterial, it will automatically be available as a sampler in all shaders by its property name.

\qmlproperty Texture TextureInput::texture The texture for which this TextureInput serves as an indirection.

\qmlproperty bool TextureInput::enabled The property determines if this TextureInput is enabled. The default value is true. When disabled, the shaders of the effect sample a dummy, opaque black texture instead of the one specified by \l texture.

\qmltype Pass \inherits Object \inqmlmodule QtQuick3D

Defines a render pass in an Effect.

An \l Effect may consist of multiple render passes. Each render pass has a setup phase where the list of \l{Pass::commands}{render commands} are executed, a \l{Pass::output}{output buffer} and a list of \l{Pass::shaders}{shaders} to use for rendering the effect.

See the documentation for \l Effect for more details on how to set up multiple rendering passes.

\qmlproperty Buffer Pass::output Specifies the output \l {Buffer}{buffer} of the pass.

\qmlproperty list Pass::commands Specifies the list of render \l {Command}{commands} of the pass.

\qmlproperty list Pass::shaders Specifies the list of \l {Shader}{shaders} of the pass.

\qmltype Command \inherits Object \inqmlmodule QtQuick3D

Supertype of commands to be performed as part of a pass in an Effect.

The Command type should not be instantiated by itself, but only exists as a polymorphic supertype for the different actions that can be performed as part of a \l{Pass}{render pass}.

See also
BufferInput, SetUniformValue, Effect

\qmltype BufferInput \inherits Command \inqmlmodule QtQuick3D

Defines an input buffer to be used as input for a pass of an Effect.

BufferInput is a \l Command which can be added to the list of commands in the \l Pass of an \l Effect. When executed, it will expose the buffer as a sample to the shaders in the render pass. The shaders must declare a sampler with the name given in the BufferInput's sampler property.

This can be used for sharing intermediate results between the different passes of an effect.

See also
TextureInput

\qmlproperty Buffer BufferInput::buffer Specifies the \l {Buffer}{buffer} which should be exposed to the shader.

\qmlproperty string BufferInput::sampler Specifies the name under which the buffer is exposed to the shader. When this property is not set, the buffer is exposed with the built-in name INPUT.

\qmltype Buffer \inherits Object \inqmlmodule QtQuick3D

Creates or references a color buffer to be used for a pass of an Effect.

A Buffer can be used to create intermediate buffers to share data between \l{Pass}{render passes} in an \l Effect.

Note
If the \l name property of the Buffer is empty, it will reference the default output texture of the render pass.

\qmlproperty enumeration Buffer::format Specifies the texture format. The default value is Buffer.RGBA8.

\value Buffer.RGBA8 \value Buffer.RGBA16F \value Buffer.RGBA32F \value Buffer.R8 \value Buffer.R16 \value Buffer.R16F \value Buffer.R32F

\qmlproperty enumeration Buffer::textureFilterOperation Specifies the texture filtering mode when sampling the contents of the Buffer. The default value is Buffer.Linear.

\value Buffer.Nearest Use nearest-neighbor filtering. \value Buffer.Linear Use linear filtering.

\qmlproperty enumeration Buffer::textureCoordOperation Specifies the behavior for texture coordinates when sampling outside the [0, 1] range. The default is Buffer.ClampToEdge.

\value Buffer.ClampToEdge Clamp coordinates to the edges. \value Buffer.Repeat Wrap the coordinates at the edges to tile the texture. \value Buffer.MirroredRepeat Wrap the coordinate at the edges, but mirror the texture when tiling it.

\qmlproperty real Buffer::sizeMultiplier Specifies the size multiplier of the buffer. For instance, a value of 1.0 creates a buffer with the same size as the effect's input texture while 0.5 creates buffer where both width and height is half as big. The default value is 1.0.

\qmlproperty enumeration Buffer::bufferFlags Specifies the buffer allocation flags. The default is Buffer.None.

\value Buffer.None No special behavior. \value Buffer.SceneLifetime The buffer is allocated for the whole lifetime of the scene.

\qmlproperty string Buffer::name Specifies the name of the buffer.

Note
When this property is empty, the Buffer will refer to the default output texture of the \l{Pass}{render pass} instead of allocating a buffer. This can be useful to override certain settings of the output, such as the texture format, without introducing a new, separate intermediate texture.

\qmltype SetUniformValue \inherits Command \inqmlmodule QtQuick3D

Defines a value to be set during a single \l {Pass}{pass}.

Since
5.15

SetUniformValue is a \l Command which can be added to the list of commands in a \l Pass. When executed, it will set the uniform given by the \l{SetUniformValue::target}{target} property to \l{SetUniformValue::value}{value}.

Note
The value set by this command is will only be set during the \l {Pass}{pass} it occurs in. For consecutive passes the value will be revert to the initial value of the uniform as it was defined in the \l Effect item.
See also
BufferInput

\qmlproperty string SetUniformValue::target Specifies the name of the uniform that will have its value changed during the \l {Pass}{pass}. This must match the name of an existing property in the \l Effect.

\qmlproperty Variant SetUniformValue::value Specifies the value that will be set on the target uniform.

Typedef Documentation

◆ MetaTypeList

◆ ResolveFunction

using QSSGShaderUtils::ResolveFunction = bool (*)(const QUrl &url, const QQmlContext *context, QByteArray &shaderData, QByteArray &shaderPathKey)

Definition at line 35 of file qquick3dshaderutils_p.h.

Function Documentation

◆ resolveShader()

Q_QUICK3D_EXPORT QByteArray QSSGShaderUtils::resolveShader ( const QUrl & fileUrl,
const QQmlContext * context,
QByteArray & shaderPathKey )

Definition at line 245 of file qquick3dshaderutils.cpp.

References QByteArray::append(), context, QUrl::fileName(), QByteArray(), qPrintable, qWarning, QIODeviceBase::ReadOnly, resolveShaderOverride, QIODeviceBase::Text, QString::toUtf8(), and QQmlFile::urlToLocalFileOrQrc().

Referenced by QQuick3DCustomMaterial::updateSpatialNode(), and QQuick3DEffect::updateSpatialNode().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setResolveFunction()

Q_QUICK3D_EXPORT void QSSGShaderUtils::setResolveFunction ( ResolveFunction fn)

Definition at line 240 of file qquick3dshaderutils.cpp.

References resolveShaderOverride.

◆ supportedMetatypes()

Q_QUICK3D_EXPORT MetaTypeList QSSGShaderUtils::supportedMetatypes ( )

Definition at line 510 of file qquick3dshaderutils.cpp.

References qssg_metatype_list.

◆ uniformType()

Q_QUICK3D_EXPORT QSSGRenderShaderValue::Type QSSGShaderUtils::uniformType ( QMetaType type)

Definition at line 471 of file qquick3dshaderutils.cpp.

References QSSGRenderShaderValue::Unknown.

◆ uniformTypeName() [1/2]

Q_QUICK3D_EXPORT QByteArray QSSGShaderUtils::uniformTypeName ( QMetaType type)

Definition at line 394 of file qquick3dshaderutils.cpp.

References QByteArray().

+ Here is the call graph for this function:

◆ uniformTypeName() [2/2]

Variable Documentation

◆ qssg_metatype_list

constexpr QMetaType::Type QSSGShaderUtils::qssg_metatype_list[]
staticconstexpr
Initial value:
{
QMetaType::Double,
QMetaType::Bool,
QMetaType::QVector2D,
QMetaType::QVector3D,
QMetaType::QVector4D,
QMetaType::Int,
QMetaType::QColor,
QMetaType::QSize,
QMetaType::QSizeF,
QMetaType::QPoint,
QMetaType::QPointF,
QMetaType::QRect,
QMetaType::QRectF,
QMetaType::QQuaternion,
QMetaType::QMatrix4x4
}

Definition at line 271 of file qquick3dshaderutils.cpp.

Referenced by supportedMetatypes().

◆ resolveShaderOverride

ResolveFunction QSSGShaderUtils::resolveShaderOverride = nullptr

Definition at line 238 of file qquick3dshaderutils.cpp.

Referenced by resolveShader(), and setResolveFunction().