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;
89 if (instanceTable->isBufferless())
92 const auto points = globalBounds.toQSSGBoxPointsNoEmptyCheck();
93 for (
int i = 0; i < instanceTable->count(); ++i) {
94 const QMatrix4x4 transform = instanceTable->getTransform(i);
95 for (
const QVector3D &point : points) {
96 globalBoundsInstancing.include(transform.map(point));
101QSSGParticlesRenderable::QSSGParticlesRenderable(QSSGRenderableObjectFlags inFlags,
102 const QVector3D &inWorldCenterPt,
104 const QMatrix4x4 &inGlobalTransform,
105 const QSSGRenderParticles &inParticles,
106 QSSGRenderableImage *inFirstImage,
107 QSSGRenderableImage *inColorTable,
108 const QSSGShaderLightListView &inLights,
110 QSSGShaderParticleMaterialKey inShaderKey)
111 : QSSGRenderableObject(Type::Particles,
114 inParticles.m_particleBuffer.bounds(),
115 inParticles.m_depthBiasSq)
117 , particles(inParticles)
118 , firstImage(inFirstImage)
119 , colorTable(inColorTable)
121 , globalTransform(inGlobalTransform)
123 , shaderDescription(inShaderKey)
126 globalBounds = inParticles.m_particleBuffer.bounds();
127 if (inParticles.type != QSSGRenderParticles::Type::ModelBlendParticle)
128 globalBounds.transform(inGlobalTransform);