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 if (!instanceTable || !anyLightHasShadows || !(inFlags.castsShadows() || inFlags.receivesShadows()))
79 QSSGBounds3 bounds = QSSGBounds3(instanceTable->getShadowBoundsMinimum(), instanceTable->getShadowBoundsMaximum());
80 if (!bounds.isEmpty() && bounds.isFinite()) {
81 globalBoundsInstancing = bounds;
86 const auto points = globalBounds.toQSSGBoxPointsNoEmptyCheck();
87 for (
int i = 0; i < instanceTable->count(); ++i) {
88 const QMatrix4x4 transform = instanceTable->getTransform(i);
89 for (
const QVector3D &point : points) {
90 globalBoundsInstancing.include(transform.map(point));
95QSSGParticlesRenderable::QSSGParticlesRenderable(QSSGRenderableObjectFlags inFlags,
96 const QVector3D &inWorldCenterPt,
98 const QMatrix4x4 &inGlobalTransform,
99 const QSSGRenderParticles &inParticles,
100 QSSGRenderableImage *inFirstImage,
101 QSSGRenderableImage *inColorTable,
102 const QSSGShaderLightListView &inLights,
104 QSSGShaderParticleMaterialKey inShaderKey)
105 : QSSGRenderableObject(Type::Particles,
108 inParticles.m_particleBuffer.bounds(),
109 inParticles.m_depthBiasSq)
111 , particles(inParticles)
112 , firstImage(inFirstImage)
113 , colorTable(inColorTable)
115 , globalTransform(inGlobalTransform)
117 , shaderDescription(inShaderKey)
120 globalBounds = inParticles.m_particleBuffer.bounds();
121 if (inParticles.type != QSSGRenderParticles::Type::ModelBlendParticle)
122 globalBounds.transform(inGlobalTransform);