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