Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qssgrenderskymaterial_p.h
Go to the documentation of this file.
1// Copyright (C) 2026 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QSSG_RENDER_SKY_MATERIAL_H
6#define QSSG_RENDER_SKY_MATERIAL_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtQuick3DRuntimeRender/private/qssgrendergraphobject_p.h>
20#include <QtQuick3DRuntimeRender/private/qssgrenderhelpers_p.h>
21#include <QtQuick3DRuntimeRender/private/qssgshadermaterialadapter_p.h>
22#include <QtQuick3DRuntimeRender/private/qssgrendershadercache_p.h>
23
25
26class QSSGRhiEffectSystem;
27
28struct Q_QUICK3DRUNTIMERENDER_EXPORT QSSGRenderSkyMaterial : public QSSGRenderGraphObject
29{
30 // Background source: Cubemap samples the IBL radiance cube; ScreenSpace* evaluate the
31 // sky shader directly on screen at the given scale. See the SkyMaterial QML docs.
32 enum class SkyboxMode { Cubemap, ScreenSpaceFull, ScreenSpaceHalf, ScreenSpaceQuarter };
33
34 int radianceMapSize = 512;
35 int iblSampleCount = 16;
36 int iblSamplesPerFrame = 0;
37 int iblRenderFrames = 0;
38 SkyboxMode skyboxMode = SkyboxMode::Cubemap;
39 bool wantsMoreFrames = false;
40 bool enableIBL = false;
41
42 QSSGRenderSkyMaterial();
43 ~QSSGRenderSkyMaterial();
44
45 QList<QSSGBaseTypeProperty> propertyUniforms;
46
47 // Cube-face pipeline used to render the procedural sky into the IBL environment cube.
48 QSSGRhiShaderPipelinePtr iblPassPipeline;
49 // Screen-space pipeline used to evaluate the sky shader directly into the visible
50 // background (fullscreen quad), decoupled from the IBL cube.
51 QSSGRhiShaderPipelinePtr backgroundPipeline;
52
53 QSSGRhiShaderPipelinePtr ensurePipeline(const QSSGRenderContextInterface &sgContext);
54 QSSGRhiShaderPipelinePtr ensureBackgroundPipeline(const QSSGRenderContextInterface &sgContext,
55 const QSSGShaderFeatures &tonemapFeatures,
56 quint32 tonemapKey,
57 int viewCount);
58
59 // returns uniform stride per face
60 quint32 updateUniforms(const QSSGRenderContextInterface &sgContext,
61 QSSGPassKey passKey,
62 const QMatrix4x4 &mvp,
63 const QVarLengthArray<QMatrix4x4, 6> views,
64 QRhiResourceUpdateBatch *rub);
65 void updateBackgroundUniforms(const QSSGRenderContextInterface &sgContext,
66 QSSGPassKey passKey,
67 const QVarLengthArray<QMatrix4x4, 2> &inverseProjections,
68 const QVarLengthArray<QMatrix4x4, 2> &viewRotations,
69 float adjustY,
70 float exposure,
71 QRhiResourceUpdateBatch *rub);
72
73 QByteArray fragmentShaderSource;
74
75 QByteArray shaderPathKey = "sky material --";
76
77 bool isDirty = true;
78 bool isFragmentShaderDirty = true;
79 bool isBackgroundShaderDirty = true;
80
81 QSSGRhiShaderResourceBindingList bindings;
82 QSSGRhiShaderResourceBindingList backgroundBindings;
83
84private:
85 QSSGRhiShaderPipelinePtr buildPipeline(const QSSGRenderContextInterface &sgContext,
86 QByteArray vertexShader,
87 const QSSGShaderCustomMaterialAdapter::StringPairList &vertexViewDependentUniforms,
88 const QSSGShaderCustomMaterialAdapter::StringPairList &vertexUniforms,
89 const QByteArray &fragmentMainSnippet,
90 const QSSGShaderCustomMaterialAdapter::StringPairList &fragmentUniforms,
91 const QSSGShaderFeatures &features,
92 int viewCount,
93 const QByteArray &cacheKeyTag);
94
95 quint32 m_backgroundTonemapKey = quint32(-1);
96 int m_backgroundViewCount = 0;
97};
98
99QT_END_NAMESPACE
100
101#endif // QSSG_RENDER_SKY_MATERIAL_H
void setDescription(QSSGRhiContext &rhiCtx, QRhiTextureRenderTargetDescription rtDesc, QRhiTextureRenderTarget::Flags={})
void reset(QSSGRhiResourceRegistry *registry)
QShaderDescription::VariableType samplerType(const QSSGRhiShaderPipeline &shaders, const QByteArray &name)
QRhiVertexInputAttribute::Format toVertexInputFormat(QSSGRenderComponentType compType, quint32 numComps)
QRhiTexture * dummyTextureForSampler(QSSGRhiContext *rhiCtx, QShaderDescription::VariableType samplerType, QRhiResourceUpdateBatch *rub, int arraySize, const QSize &size, const QColor &fillColor)
QRhiGraphicsPipeline::Topology toTopology(QSSGRenderDrawMode drawMode)
void bakeVertexInputLocations(QSSGRhiInputAssemblerState *ia, const QSSGRhiShaderPipeline &shaders, int instanceBufferBinding)
Combined button and popup list for selecting options.
Q_TRACE_POINT(qtcore, QCoreApplication_postEvent_exit)
Q_TRACE_POINT(qtcore, QFactoryLoader_update, const QString &fileName)
Q_TRACE_POINT(qtquick3d, QSSG_renderFrame_entry, int width, int height)
static void releaseAutoLodDataIf(QHash< const QSSGRenderModel *, QSSGRhiInstanceBufferData > &instanceBuffersPerModel, Predicate release)
static QString getUBMemberSizeWarning(QLatin1StringView name, qsizetype correctedSize, qsizetype requestedSize)
static QByteArray asLookupKey(QByteArrayView name)