ShaderNode Class
| Header: | #include <ShaderNode> |
Public Functions
| int * | materialVariant() const |
| QRectF | rect() const |
| void | setExtraDataChannels(unsigned char count) |
| void | setTexture(ShaderNode::Channel channel, ShaderNode::Binding binding, const int &texture, int options = {}) |
| void | setTexture(ShaderNode::Channel channel, ShaderNode::Binding binding, int *provider, int options = {}) |
| void | setUvChannels(unsigned char count) |
| std::span<char> | uniformData() |
| virtual void | update() |
| QRectF | uvs(ShaderNode::Channel channel) const |
Protected Functions
| int * | createMaterialVariant(int *variant) |
| void | requestGeometryUpdate() |
| void | setIndexCount(int count) |
| void | setVertexCount(int count) |
| virtual void | updateGeometry(int *geometry) |
Detailed Description
A base class for scene graph nodes that want to use a shader to render something.
Member Function Documentation
[protected] int *ShaderNode::createMaterialVariant(int *variant)
Create a new instance of a certain material variant.
This should return a new instance of the material that matches \p variant, or nullptr if the specified variant cannot be handled by the current node.
int *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.
[protected] void ShaderNode::requestGeometryUpdate()
Request an update of the geometry data.
Geometry updates are only performed on request for performance reasons.
void ShaderNode::setExtraDataChannels(unsigned char count)
Set the number of extra vertex data channels to \p count.
Extra vertex data channels are used to store extra data in the vertices of the geometry. These can be used to store colors or other values. By default ShaderNode uses a single quad as geometry with no extra data channels.
[protected] void ShaderNode::setIndexCount(int count)
Set the number of indices used by the geometry of this node to \p count.
The default geometry uses no indices. If you set this you will also want to override updateGeometry() to make use of the indices.
void ShaderNode::setTexture(ShaderNode::Channel channel, ShaderNode::Binding binding, const int &texture, int options = {})
Set the texture for a binding to a texture.
This will assign \p texture to binding \p binding of the material. The texture will use UV coordinates from \p channel. \p options is used to determine if the texture is part of an atlas.
The UV coordinates of \p channel will be updated to match the expected coordinates for the texture, such that textures from a texture atlas work correctly.
void ShaderNode::setTexture(ShaderNode::Channel channel, ShaderNode::Binding binding, int *provider, int options = {})
Set the texture for a channel to a texture provider.
This will use \p provider to provide the texture for binding \p binding \p options will be used whenever a new texture is created from \p provider. The texture will use UV coordinates from channel \p channel.
The UV coordinates of \p channel will be updated to match the expected coordinates for the texture, such that textures from a texture atlas work correctly.
void ShaderNode::setUvChannels(unsigned char count)
Set the number of UV channels.
Each UV channel gets its own set of coordinates. By default, the UVs will be set to (0, 0, 1, 1).
[protected] void ShaderNode::setVertexCount(int count)
Set the number of vertices used by the geometry of this node to \p count.
By default a single quad is used, if you set this you will also want to override updateGeometry() .
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.
[virtual protected] void ShaderNode::updateGeometry(int *geometry)
Update the geometry data of this node.
Override this if you want to change the vertex and/or index data.
QRectF ShaderNode::uvs(ShaderNode::Channel channel) const
The UV coordinates of the geometry of this node.