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 void updateBackgroundUniforms(const QSSGRenderContextInterface &sgContext,
65 QSSGPassKey passKey,
66 const QVarLengthArray<QMatrix4x4, 2> &inverseProjections,
67 const QVarLengthArray<QMatrix4x4, 2> &viewRotations,
68 float adjustY,
69 float exposure);
70
71 QByteArray fragmentShaderSource;
72
73 QByteArray shaderPathKey = "sky material --";
74
75 bool isDirty = true;
76 bool isFragmentShaderDirty = true;
77 bool isBackgroundShaderDirty = true;
78
79 QSSGRhiShaderResourceBindingList bindings;
80 QSSGRhiShaderResourceBindingList backgroundBindings;
81
82private:
83 QSSGRhiShaderPipelinePtr buildPipeline(const QSSGRenderContextInterface &sgContext,
84 QByteArray vertexShader,
85 const QSSGShaderCustomMaterialAdapter::StringPairList &vertexViewDependentUniforms,
86 const QSSGShaderCustomMaterialAdapter::StringPairList &vertexUniforms,
87 const QByteArray &fragmentMainSnippet,
88 const QSSGShaderCustomMaterialAdapter::StringPairList &fragmentUniforms,
89 const QSSGShaderFeatures &features,
90 int viewCount,
91 const QByteArray &cacheKeyTag);
92
93 quint32 m_backgroundTonemapKey = quint32(-1);
94 int m_backgroundViewCount = 0;
95};
96
97QT_END_NAMESPACE
98
99#endif // QSSG_RENDER_SKY_MATERIAL_H
void setDescription(QRhi *rhi, QRhiTextureRenderTargetDescription rtDesc, QRhiTextureRenderTarget::Flags={})
QRhiVertexInputAttribute::Format toVertexInputFormat(QSSGRenderComponentType compType, quint32 numComps)
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 QString getUBMemberSizeWarning(QLatin1StringView name, qsizetype correctedSize, qsizetype requestedSize)