diff options
Diffstat (limited to 'src/runtimerender/rendererimpl/qssglayerrenderdata.cpp')
-rw-r--r-- | src/runtimerender/rendererimpl/qssglayerrenderdata.cpp | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/runtimerender/rendererimpl/qssglayerrenderdata.cpp b/src/runtimerender/rendererimpl/qssglayerrenderdata.cpp index 5f972a6e..5ae54457 100644 --- a/src/runtimerender/rendererimpl/qssglayerrenderdata.cpp +++ b/src/runtimerender/rendererimpl/qssglayerrenderdata.cpp @@ -1243,6 +1243,18 @@ bool QSSGLayerRenderData::prepareModelsForRender(const RenderableNodeEntries &re if (maybeDebugDraw && debugDrawSystem->isEnabled(QSSGDebugDrawSystem::Mode::MeshLodNormal)) debugDrawSystem->debugNormals(*bufferManager, theModelContext, theSubset, subsetLevelOfDetail, (theModelCenter - camera->getGlobalPos()).length() * 0.01); + static auto checkF32TypeIndex = [&rhiCtx](QRhiVertexInputAttribute::Format f) { + if ((f == QRhiVertexInputAttribute::Format::Float4) + || (f == QRhiVertexInputAttribute::Format::Float3) + || (f == QRhiVertexInputAttribute::Format::Float2) + || (f == QRhiVertexInputAttribute::Format::Float)) { + return true; + } + if (!rhiCtx->rhi()->isFeatureSupported(QRhi::IntAttributes)) + qWarning() << "WARN: Model has non-integer type indices for skinning but current RHI backend doesn't support it!"; + return false; + }; + if (theMaterialObject->type == QSSGRenderGraphObject::Type::DefaultMaterial || theMaterialObject->type == QSSGRenderGraphObject::Type::PrincipledMaterial || theMaterialObject->type == QSSGRenderGraphObject::Type::SpecularGlossyMaterial) { @@ -1261,8 +1273,11 @@ bool QSSGLayerRenderData::prepareModelsForRender(const RenderableNodeEntries &re const auto boneCount = model.skin ? model.skin->boneCount : model.skeleton ? model.skeleton->boneCount : 0; renderer->defaultMaterialShaderKeyProperties().m_boneCount.setValue(theGeneratedKey, boneCount); - renderer->defaultMaterialShaderKeyProperties().m_usesFloatJointIndices.setValue( - theGeneratedKey, !rhiCtx->rhi()->isFeatureSupported(QRhi::IntAttributes)); + if (auto idJoint = theSubset.rhi.ia.inputs.indexOf(QSSGRhiInputAssemblerState::JointSemantic); idJoint != -1) { + const auto attr = theSubset.rhi.ia.inputLayout.attributeAt(idJoint); + renderer->defaultMaterialShaderKeyProperties().m_usesFloatJointIndices.setValue(theGeneratedKey, checkF32TypeIndex(attr->format())); + } + // Instancing renderer->defaultMaterialShaderKeyProperties().m_usesInstancing.setValue(theGeneratedKey, usesInstancing); // Morphing @@ -1319,8 +1334,10 @@ bool QSSGLayerRenderData::prepareModelsForRender(const RenderableNodeEntries &re const auto boneCount = model.skin ? model.skin->boneCount : model.skeleton ? model.skeleton->boneCount : 0; renderer->defaultMaterialShaderKeyProperties().m_boneCount.setValue(theGeneratedKey, boneCount); - renderer->defaultMaterialShaderKeyProperties().m_usesFloatJointIndices.setValue( - theGeneratedKey, !rhiCtx->rhi()->isFeatureSupported(QRhi::IntAttributes)); + if (auto idJoint = theSubset.rhi.ia.inputs.indexOf(QSSGRhiInputAssemblerState::JointSemantic); idJoint != -1) { + const auto attr = theSubset.rhi.ia.inputLayout.attributeAt(idJoint); + renderer->defaultMaterialShaderKeyProperties().m_usesFloatJointIndices.setValue(theGeneratedKey, checkF32TypeIndex(attr->format())); + } // Instancing bool usesInstancing = theModelContext.model.instancing() |