Fixed more shadows

This commit is contained in:
Brandon Mak 2023-03-10 19:22:50 +08:00
parent 39bebd1db4
commit 1d16bd2744
5 changed files with 36 additions and 17 deletions

View File

@ -26,12 +26,12 @@ layout (std430, set = 2, binding = 1) buffer AnimBoneMatrices
void main() void main()
{ {
// // Compute bone matrix // // Compute bone matrix
// mat4 boneMatrix = BoneMatrices.data[firstBoneIndex + aBoneIndices[0]] * aBoneWeights[0]; mat4 boneMatrix = BoneMatrices.data[firstBoneIndex + aBoneIndices[0]] * aBoneWeights[0];
// boneMatrix += BoneMatrices.data[firstBoneIndex + aBoneIndices[1]] * aBoneWeights[1]; boneMatrix += BoneMatrices.data[firstBoneIndex + aBoneIndices[1]] * aBoneWeights[1];
// boneMatrix += BoneMatrices.data[firstBoneIndex + aBoneIndices[2]] * aBoneWeights[2]; boneMatrix += BoneMatrices.data[firstBoneIndex + aBoneIndices[2]] * aBoneWeights[2];
// boneMatrix += BoneMatrices.data[firstBoneIndex + aBoneIndices[3]] * aBoneWeights[3]; boneMatrix += BoneMatrices.data[firstBoneIndex + aBoneIndices[3]] * aBoneWeights[3];
// clip space for rendering // clip space for rendering
gl_Position = cameraData.vpMat * worldTransform * vec4 (aVertexPos, 1.0f); // gl_Position = cameraData.vpMat * worldTransform * vec4 (aVertexPos, 1.0f);
// gl_Position = cameraData.vpMat * worldTransform * boneMatrix * vec4 (aVertexPos, 1.0f); gl_Position = cameraData.vpMat * worldTransform * boneMatrix * vec4 (aVertexPos, 1.0f);
} }

View File

@ -726,16 +726,34 @@ namespace SHADE
cmdBuffer->BindVertexBuffer(SHGraphicsConstants::VertexBufferBindings::BONE_MATRIX_FIRST_INDEX, transformDataBuffer[frameIndex], 0); cmdBuffer->BindVertexBuffer(SHGraphicsConstants::VertexBufferBindings::BONE_MATRIX_FIRST_INDEX, transformDataBuffer[frameIndex], 0);
} }
auto const& descMappings = SHGraphicsPredefinedData::GetMappings(SHGraphicsPredefinedData::SystemType::BATCHING); if (IsAnimated())
if (instanceDataDescSet[frameIndex])
{ {
cmdBuffer->BindDescriptorSet auto const& descMappings = SHGraphicsPredefinedData::GetMappings(SHGraphicsPredefinedData::SystemType::BATCHING_ANIM);
( if (instanceDataDescSet[frameIndex])
instanceDataDescSet[frameIndex], {
SH_PIPELINE_TYPE::GRAPHICS, cmdBuffer->BindDescriptorSet
descMappings.at(SHPredefinedDescriptorTypes::PER_INSTANCE_BATCH), (
dynamicOffset instanceDataDescSet[frameIndex],
); SH_PIPELINE_TYPE::GRAPHICS,
descMappings.at(SHPredefinedDescriptorTypes::PER_INSTANCE_ANIM_BATCH),
dynamicOffset
);
}
}
else
{
auto const& descMappings = SHGraphicsPredefinedData::GetMappings(SHGraphicsPredefinedData::SystemType::BATCHING);
if (instanceDataDescSet[frameIndex])
{
cmdBuffer->BindDescriptorSet
(
instanceDataDescSet[frameIndex],
SH_PIPELINE_TYPE::GRAPHICS,
descMappings.at(SHPredefinedDescriptorTypes::PER_INSTANCE_BATCH),
dynamicOffset
);
}
} }
cmdBuffer->DrawMultiIndirect(drawDataBuffer[frameIndex], static_cast<uint32_t>(drawData.size())); cmdBuffer->DrawMultiIndirect(drawDataBuffer[frameIndex], static_cast<uint32_t>(drawData.size()));
cmdBuffer->EndLabeledSegment(); cmdBuffer->EndLabeledSegment();

View File

@ -37,7 +37,8 @@ namespace SHADE
{SHPredefinedDescriptorTypes::STATIC_DATA, 0}, {SHPredefinedDescriptorTypes::STATIC_DATA, 0},
{SHPredefinedDescriptorTypes::CAMERA, 1}, {SHPredefinedDescriptorTypes::CAMERA, 1},
{SHPredefinedDescriptorTypes::PER_INSTANCE_ANIM_BATCH, 2}, {SHPredefinedDescriptorTypes::PER_INSTANCE_ANIM_BATCH, 2},
}); {SHPredefinedDescriptorTypes::RENDER_GRAPH_RESOURCE, 3},
});
perSystemData[SHUtilities::ConvertEnum(SystemType::TEXT_RENDERING)].descMappings.AddMappings perSystemData[SHUtilities::ConvertEnum(SystemType::TEXT_RENDERING)].descMappings.AddMappings
({ ({

View File

@ -497,7 +497,7 @@ namespace SHADE
} }
// get target node // get target node
auto targetNode = nodes.begin() + nodeIndexing.at(nodeToAddAfter); auto targetNode = nodes.begin() + nodeIndexing.at(nodeToAddAfter) + 1;
auto node = nodes.insert(targetNode, renderGraphStorage->resourceHub->Create<SHRenderGraphNode>(nodeName, renderGraphStorage, std::move(descInitParams), std::vector<Handle<SHRenderGraphNode>>(), true)); auto node = nodes.insert(targetNode, renderGraphStorage->resourceHub->Create<SHRenderGraphNode>(nodeName, renderGraphStorage, std::move(descInitParams), std::vector<Handle<SHRenderGraphNode>>(), true));
ReindexNodes (); ReindexNodes ();