9#include <QtQuick3DUtils/private/qssgutils_p.h>
11#include <QtQuick3DRuntimeRender/private/qssgrenderer_p.h>
12#include <QtQuick3DRuntimeRender/private/qssgrendercamera_p.h>
13#include <QtQuick3DRuntimeRender/private/qssglayerrenderdata_p.h>
59 oneOverSize =
QVector2D(1.0f / particleBuffer.size().width(), 1.0f / particleBuffer.size().height());
60 shaders.setUniform(ubufData,
"qt_oneOverParticleImageSize", &oneOverSize, 2 *
sizeof(
float));
61 shaders.setUniform(ubufData,
"qt_countPerSlice", &particlesPerSlice, 1 *
sizeof(
quint32));
64 shaders.setUniform(ubufData,
"qt_opacity", &renderable.
opacity, 1 *
sizeof(
float));
68 float ooImageCount = 1.0f / imageCount;
70 QVector4D spriteConfig(imageCount, ooImageCount, 0.0f, blendImages);
71 shaders.setUniform(ubufData,
"qt_spriteConfig", &spriteConfig, 4 *
sizeof(
float));
74 shaders.setUniform(ubufData,
"qt_billboard", &billboard, 1 *
sizeof(
float));
83 auto &lights = renderable.
lights;
84 for (
quint32 lightIdx = 0, lightEnd = lights.size();
90 if (theLight->
type == QSSGRenderLight::Type::DirectionalLight) {
92 }
else if (theLight->
type == QSSGRenderLight::Type::PointLight && pointLight < 4) {
99 }
else if (theLight->
type == QSSGRenderLight::Type::SpotLight && spotLight < 4) {
108 float innerConeAngle = std::min(theLight->
m_innerConeAngle, coneAngle - 0.01f);
116 int lightOffset =
shaders.offsetOfUniform(
"qt_pointLightPosition");
117 if (lightOffset >= 0)
121 int enablePointLights = pointLight > 0 ? 1 : 0;
122 int enableSpotLights = spotLight > 0 ? 1 : 0;
123 shaders.setUniform(ubufData,
"qt_pointLights", &enablePointLights,
sizeof(
int));
124 shaders.setUniform(ubufData,
"qt_spotLights", &enableSpotLights,
sizeof(
int));
135 const auto size =
image->m_texture.m_texture->pixelSize();
136 texcoordScale *= float(
size.height()) / float(
size.width());
138 shaders.setUniform(ubufData,
"qt_alphaFade", &alphaFade,
sizeof(
float));
139 shaders.setUniform(ubufData,
"qt_sizeModifier", &sizeModifier,
sizeof(
float));
140 shaders.setUniform(ubufData,
"qt_texcoordScale", &texcoordScale,
sizeof(
float));
149 auto &particleBuffer = *
model->particleBuffer;
150 const quint32 particlesPerSlice = particleBuffer.particlesPerSlice();
151 const QVector2D oneOverSize =
QVector2D(1.0f / particleBuffer.size().width(), 1.0f / particleBuffer.size().height());
152 shaderPipeline.
setUniform(ubufData,
"qt_oneOverParticleImageSize", &oneOverSize, 2 *
sizeof(
float));
153 shaderPipeline.
setUniform(ubufData,
"qt_countPerSlice", &particlesPerSlice,
sizeof(
quint32));
155 shaderPipeline.
setUniform(ubufData,
"qt_particleMatrix", &particleMatrix, 16 *
sizeof(
float));
187 const QVector3D &cameraDirection,
bool animatedParticles)
193 auto particleCount =
buffer.particleCount();
194 const bool lineParticles =
segments > 0;
197 sortData.
resize(particleCount);
209 const auto slices =
buffer.sliceCount();
210 const auto ss =
buffer.sliceStride();
211 const auto pps =
buffer.particlesPerSlice();
218 for (
i = 0;
i < particleCount;
i++) {
223 for (
int j = 1;
j <
buffer.segments();
j++) {
229 }
else if (animatedParticles) {
230 for (
int s = 0;
s < slices;
s++) {
232 for (
int p = 0;
p < pps &&
i < particleCount;
p++) {
241 for (
int s = 0;
s < slices;
s++) {
243 for (
int p = 0;
p < pps &&
i < particleCount;
p++) {
261 const auto slices =
buffer.sliceCount();
262 const auto ss =
buffer.sliceStride();
263 const auto pps =
buffer.particlesPerSlice();
265 char *dest =
dst.data();
270 for (
int s = 0;
s < slices;
s++) {
272 for (
int p = 0;
p < pps &&
i < particleCount;
p++) {
284 }
else if (animatedParticles) {
285 for (
int s = 0;
s < slices;
s++) {
287 for (
int p = 0;
p < pps &&
i < particleCount;
p++) {
296 for (
int s = 0;
s < slices;
s++) {
298 for (
int p = 0;
p < pps &&
i < particleCount;
p++) {
336 const void *node = &renderable.
particles;
413 if (samplerBinding >= 0) {
415 if (samplerBinding >= 0 &&
texture) {
441 if (samplerBinding >= 0) {
443 if (samplerBinding >= 0 &&
texture) {
456 if (samplerBinding >= 0) {
457 bool hasTexture =
false;
490 bool srbChanged =
false;
491 if (!srb || bindings != dcd.
bindings) {
492 srb = rhiCtx->
srb(bindings);
516 renderPassDescriptor,
521 renderPassDescriptor,
539 bool update = particleBuffer.
serial() != particleData.
serial;
564 if (samplerBinding >= 0) {
566 if (samplerBinding >= 0 &&
texture) {
581 bool *needsSetViewport,
600 cb->setGraphicsPipeline(ps);
601 cb->setVertexInput(0, 0,
nullptr);
602 cb->setShaderResources(srb);
604 if (needsSetViewport && *needsSetViewport) {
605 cb->setViewport(
state.viewport);
606 *needsSetViewport =
false;
char * data()
\macro QT_NO_CAST_FROM_BYTEARRAY
qsizetype size() const noexcept
Returns the number of bytes in this byte array.
void clear()
Clears the contents of the byte array and makes it null.
void resize(qsizetype size)
Sets the size of the byte array to size bytes.
QList< T > & fill(parameter_type t, qsizetype size=-1)
void resize(qsizetype size)
The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space.
QMatrix4x4 inverted(bool *invertible=nullptr) const
Returns the inverse of this matrix.
QPoint map(const QPoint &point) const
Maps point by multiplying this matrix by point.
const float * constData() const
Returns a constant pointer to the raw data of this matrix.
virtual char * beginFullDynamicBufferUpdateForCurrentFrame()
virtual void endFullDynamicBufferUpdateForCurrentFrame()
To be called when the entire contents of the buffer data has been updated in the memory block returne...
void resourceUpdate(QRhiResourceUpdateBatch *resourceUpdates)
Sometimes committing resource updates is necessary or just more convenient without starting a render ...
void uploadTexture(QRhiTexture *tex, const QRhiTextureUploadDescription &desc)
Enqueues uploading the image data for one or more mip levels in one or more layers of the texture tex...
void setData(const QByteArray &data)
Sets data.
virtual bool create()=0
Creates the corresponding native graphics resources.
void setPixelSize(const QSize &sz)
Sets the texture size, specified in pixels, to sz.
bool isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture::Flags flags={}) const
QMatrix4x4 clipSpaceCorrMatrix() const
QRhiTexture * newTexture(QRhiTexture::Format format, const QSize &pixelSize, int sampleCount=1, QRhiTexture::Flags flags={})
QRhiResourceUpdateBatch * nextResourceUpdateBatch()
QSSGRenderCamera * camera
std::optional< QSSGCameraRenderData > cameraData
static void updateUniformsForParticles(QSSGRhiShaderPipeline &shaderPipeline, QSSGRhiContext *rhiCtx, char *ubufData, QSSGParticlesRenderable &renderable, QSSGRenderCamera &inCamera)
static void rhiRenderRenderable(QSSGRhiContext *rhiCtx, QSSGParticlesRenderable &renderable, bool *needsSetViewport, int cubeFace, const QSSGRhiGraphicsPipelineState &state)
static void updateUniformsForParticleModel(QSSGRhiShaderPipeline &shaderPipeline, char *ubufData, const QSSGRenderModel *model, quint32 offset)
static void prepareParticlesForModel(QSSGRhiShaderPipeline &shaderPipeline, QSSGRhiContext *rhiCtx, QSSGRhiShaderResourceBindingList &bindings, const QSSGRenderModel *model)
static void rhiPrepareRenderable(QSSGRhiShaderPipeline &shaderPipeline, QSSGPassKey passKey, QSSGRhiContext *rhiCtx, QSSGRhiGraphicsPipelineState *ps, QSSGParticlesRenderable &renderable, const QSSGLayerRenderData &inData, QRhiRenderPassDescriptor *renderPassDescriptor, int samples, QSSGRenderCamera *camera=nullptr, int cubeFace=-1, QSSGReflectionMapEntry *entry=nullptr)
QRhiTexture * dummyTexture(QRhiTexture::Flags flags, QRhiResourceUpdateBatch *rub, const QSize &size=QSize(64, 64), const QColor &fillColor=Qt::black)
QRhiCommandBuffer * commandBuffer() const
QSSGRhiDrawCallData & drawCallData(const QSSGRhiDrawCallDataKey &key)
QRhiShaderResourceBindings * srb(const QSSGRhiShaderResourceBindingList &bindings)
QRhiGraphicsPipeline * pipeline(const QSSGGraphicsPipelineStateKey &key, QRhiRenderPassDescriptor *rpDesc, QRhiShaderResourceBindings *srb)
QRhiSampler * sampler(const QSSGRhiSamplerDescription &samplerDescription)
QSSGRhiParticleData & particleData(const QSSGRenderGraphObject *particlesOrModel)
void ensureUniformBuffer(QRhiBuffer **ubuf)
int bindingForTexture(const char *name, int hint=-1)
void setUniform(char *ubufData, const char *name, const void *data, size_t size, int *storeIndex=nullptr, UniformFlags flags={})
QString normalized(NormalizationForm mode, QChar::UnicodeVersion version=QChar::Unicode_Unassigned) const
Returns the string in the given Unicode normalization mode, according to the given version of the Uni...
bool contains(const AT &t) const
The QVector2D class represents a vector or vertex in 2D space.
The QVector3D class represents a vector or vertex in 3D space.
static constexpr float dotProduct(QVector3D v1, QVector3D v2) noexcept
Returns the dot product of v1 and v2.
The QVector4D class represents a vector or vertex in 4D space.
\keyword 16-bit Floating Point Support\inmodule QtCore \inheaderfile QFloat16
Combined button and popup list for selecting options.
Q_DECL_CONSTEXPR float translateConstantAttenuation(float attenuation)
Q_DECL_CONSTEXPR float translateQuadraticAttenuation(float attenuation)
Q_DECL_CONSTEXPR float translateLinearAttenuation(float attenuation)
Q_CORE_EXPORT void qFloatToFloat16(qfloat16 *, const float *, qsizetype length) noexcept
constexpr float qDegreesToRadians(float degrees)
constexpr const T & qMin(const T &a, const T &b)
GLboolean GLboolean GLboolean b
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLenum GLsizei count
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLuint GLintptr offset
GLsizei GLsizei GLchar * source
GLsizei GLsizei GLuint * shaders
#define Q_QUICK3D_PROFILE_START(Type)
#define Q_QUICK3D_PROFILE_END_WITH_ID(Type, Payload, POID)
static int segmentCount(const QPainterPath &path, qreal pathLength)
QtPrivate::QRegularExpressionMatchIteratorRangeBasedForIterator begin(const QRegularExpressionMatchIterator &iterator)
#define QSSGRHICTX_STAT(ctx, f)
QRhiSampler::Filter toRhi(QSSGRenderTextureFilterOp op)
#define QSSG_MAX_NUM_LIGHTS
static QByteArray convertParticleData(QByteArray &dest, const QByteArray &data, bool convert)
static void fillTargetBlend(QRhiGraphicsPipeline::TargetBlend &targetBlend, QSSGRenderParticles::BlendMode mode)
static QT_BEGIN_NAMESPACE const QRhiShaderResourceBinding::StageFlags VISIBILITY_ALL
static void sortParticles(QByteArray &result, QList< QSSGRhiSortData > &sortData, const QSSGParticleBuffer &buffer, const QSSGRenderParticles &particles, const QVector3D &cameraDirection, bool animatedParticles)
SSL_CTX int(* cb)(SSL *ssl, unsigned char **out, unsigned char *outlen, const unsigned char *in, unsigned int inlen, void *arg)
unsigned long long quint64
QSqlQueryModel * model
[16]
myFilter draw(painter, QPoint(0, 0), originalPixmap)
QVector4D spotLightDir[4]
float pointLightLinearAtt[4]
QVector4D pointLightColor[4]
QVector4D spotLightPos[4]
float spotLightConstantAtt[4]
float spotLightLinearAtt[4]
float spotLightQuadAtt[4]
QVector4D spotLightColor[4]
float spotLightInnerConeAngle[4]
float pointLightConstantAtt[4]
float spotLightConeAngle[4]
float pointLightQuadAtt[4]
QVector4D pointLightPos[4]
static QSSGGraphicsPipelineStateKey create(const QSSGRhiGraphicsPipelineState &state, const QRhiRenderPassDescriptor *rpDesc, const QRhiShaderResourceBindings *srb)
struct QSSGGraphicsPipelineStateKey::@759 extra
QVector< quint32 > renderTargetDescription
size_t renderTargetDescriptionHash
int particleCount() const
int particlesPerSlice() const
struct QSSGParticlesRenderable::@767::@768 mainPass
QSSGRenderableImage * colorTable
QRhiShaderResourceBindings * srb
struct QSSGParticlesRenderable::@767 rhiRenderData
struct QSSGParticlesRenderable::@767::@771 reflectionPass
const QSSGShaderLightListView & lights
QSSGRenderableImage * firstImage
const QSSGRenderParticles & particles
QRhiGraphicsPipeline * pipeline
QSSGRenderTextureFilterOp m_mipFilterType
QSSGRenderTextureCoordOp m_horizontalTilingMode
QSSGRenderTextureFilterOp m_minFilterType
QSSGRenderTextureCoordOp m_verticalTilingMode
QSSGRenderTextureFilterOp m_magFilterType
QMatrix4x4 globalTransform
QVector3D getGlobalPos() const
QSSGRenderParticles::BlendMode m_blendMode
QVarLengthArray< QSSGRenderLight *, 4 > m_lights
QSSGRenderParticles::FeatureLevel m_featureLevel
QSSGParticleBuffer m_particleBuffer
QSSGRenderImageTexture m_texture
const QSSGRenderImage & m_imageNode
bool hasTransparency() const
const QMatrix4x4 & globalTransform
QSSGRenderableObjectFlags renderableFlags
QSSGRhiShaderResourceBindingList bindings
QSSGRhiGraphicsPipelineState ps
QRhiShaderResourceBindings * srb
QVector< quint32 > renderTargetDescription
QRhiGraphicsPipeline * pipeline
size_t renderTargetDescriptionHash
QSSGRhiInputAssemblerState ia
QRhiGraphicsPipeline::CullMode cullMode
QRhiGraphicsPipeline::TargetBlend targetBlend
QList< QSSGRhiSortData > sortData
void addUniformBuffer(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiBuffer *buf, int offset, int size)
void addTexture(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiTexture *tex, QRhiSampler *sampler)