17QSSGModelContext::QSSGModelContext(
const QSSGRenderModel &inModel,
18 const QMatrix4x4 &inGlobalTransform,
19 const QMatrix3x3 &inNormalMatrix,
20 const QSSGRenderMvpArray &inModelViewProjections)
22 , globalTransform(inGlobalTransform)
23 , normalMatrix(inNormalMatrix)
24 , modelViewProjections(inModelViewProjections)
29QSSGSubsetRenderable::QSSGSubsetRenderable(Type type,
30 QSSGRenderableObjectFlags inFlags,
31 const QVector3D &inWorldCenterPt,
33 const QSSGRenderSubset &inSubset,
34 const QSSGModelContext &inModelContext,
36 quint32 inSubsetLevelOfDetail,
37 const QSSGRenderGraphObject &mat,
38 QSSGRenderableImage *inFirstImage,
39 QSSGShaderDefaultMaterialKey inShaderKey,
40 const QSSGShaderLightListView &inLights,
41 bool anyLightHasShadows)
42 : QSSGRenderableObject(type,
46 inModelContext.model.m_depthBiasSq,
47 inModelContext.model.instancingLodMin,
48 inModelContext.model.instancingLodMax)
49 , subsetLevelOfDetail(inSubsetLevelOfDetail)
51 , modelContext(inModelContext)
55 , firstImage(inFirstImage)
56 , shaderDescription(inShaderKey)
59 if (mat.type == QSSGRenderGraphObject::Type::CustomMaterial)
60 depthWriteMode =
static_cast<
const QSSGRenderCustomMaterial *>(&mat)->m_depthDrawMode;
62 depthWriteMode =
static_cast<
const QSSGRenderDefaultMaterial *>(&mat)->depthDrawMode;
64 const bool modelBlendParticle = (inModelContext.model.particleBuffer !=
nullptr
65 && inModelContext.model.particleBuffer->particleCount());
66 if (modelBlendParticle)
67 globalBounds = inModelContext.model.particleBuffer->bounds();
69 globalBounds.transform(inModelContext.globalTransform);
72 const QSSGRenderInstanceTable *instanceTable = inModelContext.model.instanceTable;
73 if (!instanceTable || !anyLightHasShadows || !(inFlags.castsShadows() || inFlags.receivesShadows()))
77 QSSGBounds3 bounds = QSSGBounds3(instanceTable->getShadowBoundsMinimum(), instanceTable->getShadowBoundsMaximum());
78 if (!bounds.isEmpty() && bounds.isFinite()) {
79 globalBoundsInstancing = bounds;
84 const auto points = globalBounds.toQSSGBoxPointsNoEmptyCheck();
85 for (
int i = 0; i < instanceTable->count(); ++i) {
86 const QMatrix4x4 transform = instanceTable->getTransform(i);
87 for (
const QVector3D &point : points) {
88 globalBoundsInstancing.include(transform.map(point));
93QSSGParticlesRenderable::QSSGParticlesRenderable(QSSGRenderableObjectFlags inFlags,
94 const QVector3D &inWorldCenterPt,
96 const QMatrix4x4 &inGlobalTransform,
97 const QSSGRenderParticles &inParticles,
98 QSSGRenderableImage *inFirstImage,
99 QSSGRenderableImage *inColorTable,
100 const QSSGShaderLightListView &inLights,
102 : QSSGRenderableObject(Type::Particles,
105 inParticles.m_particleBuffer.bounds(),
106 inParticles.m_depthBiasSq)
108 , particles(inParticles)
109 , firstImage(inFirstImage)
110 , colorTable(inColorTable)
112 , globalTransform(inGlobalTransform)
116 globalBounds = inParticles.m_particleBuffer.bounds();
117 if (inParticles.type != QSSGRenderParticles::Type::ModelBlendParticle)
118 globalBounds.transform(inGlobalTransform);