19QSSGModelContext::QSSGModelContext(
const QSSGRenderModel &inModel,
20 const QMatrix4x4 &inGlobalTransform,
21 const QMatrix3x3 &inNormalMatrix,
22 const QSSGRenderMvpArray &inModelViewProjections)
24 , globalTransform(inGlobalTransform)
25 , normalMatrix(inNormalMatrix)
26 , modelViewProjections(inModelViewProjections)
31QSSGSubsetRenderable::QSSGSubsetRenderable(Type type,
32 QSSGRenderableObjectFlags inFlags,
33 const QVector3D &inWorldCenterPt,
35 const QSSGRenderSubset &inSubset,
36 const QSSGModelContext &inModelContext,
38 quint32 inSubsetLevelOfDetail,
39 const QSSGRenderGraphObject &mat,
40 QSSGRenderableImage *inFirstImage,
41 QSSGShaderDefaultMaterialKey inShaderKey,
42 const QSSGShaderLightListView &inLights,
43 bool anyLightHasShadows)
44 : QSSGRenderableObject(type,
48 inModelContext.model.m_depthBiasSq,
49 inModelContext.model.instancingLodMin,
50 inModelContext.model.instancingLodMax)
51 , subsetLevelOfDetail(inSubsetLevelOfDetail)
53 , modelContext(inModelContext)
57 , firstImage(inFirstImage)
58 , shaderDescription(inShaderKey)
61 if (mat.type == QSSGRenderGraphObject::Type::CustomMaterial)
62 depthWriteMode =
static_cast<
const QSSGRenderCustomMaterial *>(&mat)->m_depthDrawMode;
64 depthWriteMode =
static_cast<
const QSSGRenderDefaultMaterial *>(&mat)->depthDrawMode;
66 const bool modelBlendParticle = (inModelContext.model.particleBuffer !=
nullptr
67 && inModelContext.model.particleBuffer->particleCount());
68 if (modelBlendParticle)
69 globalBounds = inModelContext.model.particleBuffer->bounds();
71 globalBounds.transform(inModelContext.globalTransform);
74 const QSSGRenderInstanceTable *instanceTable = inModelContext.model.instanceTable;
75 isInstanced = instanceTable !=
nullptr;
76 if (!instanceTable || !anyLightHasShadows || !(inFlags.castsShadows() || inFlags.receivesShadows()))
80 QSSGBounds3 bounds = QSSGBounds3(instanceTable->getShadowBoundsMinimum(), instanceTable->getShadowBoundsMaximum());
81 if (!bounds.isEmpty() && bounds.isFinite()) {
82 globalBoundsInstancing = bounds;
87 const auto points = globalBounds.toQSSGBoxPointsNoEmptyCheck();
88 for (
int i = 0; i < instanceTable->count(); ++i) {
89 const QMatrix4x4 transform = instanceTable->getTransform(i);
90 for (
const QVector3D &point : points) {
91 globalBoundsInstancing.include(transform.map(point));
96QSSGParticlesRenderable::QSSGParticlesRenderable(QSSGRenderableObjectFlags inFlags,
97 const QVector3D &inWorldCenterPt,
99 const QMatrix4x4 &inGlobalTransform,
100 const QSSGRenderParticles &inParticles,
101 QSSGRenderableImage *inFirstImage,
102 QSSGRenderableImage *inColorTable,
103 const QSSGShaderLightListView &inLights,
105 QSSGShaderParticleMaterialKey inShaderKey)
106 : QSSGRenderableObject(Type::Particles,
109 inParticles.m_particleBuffer.bounds(),
110 inParticles.m_depthBiasSq)
112 , particles(inParticles)
113 , firstImage(inFirstImage)
114 , colorTable(inColorTable)
116 , globalTransform(inGlobalTransform)
118 , shaderDescription(inShaderKey)
121 globalBounds = inParticles.m_particleBuffer.bounds();
122 if (inParticles.type != QSSGRenderParticles::Type::ModelBlendParticle)
123 globalBounds.transform(inGlobalTransform);