ShaderNode Class
Header: | #include <ShaderNode> |
Inherits: | QSGGeometryNode |
Public Functions
QSGMaterialType * | materialVariant() const |
QRectF | rect() const |
void | setShader(const QString &shader) |
void | setTexture(ShaderNode::TextureChannel channel, QSGTextureProvider *provider, QQuickWindow::CreateTextureOptions options = {}) |
void | setTexture(ShaderNode::TextureChannel channel, const QImage &image, QQuickWindow *window, QQuickWindow::CreateTextureOptions options = {}) |
void | setTextureChannels(unsigned char count) |
void | setUniformBufferSize(qsizetype size) |
std::span<char> | uniformData() |
virtual void | update() |
QRectF | uvs(ShaderNode::TextureChannel channel) const |
Static Public Members
QColor | toPremultiplied(const QColor &value) |
Protected Functions
virtual QSGMaterial * | createMaterialVariant(QSGMaterialType *variant) |
Detailed Description
A base class for scene graph nodes that want to use a shader to render something.
Member Function Documentation
[virtual protected]
QSGMaterial *ShaderNode::createMaterialVariant(QSGMaterialType *variant)
Create a new instance of a certain material variant.
This should return a new instance of the material that matches variant, or nullptr if the specified variant cannot be handled by the current node.
QSGMaterialType *ShaderNode::materialVariant() const
The variant of the material used for rendering.
This will be passed to createMaterialVariant() to perform the actual creation of the material.
QRectF ShaderNode::rect() const
The rectangle describing the geometry of this node.
void ShaderNode::setShader(const QString &shader)
Set the name of the shader to use for rendering.
By default this will create and use an instance of ShaderMaterial that corresponds to the given shader.
void ShaderNode::setTexture(ShaderNode::TextureChannel channel, QSGTextureProvider *provider, QQuickWindow::CreateTextureOptions options = {})
Set the texture for a channel to a texture provider.
This will use provider to provide the texture for channel channel. options will be used whenever a new texture is created from provider.
void ShaderNode::setTexture(ShaderNode::TextureChannel channel, const QImage &image, QQuickWindow *window, QQuickWindow::CreateTextureOptions options = {})
Set the texture for a channel to an image.
This will create a texture from image using window and the options specified by options, then assign it to texture channel channel. Textures created from images are cached, if an image has the same cache ID as a previous call to setTexture(), no new texture will be created.
void ShaderNode::setTextureChannels(unsigned char count)
Set the number of texture channels.
Each texture channel gets its own set of UV coordinates and texture. By default, the UVs will be set to (0, 0, 1, 1) unless the texture is an atlas texture, in which case coordinates matching the atlas will be used. Use setTexture() to set the texture to use for a channel.
void ShaderNode::setUniformBufferSize(qsizetype size)
Set the size of buffer used by the material for storing uniform values.
The given size is in bytes. Note that you should account for all uniforms in your shader's uniform buffer.
[static]
QColor ShaderNode::toPremultiplied(const QColor &value)
Helper function that returns a pre-multiplied version of a color.
std::span<char> ShaderNode::uniformData()
A writeable view of the material's uniform data buffer.
This can be used in combination with UniformDataStream to write the values of your uniforms.
[virtual]
void ShaderNode::update()
Update internal state based on newly-set parameters.
This is done as an explicit step to ensure we don't modify expensive GPU resources like geometry multiple times during a single update.
QRectF ShaderNode::uvs(ShaderNode::TextureChannel channel) const
The UV coordinates of the geometry of this node.