1// Copyright (C) 2008-2012 NVIDIA Corporation.
2// Copyright (C) 2019 The Qt Company Ltd.
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
4
5#ifndef QSSG_RENDER_DEFAULT_MATERIAL_SHADER_GENERATOR_H
6#define QSSG_RENDER_DEFAULT_MATERIAL_SHADER_GENERATOR_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/qssgrendermaterialshadergenerator_p.h>
20#include <QtQuick3DRuntimeRender/private/qssgrendershadercodegenerator_p.h>
21#include <QtQuick3DRuntimeRender/private/qssgrendershadowmap_p.h>
22#include <QtQuick3DRuntimeRender/private/qssgrenderlight_p.h>
23#include <QtQuick3DRuntimeRender/private/qssgrenderableimage_p.h>
24#include <QtQuick3DRuntimeRender/private/qssgrendershaderkeys_p.h>
25
26QT_BEGIN_NAMESPACE
27
28struct QSSGRenderableImage;
29struct QSSGShaderDefaultMaterialKeyProperties;
30struct QSSGShaderDefaultMaterialKey;
31struct QSSGLayerGlobalRenderProperties;
32struct QSSGMaterialVertexPipeline;
33
34struct Q_QUICK3DRUNTIMERENDER_EXPORT QSSGMaterialShaderGenerator
35{
36 struct LightVariableNames
37 {
38 QByteArray lightColor;
39 QByteArray lightSpecularColor;
40 QByteArray lightAttenuation;
41 QByteArray lightConstantAttenuation;
42 QByteArray lightLinearAttenuation;
43 QByteArray lightQuadraticAttenuation;
44 QByteArray normalizedDirection;
45 QByteArray lightDirection;
46 QByteArray lightPos;
47 QByteArray lightConeAngle;
48 QByteArray lightInnerConeAngle;
49 QByteArray relativeDistance;
50 QByteArray relativeDirection;
51 QByteArray spotAngle;
52 };
53
54 struct ShadowVariableNames
55 {
56 QByteArray shadowMapStem;
57 QByteArray shadowCubeStem;
58 QByteArray shadowMatrixStem;
59 QByteArray shadowCoordStem;
60 QByteArray shadowControlStem;
61 };
62
63 ~QSSGMaterialShaderGenerator() = default;
64
65 static const char* getSamplerName(QSSGRenderableImage::Type type);
66
67 static QSSGRhiShaderPipelinePtr generateMaterialRhiShader(const QByteArray &inShaderKeyPrefix,
68 QSSGMaterialVertexPipeline &vertexGenerator,
69 const QSSGShaderDefaultMaterialKey &key,
70 QSSGShaderDefaultMaterialKeyProperties &inProperties,
71 const QSSGShaderFeatures &inFeatureSet,
72 const QSSGRenderGraphObject &inMaterial,
73 const QSSGShaderLightListView &inLights,
74 QSSGRenderableImage *inFirstImage, QSSGShaderLibraryManager &shaderLibraryManager,
75 QSSGShaderCache &theCache);
76
77 static void setRhiMaterialProperties(const QSSGRenderContextInterface &,
78 QSSGRhiShaderPipeline &shaders,
79 char *ubufData,
80 QSSGRhiGraphicsPipelineState *inPipelineState,
81 const QSSGRenderGraphObject &inMaterial,
82 const QSSGShaderDefaultMaterialKey &inKey,
83 QSSGShaderDefaultMaterialKeyProperties &inProperties,
84 const QSSGRenderCamera &inCamera,
85 const QMatrix4x4 &inModelViewProjection,
86 const QMatrix3x3 &inNormalMatrix,
87 const QMatrix4x4 &inGlobalTransform,
88 const QMatrix4x4 &clipSpaceCorrMatrix,
89 const QMatrix4x4 &localInstanceTransform,
90 const QMatrix4x4 &globalInstanceTransform,
91 const QSSGDataView<float> &inMorphWeights,
92 QSSGRenderableImage *inFirstImage,
93 float inOpacity,
94 const QSSGLayerGlobalRenderProperties &inRenderProperties,
95 const QSSGShaderLightListView &inLights,
96 const QSSGShaderReflectionProbe &reflectionProbe,
97 bool receivesShadows,
98 bool receivesReflections,
99 const QVector2D *shadowDepthAdjust,
100 QRhiTexture *lightmapTexture);
101
102 static const char *directionalLightProcessorArgumentList();
103 static const char *pointLightProcessorArgumentList();
104 static const char *spotLightProcessorArgumentList();
105 static const char *ambientLightProcessorArgumentList();
106 static const char *specularLightProcessorArgumentList();
107 static const char *shadedFragmentMainArgumentList();
108 static const char *postProcessorArgumentList();
109 static const char *iblProbeProcessorArgumentList();
110 static const char *vertexMainArgumentList();
111 static const char *vertexInstancedMainArgumentList();
112
113private:
114 QSSGMaterialShaderGenerator() = delete;
115 Q_DISABLE_COPY(QSSGMaterialShaderGenerator)
116};
117
118namespace QtQuick3DEditorHelpers {
119namespace CustomMaterial {
120// NOTE: Returns a copy of the actual list, cache as needed!
121[[nodiscard]] Q_QUICK3DRUNTIMERENDER_EXPORT QList<QByteArrayView> reservedArgumentNames();
122}
123}
124
125QT_END_NAMESPACE
126#endif
127

source code of qtquick3d/src/runtimerender/qssgrenderdefaultmaterialshadergenerator_p.h