3#include <Gfx/Graph/Node.hpp>
4#include <Gfx/Graph/NodeRenderer.hpp>
5#include <Gfx/Graph/RenderList.hpp>
6#include <Gfx/Graph/RenderState.hpp>
7#include <Gfx/Graph/Uniforms.hpp>
14 static const constexpr auto vertex = R
"_(#version 450
15 layout(location = 0) in vec2 position;
16 layout(location = 1) in vec2 texcoord;
18 layout(binding = 3) uniform sampler2D y_tex;
19 layout(location = 0) out vec2 v_texcoord;
21 layout(std140, binding = 0) uniform renderer_t {
22 mat4 clipSpaceCorrMatrix;
26 out gl_PerVertex { vec4 gl_Position; };
30 v_texcoord = texcoord;
31 gl_Position = renderer.clipSpaceCorrMatrix * vec4(position.xy, 0.0, 1.);
32#if defined(QSHADER_HLSL) || defined(QSHADER_MSL)
33 gl_Position.y = - gl_Position.y;
38 static const constexpr auto filter = R
"_(#version 450
39 layout(location = 0) in vec2 v_texcoord;
40 layout(location = 0) out vec4 fragColor;
42 layout(std140, binding = 0) uniform renderer_t {
43 mat4 clipSpaceCorrMatrix;
47 layout(binding=3) uniform sampler2D y_tex;
52 fragColor = texture(y_tex, v_texcoord);
58 int currentImageIndex{};
65 using GenericNodeRenderer::GenericNodeRenderer;
69 QRhiTexture* texture{};
70 void init(
RenderList& renderer, QRhiResourceUpdateBatch& res)
override
73 defaultMeshInit(renderer, mesh, res);
74 processUBOInit(renderer);
75 m_material.init(renderer, node.
input, m_samplers);
76 std::tie(m_vertexS, m_fragmentS)
79 auto& n =
static_cast<const TexgenNode&
>(this->node);
80 auto& rhi = *renderer.
state.rhi;
83 = rhi.newTexture(QRhiTexture::RGBA8, n.image.size(), 1, QRhiTexture::Flag{});
89 auto sampler = rhi.newSampler(
90 QRhiSampler::Linear, QRhiSampler::Linear, QRhiSampler::None,
91 QRhiSampler::ClampToEdge, QRhiSampler::ClampToEdge);
94 m_samplers.push_back({sampler, texture});
96 defaultPassesInit(renderer, mesh);
100 RenderList& renderer, QRhiResourceUpdateBatch& res,
103 defaultUBOUpdate(renderer, res);
104 auto& n =
static_cast<const TexgenNode&
>(this->node);
105 if(func_t f = n.function.load())
107 f(
const_cast<uchar*
>(n.image.bits()), n.image.width(), n.image.height(), t++);
108 res.uploadTexture(texture, n.image);
114 texture->deleteLater();
126 image = QImage{QSize(640, 480), QImage::Format_ARGB32_Premultiplied};
127 output.push_back(
new Port{
this, {}, Types::Image, {}});
129 virtual ~TexgenNode()
131 m_materialData.release();
134 using func_t = void (*)(
unsigned char* rgb,
int width,
int height,
int t);
135 std::atomic<func_t> function{};
Generic renderer.
Definition NodeRenderer.hpp:84
std::vector< Port * > input
Input ports of that node.
Definition score-plugin-gfx/Gfx/Graph/Node.hpp:104
ossia::small_pod_vector< Port *, 1 > output
Output ports of that node.
Definition score-plugin-gfx/Gfx/Graph/Node.hpp:110
Common base class for most single-pass, simple nodes.
Definition score-plugin-gfx/Gfx/Graph/Node.hpp:228
Renderer for a given node.
Definition NodeRenderer.hpp:11
List of nodes to be rendered to an output.
Definition RenderList.hpp:19
const score::gfx::Mesh & defaultTriangle() const noexcept
A triangle mesh correct for this API.
Definition RenderList.cpp:305
RenderState & state
RenderState corresponding to this RenderList.
Definition RenderList.hpp:89
Graphics rendering pipeline for ossia score.
Definition Filter/PreviewWidget.hpp:12
std::pair< QShader, QShader > makeShaders(const RenderState &v, QString vert, QString frag)
Get a pair of compiled vertex / fragment shaders from GLSL 4.5 sources.
Definition score-plugin-gfx/Gfx/Graph/Utils.cpp:390
Connection between two score::gfx::Port.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:66
Port of a score::gfx::Node.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:48
Definition TexgenNode.hpp:64
Definition TexgenNode.hpp:57
Definition TexgenNode.hpp:13
score::gfx::NodeRenderer * createRenderer(RenderList &r) const noexcept override
Create a renderer in a given context for this node.
Definition TexgenNode.hpp:137
Definition Uniforms.hpp:5